A simple webapp of the whole

Source: Internet
Author: User

Before I start, I'll give you the demo link http://xqhuadou.com/demo1/index.html of the previous tab. I believe it should be a very good feeling, but this one has been modified before.

The production process I will not say more, you can directly see the source code.

OK, now start our webapp process, since it's app, it's necessary to have an icon, just like this

  

Now we can play people to find fault, is not and the local app very much like, open the words Pocket content is the effect on the right.

  

OK, no matter what kind of drawing software we use, we will use the OK, to make a chic icon is not a problem, but note that the size of the icon to a variety of, because the Android screen fragmentation, we have to consider the different screen icon size,

57*57, 120*120, 196*196 three PNG images of different sizes. With the icon we should how to use, since we do webapp, he is actually a Web page, before the icon on the desktop is actually just a shortcut to open the page.

Now we need to make the front-end Web page, the application of the homepage is like, I believe in HTML to make such a page layout is not difficult, but we need to write a lot of HTML meta tags, like this

  

<Html><Head><MetaName= "Renderer"Content= "WebKit"><MetaName= "Apple-mobile-web-app-capable"Content= "Yes"><MetaName= ' Apple-touch-fullscreen 'Content= ' Yes '><MetaName= "Full-screen"Content= "Yes"><MetaName= "Apple-mobile-web-app-status-bar-style"Content= "BLACK"><MetaName= "Format-detection"Content= "Telephone=no"><MetaName= "Format-detection"Content= "Address=no"><!--Desktop shortcut icons-<LinkRel= "Apple-touch-icon-precomposed"Sizes= "57x57"Href= "Images/ico-57x57.png"><LinkRel= "Apple-touch-icon-precomposed"Sizes= "120x120"Href= "Images/ico-120x120.png"><LinkRel= "Apple-touch-icon-precomposed"Sizes= "196x196" Href=" Images/ico-196x196.png " > <meta http-equiv= "Content-type"  Content= "text/html; Charset=utf-8 "/> <!--  screen fit --> <meta name= "viewport"  Content= "width=device-width,initial-scale=1, maximum-scale=1, minimum-scale=1, User-scalable=no ">         

Above these many labels, in fact the most important wine is the screen adaptation of the META tag content, is the document width is equal to the width of the device screen, and does not allow amplification, so the next we write all the div element width can not be fixed width, because, If you want to make sure that the full screen element is displayed on a screen with a different screen size, it's easy to think of a 100% percent width setting. Remember that HTML5 has a lot of new features to support us in making such an application.

General CSS style I will not say a few, to tell a few places to pay attention to, under normal circumstances, click on the mobile phone page <a></a> is highlighted, and the highlight for different phones are not the same, so we should remove such a display, Add this CSS to the a tag.

a{text-decoration:none;  Color:#333333;  -webkit-touch-callout:none;  -webkit-tap-highlight-color:Rgba (61,194,168,1);}       

Because it is a web, we can not guarantee that every open device is a mobile phone, it is possible to open this page is a PC, so it is best for us to make a little response. Just like this.

  

While it's not cool to watch on a PC, at least we make a difference, and as a user you should be able to feel something different. Of course, for the siege Lion This is only the code can solve, to a media query, the same HTML5 credit, like this

. Page{width:60%;margin:0 Auto;}. Log_reg{width:60%;Margin-left:-30%;}@media screen and (max-width:823px){. page{width:80%;}. Log_reg{width:80%;Margin-left:-40%;}} @media screen and (max-width:598px){. page{width:90%;}. Log_reg{width:90%;Margin-left:-45%;}} @media screen and (max-width:480px){. page{width:100%;}. Log_reg{width:90%;Margin-left:-45%;}}

With the above-mentioned basis, it is not difficult to write the above interface, the next task is the focus, functional development. I'm not going to say much about the backstage, I'm just explaining this simple application server java. This app goes out to register and login there are only two other functions, one is to express the mood, the second is to watch, that is, comments. Let's start by logging in. JS code on the previous segment

//Login Registration Component Operation        var$ze = $ (". Ze");//Masking Components        var$log _reg_warp = $ (". Log_reg_warp");//sign in and register an outer package component    var$oli = $ (". Topbar li"); var$log _reg = $ (". Log_reg");//Entire Login Component    var$check = $ ("#check");//Prompt information Component$to _log.click (function() {$log _reg.animate ({top:65});        $ze. Show (); //automatically fill in User name and password        if(Localstorage.account) {$ ("#account"). Val (Localstorage.account); $("#password"). Val (Localstorage.password);    }        }); $("#close"). Click (function() {$log _reg.animate ({top:-230});        $ze. Hide ();            });  for(vari=0; i< $oli. length;i++) {$oli [I].index=[i]; }        //Login Registration Interface Switch$oli. Click (function(){        $( This). addclass ("Activ"). Siblings (). Removeclass ("Activ"); $log _reg_warp.animate ({left:- This. index*100+ "%"}, "slow"); $check. Text (" ");        }); //Login Action$ ("#log"). Click (function(){        varAccount = $.trim ($ ("#account"). Val ());//get account to remove space        varPassword = $.trim ($ ("#password"). Val ());//Get password Remove space$.ajax ({URL:' Useraction_log_ajax ', Data:{account:account,password:password}, type:' Post ', Success:function(data) {Switch(data) { Case' 0 '://returns 0 Login success$to _log.find ("span"). Text (account);//Modify Login Status$check. Text ("");//Remove the hint message$log _reg.animate ({top:-230});//Login Component Hide$ze. Hide ();//Mask Layer HideSessionstorage.islog =true; //locally Stored user name and passwordLocalstorage.account =Account ; Localstorage.password=password;  Break; //1 User name or password is returned incorrectly                     Case' 1 ': $check. Text ("The user name or password is incorrect"); Flash (' #check ', 5,8,50);  Break; default: $check. Text ("The programmer is not, the system is not happy."); }}, Error:function() {$check. Text ("The programmer is not, the system is not happy.");                }            });            }); //Registration Action$ ("#reg"). Click (function(){        varAccount = $.trim ($ ("#account"). Val ());//get account to remove space        varPassword = $.trim ($ ("#password"). Val ());//Get password Remove space        //Registration Request$.ajax ({URL:' Useraction_reg_ajax ', Data:{account:account,password:password}, type:' Post ', Success:function(data) {//user name is occupied return 2//user name available return 0//username password format incorrect return 1                Switch(data) {//returns 0 The registration succeeds in performing the next operation                 Case' 0 ': $check. Text ("Registration is successful!" Can log in now! ");  Break; //1 User name or password is returned incorrectly                 Case' 1 ': $check. Text ("The user name or password is not in the correct format"); Flash (' #check ', 5,8,50);  Break; //returns 2 user name occupied                 Case' 2 ': $check. Text ("The user name has been robbed!" Whining! Change a "); Flash (' #check ', 5,8,50);  Break; default: $check. Text ("The programmer is not, the system is not happy."); }                            },            //error prompts the system to be busyErrorfunction() {$check. Text ("The programmer is not, the system is not happy.");            }                    }); });

Say so much, may still be unintelligible, you still first experience it! Details will be explained in detail later. Http://www.xqhuadou.com. Time problem is not compatible, WebKit kernel browser is no problem, preferably mobile phone, experience is the best.

In the last promotional picture, it feels like it's not an instant tall up,

 

A simple webapp of the whole

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.