From c83ca8e1a26abbffc31077288d30da62d9eb294c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Fri, 11 Mar 2016 22:17:02 +0800 Subject: [PATCH] Login banned message --- .../src/Astro/Blog/Components/Entry/Blog.css | 2 ++ botanjs/src/Astro/Blog/Layout/Login.css | 2 ++ botanjs/src/Astro/Blog/Layout/Login.js | 32 +++++++++++++++---- botanjs/src/externs/_AstConf_.Login.js | 2 ++ 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/botanjs/src/Astro/Blog/Components/Entry/Blog.css b/botanjs/src/Astro/Blog/Components/Entry/Blog.css index 22d8790..94bba2f 100644 --- a/botanjs/src/Astro/Blog/Components/Entry/Blog.css +++ b/botanjs/src/Astro/Blog/Components/Entry/Blog.css @@ -6,7 +6,9 @@ font-family: monospace; font-size: 1.12em; + color: black; background-color: #EEE; + padding: 0.2em 0.5em; } diff --git a/botanjs/src/Astro/Blog/Layout/Login.css b/botanjs/src/Astro/Blog/Layout/Login.css index 831cadb..3b7e482 100644 --- a/botanjs/src/Astro/Blog/Layout/Login.css +++ b/botanjs/src/Astro/Blog/Layout/Login.css @@ -39,6 +39,8 @@ input { background: rgba(0, 0, 0, 0.1) !important; } +.sttr { color: yellow; font-size: 0.8em; } + .cstatus { position: relative; } diff --git a/botanjs/src/Astro/Blog/Layout/Login.js b/botanjs/src/Astro/Blog/Layout/Login.js index 133b775..caf87b0 100644 --- a/botanjs/src/Astro/Blog/Layout/Login.js +++ b/botanjs/src/Astro/Blog/Layout/Login.js @@ -1,6 +1,8 @@ (function(){ var ns = __namespace( "Astro.Blog.Layout.Login" ); + /** @type {System.Cycle} */ + var Cycle = __import( "System.Cycle" ); /** @type {System.utils.IKey} */ var IKey = __import( "System.utils.IKey" ); /** @type {Components.MessageBox} */ @@ -19,6 +21,7 @@ var conf = config.get( "Login" ); var sHeat = conf.sHeat || ""; + var sTTR = conf.sTTR || 0; var formAction = conf.formAct || "./"; var field_username = new IKey( "name", "username" ); @@ -27,24 +30,34 @@ var init = function () { var username; - var form = Dand.wrapne('form' + var sTTRe; + var form = Dand.wrapne("form" , [ // Basic login and password fields , Dand.wrapc("flsf", "Name:") - , username = Dand.wrapna('input', [ field_username, new IKey("type", "text") ] ) + , username = Dand.wrapna("input", [ field_username, new IKey("type", "text") ] ) , Dand.wrapc("flsf", "Password:") - , Dand.wrapna('input', [ field_password, new IKey("type", "password") ] ) + , Dand.wrapna("input", [ field_password, new IKey("type", "password") ] ) - , Dand.wrapc('msg', Dand.wrap('sub', null, sHeat.toLowerCase(), sHeat)) + , sTTRe = Dand.wrap( "span", null, "sttr", PrintTTR( sTTR ) ) + , Dand.wrapc( "msg", Dand.wrap("sub", null, sHeat.toLowerCase(), sHeat ) ) ] , [ // Form attributes - new IKey('action', formAction) - , new IKey('method', 'POST') + new IKey("action", formAction) + , new IKey("method", "POST") ] ); + if( 0 < sTTR ) + { + Cycle.perma( "STTR", function() + { + if( 0 < sTTR -- ) sTTRe.innerHTML = PrintTTR( sTTR ); + }, 1000 ); + } + var mbox = new MessageBox( "Blog.Astro", form, "Login", false, submitForm.bind( form ) ).show(); username.focus(); @@ -59,6 +72,13 @@ }; }; + var PrintTTR = function ( s ) + { + if( s <= 0 ) return ""; + + return "You are locked for " + s + "s, further login attempts will result in time-reset until the lock is released"; + }; + var submitForm = function (bool) { if ( bool ) { diff --git a/botanjs/src/externs/_AstConf_.Login.js b/botanjs/src/externs/_AstConf_.Login.js index 2379ac3..3a24c8a 100644 --- a/botanjs/src/externs/_AstConf_.Login.js +++ b/botanjs/src/externs/_AstConf_.Login.js @@ -4,3 +4,5 @@ _AstConf_.Login = {}; _AstConf_.Login.formAct; /** @type {String} */ _AstConf_.Login.sHeat; +/** @type {Number} */ +_AstConf_.Login.sTTR;