From 158009dc83a912465648d39e268a6cd70a55f3d8 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 7 Nov 2016 19:35:43 +0100 Subject: [PATCH] Backup --- image/social/facebook-old.svg | 57 ---------------------- image/social/youtube-old.svg | 68 -------------------------- image/social/youtube.svg | 91 ++++++++++++++++++----------------- js/hedera/app.js | 88 ++++++++++++++++++++++++++++++++- js/hedera/gui.css | 4 +- js/hedera/login.js | 80 +++++------------------------- pages/main/head.php | 4 -- rest/misc/sms.php | 2 +- webpack.config.js | 8 +-- 9 files changed, 153 insertions(+), 249 deletions(-) delete mode 100644 image/social/facebook-old.svg delete mode 100644 image/social/youtube-old.svg diff --git a/image/social/facebook-old.svg b/image/social/facebook-old.svg deleted file mode 100644 index 503fcb8d..00000000 --- a/image/social/facebook-old.svg +++ /dev/null @@ -1,57 +0,0 @@ - - - -image/svg+xml \ No newline at end of file diff --git a/image/social/youtube-old.svg b/image/social/youtube-old.svg deleted file mode 100644 index c38c48c4..00000000 --- a/image/social/youtube-old.svg +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/image/social/youtube.svg b/image/social/youtube.svg index e6423656..c38c48c4 100644 --- a/image/social/youtube.svg +++ b/image/social/youtube.svg @@ -1,8 +1,7 @@ - + + + image/svg+xml + + + + image/svg+xml + + + + + + + \ No newline at end of file + sodipodi:nodetypes="cssscccsccccc" /> + + diff --git a/js/hedera/app.js b/js/hedera/app.js index 065abf16..cd6ce000 100644 --- a/js/hedera/app.js +++ b/js/hedera/app.js @@ -25,10 +25,15 @@ module.exports = new Class var conn = new Db.Connection (); this.link ({_conn: conn}, {'error': this._onConnError}); + + this.initAutoLogin (); } ,run: function () { + if (this.tryAutoLogin ()) + return; + var login = this._login = new Login ({conn: this._conn}); login.on ('login', this._onLogin, this); login.show (); @@ -45,7 +50,7 @@ module.exports = new Class ,_onLogout: function (gui) { - localStorage.removeItem ('hederaGuest'); + this.clearAutoLogin (); this._freeGui (); this.run (); } @@ -155,7 +160,88 @@ module.exports = new Class { this._freeLogin (); this._freeGui (); + this.deinitAutoLogin (); this._conn.unref (); } + + // Auto login functionality + + ,_firstLogin: true + + ,initAutoLogin: function () + { + var isGuest = new Vn.HashParam + ({ + type: Boolean, + key: 'guest' + }); + this.link ({_isGuest: isGuest}, {'changed': this._onGuestChange}); + + var token = new Vn.HashParam + ({ + type: String, + key: 'token' + }); + this.link ({_token: token}, {'changed': this._onTokenChange}); + } + + ,_onGuestChange: function () + { + if (this._isGuest.value) + setTimeout (this.tryAutoLogin.bind (this)); + } + + ,_onTokenChange: function () + { + if (this._token.value) + setTimeout (this.tryAutoLogin.bind (this)); + } + + ,deinitAutoLogin: function () + { + this._isGuest.unref (); + this._token.unref (); + } + + ,autoLogin: function () + { + var guest = localStorage.getItem ('hederaGuest'); + + if (this._isGuest.value || guest) + { + localStorage.setItem ('hederaGuest', true); + return true; + } + + if (this._token.value) + this._conn.token = this._token.value; + else + this._conn.fetchToken (); + + if (this._conn.token) + return true; + + return false; + } + + ,tryAutoLogin: function () + { + var ok = this.autoLogin (); + + this._firstLogin = false; + this._isGuest.value = undefined; + this._token.value = undefined; + + if (!ok) + return false; + + this._onLogin (); + return true; + } + + ,clearAutoLogin: function () + { + localStorage.removeItem ('hederaGuest'); + } }); diff --git a/js/hedera/gui.css b/js/hedera/gui.css index 7885b3ac..127e1f9b 100644 --- a/js/hedera/gui.css +++ b/js/hedera/gui.css @@ -302,8 +302,8 @@ @media (max-width: 960px) { - .action-bar span.label, - .htk-button > span + .vn-gui .action-bar span.label, + .vn-gui .htk-button > span { display: none; } diff --git a/js/hedera/login.js b/js/hedera/login.js index cf944425..56144131 100644 --- a/js/hedera/login.js +++ b/js/hedera/login.js @@ -25,7 +25,7 @@ module.exports = new Class { this.parent (props); this.builderInitString (Tpl); - + this.$('social-bar').conn = this._conn; var self = this; @@ -43,86 +43,32 @@ module.exports = new Class else this.$('spinner').stop (); } - - ,show: function () + + ,show: function (firstLogin) { document.body.appendChild (this.node); - var isGuest = new Vn.HashParam - ({ - type: Boolean, - key: 'guest' - }); - this.link ({_isGuest: isGuest}, {'changed': this._onGuestChange}); + var lastUser = localStorage.getItem ('hederaLastUser'); - var token = new Vn.HashParam - ({ - type: String, - key: 'token' - }); - this.link ({_token: token}, {'changed': this._onTokenChange}); + if (lastUser) + this.$('user').value = lastUser; - this._onGuestChange (); - this._onTokenChange (); - - if (!this._loginStarted - && (localStorage.getItem ('vnToken') - || sessionStorage.getItem ('vnToken'))) - this.login (); - - if (!this._loginStarted) - { - var lastUser = localStorage.getItem ('hederaLastUser'); - - if (lastUser) - this.$('user').value = lastUser; - - this._focusUserInput (); - } - } - - ,_onTokenChange: function () - { - if (!this.loginStarted && this._token.value) - { - this._conn.token = this._token.value; - this.login (); - } - } - - ,_onGuestChange: function () - { - var guest = localStorage.getItem ('hederaGuest'); - - if (!this.loginStarted && (this._isGuest.value || guest)) - { - localStorage.setItem ('hederaGuest', true); - this.login (); - } + this._focusUserInput (); } ,_onSubmit: function () { - this.login ( + this._conn.open ( this.$('user').value, this.$('pass').value, - this.$('remember').checked + this.$('remember').checked, + this._onConnOpen.bind (this) ); - } - - ,login: function (user, pass, remember) - { - this._loginStarted = true; - this._conn.open (user, pass, remember, - this._onConnOpen.bind (this)); this._disableUi (true); } ,_onConnOpen: function (conn, success, error) { - this._token.value = undefined; - this._isGuest.value = undefined; - this._loginStarted = false; this.$('pass').value = ''; this._disableUi (false); @@ -130,13 +76,13 @@ module.exports = new Class { var user = this.$('user').value; - if (user && !localStorage.getItem ('hederaGuest')) + if (user) localStorage.setItem ('hederaLastUser', user); + this.signalEmit ('login'); } else { - localStorage.removeItem ('hederaGuest'); this._focusUserInput (); throw error; } @@ -144,8 +90,6 @@ module.exports = new Class ,hide: function () { - this._isGuest.unref (); - this._token.unref (); Vn.Node.remove (this.node); } diff --git a/pages/main/head.php b/pages/main/head.php index c135129c..f04443c8 100755 --- a/pages/main/head.php +++ b/pages/main/head.php @@ -13,9 +13,5 @@ if ($result = $db->query ('SELECT name, content FROM metatag')) } $url = _DEV_MODE ? "http://{$_SERVER['SERVER_NAME']}:8080" : '.'; - -if (_DEV_MODE) - $this->includeJs ("$url/webpack-dev-server.js"); - $this->includeJs ("$url/build/hedera-web.js"); diff --git a/rest/misc/sms.php b/rest/misc/sms.php index 622e5f3e..c31996e4 100644 --- a/rest/misc/sms.php +++ b/rest/misc/sms.php @@ -29,7 +29,7 @@ class Sms extends Vn\Web\JsonRequest $sms = $xmlResponse->sms; $db->query ( 'INSERT INTO vn2008.sms (Id_trabajador, `text`, `to`, `from`, sent, response, Id_Cliente) - VALUES (account.user_get_id(), #, #, #, #, #, #)', + VALUES (account.userGetId(), #, #, #, #, #, #)', [ $_REQUEST['text'] ,$_REQUEST['to'] diff --git a/webpack.config.js b/webpack.config.js index 040997d0..ee829173 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -29,19 +29,19 @@ module.exports = fallback: process.env.NODE_PATH }, plugins: [ - new webpack.DefinePlugin ({ _DEV_MODE: devMode }), + new webpack.DefinePlugin ({ _DEV_MODE: devMode })/*, new webpack.optimize.UglifyJsPlugin ({ minimize: true, compress: { warnings: false } - }) + })*/ ], devServer: { inline: true, host: '0.0.0.0', headers: { "Access-Control-Allow-Origin": "*" } - }, - devtool: 'source-map' + }/*, + devtool: 'source-map'*/ };