Advertisement
Uhuuuyy

login-page.html

Jan 18th, 2024
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 2.05 KB | Source Code | 0 0
  1. <!--
  2. @license
  3. Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
  4. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
  5. The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
  6. The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
  7. Code distributed by Google as part of the polymer project is also
  8. subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
  9. -->
  10.  
  11. <link rel="import" href="../bower_components/polymer/polymer-element.html">
  12. <link rel="import" href="shared-styles.html">
  13.  
  14. <dom-module id="login-page">
  15.   <template>
  16.     <style include="shared-styles">
  17.       :host {
  18.         display: block;
  19.  
  20.         padding: 10px;
  21.       }
  22.     </style>
  23.  
  24.     <div class="card">
  25.       <div class="circle">1</div>
  26.       <h1>Login</h1>
  27.       <input type="text" name="username" value="{{username}}" on-input="handleChange" placeholder="Username">
  28.       <input type="password" name="password" value="{{password}}" on-input="handleChange" placeholder="Password">
  29.       <button on-click="handleSubmit">Submit</button>
  30.     </div>
  31.   </template>
  32.  
  33.   <script>
  34.     class LoginPage extends Polymer.Element {
  35.       static get is() { return 'login-page'; }
  36.       static get properties() {
  37.         return{
  38.           username: String,
  39.           password: String,
  40.           isAdmin: {
  41.             type: Boolean,
  42.             notify: true
  43.           }
  44.         }
  45.       }
  46.      
  47.       handleChange(e) {
  48.         this[e.target.name] = e.target.value
  49.       }
  50.  
  51.       handleSubmit(e) {
  52.         if(this.username === "admin" && this.password === "admin") {
  53.           this.isAdmin = true
  54.           window.history.pushState({}, null, "/message-page")
  55.           windows.dispatchEvent(new CustomEvent("location-changed"))
  56.           return
  57.         }
  58.  
  59.         this.isAdmin = false
  60.         alert("Mohon login sebagai admin")
  61.       }
  62.     }
  63.  
  64.     window.customElements.define(LoginPage.is, LoginPage);
  65.   </script>
  66. </dom-module>
Tags: Inter6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement