var aab= null; // Sumary // ********************************************************************************************************* // * loginForm_1: imatgeCloud, labelWww // * loginForm_2: liniaVertical // * loginForm_3: usuari, password, btnLogin // * loginForm: Els 3 anteriors // // * centerPanel: loginForm * El q fa es centrar el panel // * vpLogin: centerPanel * Es el viewport // // ********************************************************************************************************* Ext.Loader.setConfig({ enabled: true, paths: { utils: './components/utils', literals: './components/utils/literals', ux: './components/ux' } }); /** * Metode q comprova si existeix el metode CONTAINS, i si no existeix el crea. * LINK: http://www.emm-gfx.net/2013/10/string-contains-javascript-polyfill/ * **************************************************************************************************** */ if(!('contains' in String.prototype)){ String.prototype.contains = function(str, startIndex) { return -1 !== String.prototype.indexOf.call(this, str, startIndex); }; } Ext.onReady(function () { // Configuracions // ************************** Ext.Window.prototype.floating = {shadow: false}; // Eliminar totes les sombres de les finestres. Ext.tip.QuickTipManager.init(); // Necessari per a q es mostrin els tooltips. // Variables globals // ************************** var Constants= Ext.create('utils.Constants'); // var Literals= Ext.create('utils.literals.literals-ca'); // Per defecte es mostrara amb castella... var transparencia= 0.3; var espais= "     "; var espais3= "   "; var msg1= "Validando credenciales..."+espais; var msg2= "Credenciales ok..."+espais; // var msg3= "Cargant aplicaci��...
— Entre 5-10'' —"+espais+espais; /* var msg3= 'Cargant aplicaci��...
'+ 'Temps: Entre 5-10 segons'+espais+espais; */ var msg3= espais3+"Cargando aplicación..."+espais3; // Components // ************************** // - loginForm: Conte els components d'Usuari i Contrasenya. // - pImatge: Conte la imatge del login (silueta ciutat). // - pCenter: Conte els 3 panells q formen el login: pCredencials, pIdioma, pImatge. // - vpLogin: Conte el pCenter, i es l'encarregat de redimensionar el login. // ************************************************************************************************************************* var loginForm_1= Ext.create('Ext.form.Panel', { layout: 'vbox', // margins: '45 0 0 45', height: 215, // bodyStyle: 'backgroundColor: rgba(168, 198, 229, 0.7)', // bodyStyle: 'backgroundColor: rgba(111, 111, 111, 0.2)', // bodyStyle: 'backgroundColor: white', bodyStyle: 'backgroundColor: rgba(255, 255, 255, '+transparencia+')', autoDestroy: false, items: [ // IMATGE-CLOUD // -------------------------------------------------------------------- { xtype: 'image', // Versio Normal // ******************************************************************** // /* src: 'imatges/login/logo_bqait2.png', // 723 x 349 width: 158, height: 76, margins: '53 5 0 35' // */ // Versio icona Q // ******************************************************************** /* src: 'imatges/login/logo_green.png', width: 130, height: 130, margins: '32 5 0 35' */ // Versio Nadal // ******************************************************************** /* src: 'imatges/login/bqait_logo_nadal2.png', width: 158, height: 114, margins: '45 5 0 35' */ // Versio Reis // ******************************************************************** /* src: 'imatges/login/bqait_logo_reis2.png', width: 178, height: 113, margins: '45 5 0 15' */ // Versio DANA Valencia // ******************************************************************** /* src: 'imatges/login/bqait_logo_valencia2.png', // 833 x 449 width: 215, height: 116, margins: '45 0 0 25' */ // LABEL-WWW // -------------------------------------------------------------------- }, { hidden: true, xtype: 'label', html: 'BQAIT', margins: '5 5 15 83' } ] }); // ************************************************************************************************************************* var loginForm_2= Ext.create('Ext.form.Panel', { layout: 'vbox', // margins: '45 0 0 0', height: 215, // bodyStyle: 'backgroundColor: white', // Blau fluix bodyStyle: 'backgroundColor: rgba(255, 255, 255, '+transparencia+')', // Blau fluix autoDestroy: false, items: [ // LINIA-VERTICAL // -------------------------------------------------------------------- { xtype: 'image', src: 'imatges/login/linia-vertical2.png', margins: '20 5 15 15', width: 5, height: 171 } ] }); // ************************************************************************************************************************* var loginForm_3= Ext.create('Ext.form.Panel', { layout: 'vbox', // margins: '45 0 0 0', height: 215, cls: 'behind', // bodyStyle: 'backgroundColor: white', // Blau fluix bodyStyle: 'backgroundColor: rgba(255, 255, 255, '+transparencia+')', // Blau fluix autoDestroy: false, items: [ // USUARI // -------------------------------------------------------------------- { xtype: 'textfield', itemId: 'usuari', cls: 'login-fields', height: 35, padding: '50 45 0 35', emptyText: 'Usuario', allowBlank: false, width: 200, value: "", blankText: "El 'Usuario es obligatorio.", enableKeyEvents: true, listeners: { keypress: function(textfield, eo){ if(eo.getCharCode() == Ext.EventObject.ENTER) { var btn= loginForm.down('#login'); btn.handler.call(btn.scope); // Ok- Executem el handler() } } } // PASSWORD // -------------------------------------------------------------------- }, { xtype: 'textfield', itemId: 'password', inputType: 'password', cls: 'login-fields', height: 35, padding: '0 45 0 35', emptyText: 'Contrase��a', // emptyText: 'Password', allowBlank: false, width: 200, value: "", // blankText: "La Contraseña es obligatoria.", blankText: "La Contrase��a es obligatoria.", enableKeyEvents: true, listeners: { keypress: function(textfield, eo){ if(eo.getCharCode() == Ext.EventObject.ENTER) { var btn= loginForm.down('#login'); btn.handler.call(btn.scope); // Ok- Executem el handler() } } } // RECORDAR // -------------------------------------------------------------------- }, { xtype: 'checkbox', itemId: 'cb-recordar', // boxLabel: ' Lorem ipsum...
Ljkfiojnm asdkiuyqi kjdijj...', boxLabel: ' Recordar', margin: '0 0 0 33', listeners:{ change: function(self, newValue, oldValue, eOpts){ if(newValue==true){ } else{ } } } // BTN-LOGIN // -------------------------------------------------------------------- }, { xtype: 'button', text: "Acceder", itemId: 'login', textAlign: 'center', cls: 'btn_green', height: 30, width: 100, margin: '10 15 0 87', handler: function(){ // alert("login()"); if(loginForm.down('#usuari').getValue() == "" || loginForm.down('#password').getValue() == ""){ new Ext.util.DelayedTask( function(){ Ext.create('Ext.window.MessageBox', { buttonAlign: 'center', cls: 'msg-red', buttons: [ // BTN- D'acord... // ------------------------------------------------------ { text: "De acuerdo", iconAlign: 'left', scale: 'small', // icon: './imatges/icones/petits/tick4.png', margin: 5, handler: function(){ // vpLoginTask.delay(0); this.up('window').destroy(); } } ] }).show({ title: 'Login', // msg: "Campos erróneos!", msg: "Campos err��neos!", closable: false }); }).delay(0); } else{ vpLogin.setLoading(true); vpLogin.setLoading(msg1); // CRIDA AJAX *************************************************************** Ext.Ajax.request({ // url: 'loginUser5', url: 'loginUserSeq', method: 'post', timeout: 15000, params: { aab: "Nan", loginAlias: loginForm.down('#usuari').getValue(), loginPassword: loginForm.down('#password').getValue() }, // SUCCESS ------------------------------------------- (loginUser) success: function(response) { var reply= Ext.decode(response.responseText); // var idiomaStr= reply.idiomaStr; /* if(loginForm.down('#usuari').getValue() == "aflores@laselva"){ crearCookie("aab", "1_2", 1); } else if(loginForm.down('#usuari').getValue() == "rfigueras@alcover"){ crearCookie("aab", "50_1", 1); } else{ crearCookie("aab", "1354_31", 1); } */ // 25/03/22 crearCookie("aab", reply.replyStr, 1); // 11/12/19 - Gestionar cookies // ---------------------------------------------------------------------------------------------------------------- if(loginForm.down('#cb-recordar').getValue()){ crearCookie("recordar", true, 90); crearCookie("username", loginForm.down('#usuari').getValue(), 90); crearCookie("password", loginForm.down('#password').getValue(), 90); } else{ crearCookie("recordar", false, -1); crearCookie("username", "", -1); crearCookie("password", "", -1); } new Ext.util.DelayedTask( function(){ vpLogin.setLoading(msg2); }).delay(1000); new Ext.util.DelayedTask( function(){ vpLogin.setLoading(msg3); }).delay(1800); new Ext.util.DelayedTask( function(){ // loginForm.down('#idioma-ca').toggle(true); // window.location= Constants.URL+"main?idioma="+idiomaStr; // TODO // ***************************************************************** // ***************************************************************** if(loginForm.down('#usuari').getValue().contains("@sctfe") || loginForm.down('#usuari').getValue().contains("@demo2") || loginForm.down('#usuari').getValue().contains("_espai")){ window.location= Constants.URL+"mainEspai"; } else{ window.location= Constants.URL+"main"; } // */ // 22/05/24 /* if(loginForm.down('#usuari').getValue().contains("@sctfe") || loginForm.down('#usuari').getValue().substring(0,1)=="_"){ window.location= Constants.URL+"mainEspai"; } else{ window.location= Constants.URL+"main"; } */ }).delay(2500); }, // FAILURE ------------------------------------------- (loginUser) failure: function(response) { var reply= Ext.decode(response.responseText); vpLoginTask.delay(1500); new Ext.util.DelayedTask( function(){ Ext.create('Ext.window.MessageBox', { buttonAlign: 'center', cls: 'msg-red', buttons: [ // BTN- D'acord... // ------------------------------------------------------ { text: "De acuerdo", iconAlign: 'left', scale: 'small', // icon: './imatges/icones/petits/tick4.png', margin: 5, handler: function(){ // vpLoginTask.delay(0); this.up('window').destroy(); } } ] }).show({ title: 'Login', msg: reply.replyStr, closable: false }); }).delay(1500); } }); // Fi crida Ajax() loginForm.down('#login').setDisabled(true); // Pq no quedi "toggle" loginForm.down('#login').setDisabled(false); } } } // Fi del handler() ] }); // ************************************************************************************************************************* // ************************************************************************************************************************* var loginForm2= Ext.create('Ext.form.Panel', { layout: 'hbox', bodyStyle: 'backgroundColor: transparent', padding: '50 0 0 0', items: [ loginForm_1, loginForm_2, loginForm_3 ] }); var loginForm= Ext.create('Ext.form.Panel', { layout: 'vbox', cls: 'behind2', bodyStyle: 'backgroundColor: transparent', padding: '50 0 0 0', items: [ /* { xtype: 'panel', layout: 'hbox', bodyStyle: 'backgroundColor: transparent', margin: '50 0 0 0', items:[ { xtype: 'checkbox', itemId: 'cb-espai', margin: '6 0 0 0', listeners:{ change: function(self, newValue, oldValue, eOpts){ } } }, { xtype: 'label', style: 'font-size:11px; font-weight: bold;', html: 'Espai p��blic', // width: 270, margin: '14 5 0 10', cls: 'link2', listeners: { element: 'el', click: function (){ if(loginForm.down('#cb-espai').getValue()){ loginForm.down('#cb-espai').setValue(false); } else{ loginForm.down('#cb-espai').setValue(true); } } } } ] }, */ loginForm2, { xtype: 'label', // height: 40, // html: '* BQAIT recomienda el uso del navegador '+ // 'Google Chrome', html: '* Recomendamos el uso del navegador Google Chrome', margins: '7 0 0 0' }, { xtype: 'label', html: '* Contrato de servicios', cls: 'link', margins: '5 0 0 0', listeners: { element: 'el', click: function (){ var timestamp= new Date().getTime(); var nomFitxer= "contrato_servicio.pdf"+"?ts=+"+timestamp; window.open("https://mybqait.com/contractes/"+nomFitxer, '_blank'); } } } ] }); // ************************************************************************************************************************* var centerPanel= Ext.create('Ext.form.Panel', { // layout: 'hbox', layout:{ type: 'hbox', align: 'center', pack: 'center' }, minWidth: 900, maxHeight: 390, region: 'center', bodyStyle: 'backgroundColor: transparent', items: [ loginForm ] }); // ************************************************************************************************************************* var vpLogin= Ext.create('Ext.Viewport', { renderTo: Ext.getBody(), id: 'vpLoginId', padding: 0, minWidth: 900, maxWidth: 900, layout: { type: 'border', }, cls: 'viewport2', defaults: { split: true, }, items: [ centerPanel ], listeners:{ 'resize': function(vp, width, height){ // alert("Resize()"); var me= this; var amplada= 900; var altura= 500; // Una mica +, aix�� no queda centrat verticalment, sin�� + amunt winWidth= me.getWidth(); winHeight= me.getHeight(); // Quan l'amplada de la finestra ��s superior a 1024: // �� El marge esquerra es modificar�� x a q el viewport quedi centrat. if(winWidth > amplada){ var top= 5; var left= (winWidth-amplada) / 2; if(winHeight > altura){ top= (winHeight-altura) / 2; } this.getEl().setStyle({padding: top+' 2 5 '+left}); this.doLayout(); // Si l'amplada ��s inferior: // �� El marge esquerra quedar�� com x defecte= 5px } else{ var top= 5; if(winHeight > altura){ top= (winHeight-altura) / 2; } this.getEl().setStyle({padding: top+' 5 5 5'}); this.doLayout(); } } // Fi event 'resize()' } // Fi dels listeners }); // Fi del vpLogin var vpLoginTask= new Ext.util.DelayedTask( function(){ // Definim una inst��ncia de Task. vpLogin.setLoading(false); // Desactivem la m��scara. }, this); // 11/12/19 // Recuperar cookies // ********************************************************************************************** loginForm.down('#cb-recordar').setValue(obtenerCookie("recordar")); loginForm.down('#usuari').setValue(obtenerCookie("username")); loginForm.down('#password').setValue(obtenerCookie("password")); // FUNCIONS COOKIES // ********************************************************************************************** function crearCookie(clave, valor, diasexpiracion) { var d = new Date(); d.setTime(d.getTime() + (diasexpiracion*24*60*60*1000)); var expires = "expires="+d.toUTCString(); document.cookie = clave + "=" + valor + "; " + expires; } // ---------------------------------------------------------------------------------------------------------- /* function obtenerCookie(clave) { var name = clave + "="; var ca = document.cookie.split(';'); for(var i=0; i