Advertisement
vmonsores

Untitled

Mar 30th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.68 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--HTML5 doctype-->
  3. <html>
  4.  
  5. <head>
  6.  
  7. <title>Login View Template</title>
  8. <meta http-equiv="Content-type" content="text/html; charset=utf-8">
  9. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, minimal-ui">
  10. <meta name="apple-mobile-web-app-capable" content="yes" />
  11. <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
  12. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  13. <link rel="stylesheet" type="text/css" href="lib/appframework/icons.css" />
  14. <link rel="stylesheet" type="text/css" href="lib/appframework/af.ui.css" />
  15.  
  16. <script type="text/javascript" charset="utf-8" src="lib/jquery.min.js"></script>
  17. <script type="text/javascript" charset="utf-8" src="lib/fastclick.min.js"></script>
  18. <script type="text/javascript" charset="utf-8" src="lib/appframework/appframework.ui.min.js"></script>
  19.  
  20. <script src='cordova.js'></script>
  21.  
  22. <script>
  23.  
  24. $(document).ready(function(){
  25.  
  26. $("#main").bind("panelbeforeload", startApp);
  27. // setup signin and signup button events
  28. $("#login").on("click", function(){
  29. signIn();
  30. });
  31.  
  32. $("#register").on("click", function(){
  33. signUp();
  34. });
  35.  
  36. });
  37.  
  38. function signIn(){
  39. var valid_login = false;
  40.  
  41. //Pega valores digitado
  42. var username = $('#usuario').val();
  43. var senha = $('#senha').val();
  44.  
  45. //Pega dados do localstorage
  46. var usuarioLocal = JSON.parse(localStorage.getItem('usuario'));
  47.  
  48. if(usuarioLocal){
  49. //Compara os dados enviados com os dados local
  50. if(usuarioLocal.username == username && usuarioLocal.password == senha){
  51. valid_login = true;
  52. }
  53. }
  54.  
  55.  
  56.  
  57.  
  58. if(valid_login){
  59. $.afui.loadContent("#main", null, null, "fade");
  60. }
  61. else
  62. {
  63. //Example use of the error toast api
  64. var opts={
  65. message:"Usuário ou senha incorretos",
  66. position:"tc",
  67. delay:2000,
  68. autoClose:true,
  69. type:"error"
  70. };
  71. $.afui.toast(opts);
  72. }
  73. }
  74.  
  75. function signUp(){
  76.  
  77. //example client side validation
  78. if ($("#password").val() === $("#confirmpassword").val())
  79. {
  80. //Pega os dados do formulario
  81. var dados = {
  82. name: $('#name').val(),
  83. email: $('#email').val(),
  84. username: $('#username').val(),
  85. password:$('#password').val(),
  86. }
  87.  
  88. var optError = {
  89. message:"Todos campos são obrigatorio!",
  90. position:"tc",
  91. delay:2000,
  92. autoClose:true,
  93. type:"error"
  94.  
  95. }
  96.  
  97. //Verifica se tem algum vazio
  98. if(!dados.name){
  99. $.afui.toast(optError);
  100. }else if(!dados.email){
  101. return $.afui.toast(optError);
  102. }else if(!dados.username){
  103. return $.afui.toast(optError);
  104. }else if(!dados.password){
  105. return $.afui.toast(optError);
  106. }else{
  107. var usuario = JSON.stringify(dados);
  108. localStorage.setItem('usuario', usuario)
  109. //render main view
  110. $.afui.loadContent("#main", null, null, "fade");
  111. //Example use of the success toast
  112. var opts={
  113. message:"Account Created",
  114. position:"tc",
  115. delay:2000,
  116. autoClose:true,
  117. type:"success"
  118. };
  119. $.afui.toast(opts);
  120. }
  121. }
  122. else
  123. {
  124. //Example use of the error toast
  125. var opts={
  126. message:"password e confirmação não estm iguais! Verifique.",
  127. position:"tc",
  128. delay:2000,
  129. autoClose:true,
  130. type:"error"
  131. };
  132. $.afui.toast(opts);
  133. }
  134.  
  135.  
  136. }
  137.  
  138. function startApp(){
  139. // clears all back button history
  140. $.afui.clearHistory();
  141.  
  142. // your app code here
  143. }
  144.  
  145. </script>
  146.  
  147. </head>
  148.  
  149. <body>
  150.  
  151. <div id="splashscreen" class='ui-loader heavy'>
  152. App Framework - Login View
  153. <br>
  154. <br>
  155. <span class='ui-icon ui-icon-loading spin'></span>
  156. <h1>Starting app</h1>
  157. </div>
  158.  
  159. <div class="view" id="mainview">
  160. <header>
  161. <h1>Login View Example</h1>
  162. </header>
  163.  
  164. <div class="pages">
  165.  
  166. <!-- Welcome View -->
  167. <div class="panel" data-title="Welcome" id="page1" data-header="none" data-footer="none" selected="true">
  168. <div style="text-align:center">
  169. <br>
  170. <br>
  171. <p>This is space for welcome message</p>
  172. <br>
  173. <br>
  174. </div>
  175. <ul class="list inset">
  176. <li><a href="#signin" class="icon user" style="text-align:center">Login</a></li>
  177. <li><a href="#signup" class="icon pencil" style="text-align:center">Register</a></li>
  178. </ul>
  179. </div>
  180.  
  181. <!-- Login View -->
  182. <div class="panel" data-title="Login" id="signin" data-footer="none">
  183. <div style="text-align:center">
  184. <br>
  185. <br>
  186. <p>This is space for login message</p>
  187. <br>
  188. <br>
  189. </div>
  190. <input name="username" id="usuario" type="text" placeholder="username" />
  191. <input name="password" id="senha" type="password" placeholder="password" />
  192. <a class="button block" href="#" id="login">Login</a>
  193. </div>
  194.  
  195. <!-- Register View -->
  196. <div class="panel" data-title="Register" id="signup" data-footer="none">
  197. <div style="text-align:center">
  198. <br>
  199. <br>
  200. <p>This is space for register message</p>
  201. <br>
  202. <br>
  203. </div>
  204. <input name="name" type="text" placeholder="Name" id="name" />
  205. <input name="email" type="text" placeholder="Email" id="email" />
  206. <input name="username" type="text" placeholder="Username" id="username" />
  207. <input name="password" type="password" placeholder="Password" id="password" />
  208. <input name="password2" type="password" placeholder="Confirm Password" id="confirmpassword" />
  209. <a class="button block" href="#" id="register">Register</a>
  210. </div>
  211.  
  212. <!-- Main App View -->
  213. <div class="panel" data-title="Start" id="main">
  214. <a href="index2.html"></a>
  215. <p>This is App page after user has signed in...</p>
  216. </div>
  217. </div>
  218. </div>
  219.  
  220. </body>
  221.  
  222. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement