{"size": 1743, "ext": "js", "max_stars_repo_path": "internal/view/js/login.min.js", "max_stars_repo_name": "w-k-s/duit", "max_stars_repo_stars_event_min_datetime": "2020-03-22T16:01:41.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T07:32:57.000Z", "max_issues_repo_path": "internal/view/js/login.min.js", "max_issues_repo_name": "w-k-s/duit", "max_issues_repo_issues_event_min_datetime": "2020-03-24T05:42:58.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-30T05:15:38.000Z", "max_forks_repo_path": "internal/view/js/login.min.js", "max_forks_repo_name": "w-k-s/duit", "max_forks_repo_forks_event_min_datetime": "2020-03-22T21:32:28.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-02T14:04:53.000Z"}
{"max_stars_count": 157, "max_issues_count": 2, "max_forks_count": 8, "avg_line_length": 1743.0, "max_line_length": 1743, "alphanum_fraction": 0.7085484796}
import{Button,LoadingCover}from"./components/_components.min.js";import{request}from"./libs/utils.min.js";import{i18n}from"./i18n/i18n.min.js";import Cookies from"./libs/js-cookie.min.js";function loginScreen(){let o={loading:!1,username:"",password:"",error:""};return{view:function(){let e=[];""!==o.error&&e.push(m("p.login__error",o.error));let n=[];o.loading&&n.push(m(LoadingCover));let r=i18n("Original logo by $author from $website").split(" ").map(o=>"$author"===o?m("a.attribution__link",{target:"_blank",rel:"noopener",href:"https://www.flaticon.com/authors/freepik"},"Freepik "):"$website"===o?m("a.attribution__link",{target:"_blank",rel:"noopener",href:"https://www.flaticon.com"},"www.flaticon.com "):o+" ");return m(".login",m(".login__body",...e,m(".login__form",m("img.login__logo",{src:"/res/logo.svg"}),m("input[type=text].login__input",{value:o.username,placeholder:i18n("Username"),oninput(e){o.username=e.target.value}}),m("input[type=password].login__input",{value:o.password,placeholder:i18n("Password"),oninput(e){o.password=e.target.value}}),m(Button,{class:"login__button",caption:i18n("Login"),loading:o.loading,onclick(){""!==o.username&&""!==o.password&&function(){o.loading=!0,o.error="",m.redraw();let e={method:"POST",body:JSON.stringify({username:o.username,password:o.password})};request("/api/login","5s",e).then(o=>{let e=o.session,n=o.user||null;Cookies.set("session-duit",e,{expires:365}),localStorage.setItem("duit-user",JSON.stringify(n)),window.location.href="/"}).catch(e=>{o.error=e.message}).finally(()=>{o.loading=!1,m.redraw()})}()}}))),m("p.attribution",r),...n)},oncreate:function(o){o.dom.querySelector(".login__input").focus()}}}export function startApp(){m.mount(document.body,loginScreen)}