Bug fixes
This commit is contained in:
parent
6f0d4c4acd
commit
9265433bba
|
@ -15,7 +15,7 @@ AppPublisherURL={#MyAppURL}
|
||||||
AppSupportURL={#MyAppURL}
|
AppSupportURL={#MyAppURL}
|
||||||
AppUpdatesURL={#MyAppURL}
|
AppUpdatesURL={#MyAppURL}
|
||||||
CreateAppDir=yes
|
CreateAppDir=yes
|
||||||
DefaultDirName={pf}\{#MyAppName}
|
DefaultDirName={commonpf}\{#MyAppName}
|
||||||
DefaultGroupName={#MyAppName}
|
DefaultGroupName={#MyAppName}
|
||||||
;LicenseFile=src\LICENSE.txt
|
;LicenseFile=src\LICENSE.txt
|
||||||
SetupIconFile=src\icon.ico
|
SetupIconFile=src\icon.ico
|
||||||
|
|
207
src/main.js
207
src/main.js
|
@ -45,7 +45,7 @@ var App = {
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
var width = 420;
|
var width = 420;
|
||||||
var height = 360;
|
var height = 420;
|
||||||
|
|
||||||
window.resizeTo(width, height);
|
window.resizeTo(width, height);
|
||||||
window.moveTo((screen.width - width) / 2, (screen.height - height) / 2);
|
window.moveTo((screen.width - width) / 2, (screen.height - height) / 2);
|
||||||
|
@ -63,7 +63,6 @@ var App = {
|
||||||
|
|
||||||
this.appDir = this.getEnv('ProgramFiles') +'\\'+ Conf.appName;
|
this.appDir = this.getEnv('ProgramFiles') +'\\'+ Conf.appName;
|
||||||
this.moduleDir = this.shell.SpecialFolders('AppData') +'\\'+ Conf.appName;
|
this.moduleDir = this.shell.SpecialFolders('AppData') +'\\'+ Conf.appName;
|
||||||
this.remoteFile = Conf.remoteUrl +'/'+ this.module +'.7z';
|
|
||||||
this.compressFile = this.getEnv('TEMP') +'\\'+ this.module +'.7z';
|
this.compressFile = this.getEnv('TEMP') +'\\'+ this.module +'.7z';
|
||||||
this.mdbFile = this.moduleDir +'\\'+ this.module +'.mdb';
|
this.mdbFile = this.moduleDir +'\\'+ this.module +'.mdb';
|
||||||
this.lockFile = this.moduleDir +'\\'+ this.module +'.ldb';
|
this.lockFile = this.moduleDir +'\\'+ this.module +'.ldb';
|
||||||
|
@ -165,14 +164,21 @@ var App = {
|
||||||
},
|
},
|
||||||
|
|
||||||
onCleanCacheClick: function() {
|
onCleanCacheClick: function() {
|
||||||
var file;
|
setTimeout(function() { App.cleanCache(); });
|
||||||
var folder = this.fso.getFolder(this.moduleDir);
|
},
|
||||||
var files = new Enumerator(folder.files);
|
|
||||||
|
|
||||||
for (; !files.atEnd(); files.moveNext()) {
|
cleanCache: function() {
|
||||||
var file = files.item();
|
if (this.fso.folderExists(this.moduleDir)) {
|
||||||
if (/\.mdb$/.test(file.name) && file.name != 'config.mdb')
|
var folder = this.fso.getFolder(this.moduleDir);
|
||||||
file.delete(file.name);
|
var files = new Enumerator(folder.files);
|
||||||
|
|
||||||
|
for (; !files.atEnd(); files.moveNext()) {
|
||||||
|
var file = files.item();
|
||||||
|
if (/\.mdb$/.test(file.name) && file.name != 'config.mdb')
|
||||||
|
try {
|
||||||
|
file.Delete();
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showMessage(_('Cache deleted'));
|
this.showMessage(_('Cache deleted'));
|
||||||
|
@ -202,10 +208,12 @@ var App = {
|
||||||
|
|
||||||
onEnterClick: function() {
|
onEnterClick: function() {
|
||||||
this.disableUi(true, _('Loading'));
|
this.disableUi(true, _('Loading'));
|
||||||
setTimeout(function() {App.login();}, 0);
|
setTimeout(function() { App.login(); }, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
login: function() {
|
login: function() {
|
||||||
|
var downloadVersion;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var user = this.$('user').value;
|
var user = this.$('user').value;
|
||||||
var password = this.$('password').value;
|
var password = this.$('password').value;
|
||||||
|
@ -218,15 +226,16 @@ var App = {
|
||||||
this.regWrite(Conf.dsPath, 'UID', user, 'REG_SZ');
|
this.regWrite(Conf.dsPath, 'UID', user, 'REG_SZ');
|
||||||
this.regWrite(Conf.dsPath, 'PWD', password, 'REG_SZ');
|
this.regWrite(Conf.dsPath, 'PWD', password, 'REG_SZ');
|
||||||
|
|
||||||
if (this.hasToUpdate()) {
|
if (hasToUpdate.call(this)) {
|
||||||
this.disableUi(true, _('Updating'));
|
this.disableUi(true, _('Updating'));
|
||||||
|
var remoteFile = Conf.remoteUrl;
|
||||||
var queryString = lastVersion
|
remoteFile += downloadVersion
|
||||||
? 'v'+ lastVersion
|
? '/.archive/'+ this.module +'/'+ downloadVersion
|
||||||
: new Date().getTime();
|
: '/'+ this.module;
|
||||||
|
remoteFile += '.7z';
|
||||||
|
|
||||||
var request = new ActiveXObject('MSXML2.XMLHTTP');
|
var request = new ActiveXObject('MSXML2.XMLHTTP');
|
||||||
request.open('GET', this.remoteFile +'?'+ queryString, true);
|
request.open('GET', remoteFile, true);
|
||||||
request.onreadystatechange = function() {
|
request.onreadystatechange = function() {
|
||||||
App.onRequestReady(request);
|
App.onRequestReady(request);
|
||||||
};
|
};
|
||||||
|
@ -236,91 +245,93 @@ var App = {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.catchError(err);
|
this.catchError(err);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
hasToUpdate: function() {
|
function hasToUpdate() {
|
||||||
// Gets the last version number using the MySQL ODBC connection
|
// Gets the last version number using the MySQL ODBC connection
|
||||||
|
|
||||||
var mysqlConn = new ActiveXObject('ADODB.Connection');
|
|
||||||
|
|
||||||
try {
|
|
||||||
mysqlConn.open(Conf.dsName);
|
|
||||||
} catch (err) {
|
|
||||||
var dbErrors = mysqlConn.errors;
|
|
||||||
|
|
||||||
if (dbErrors.count > 0) {
|
|
||||||
var newErr;
|
|
||||||
var dbError = dbErrors.item(0);
|
|
||||||
|
|
||||||
switch (dbError.NativeError) {
|
|
||||||
case 1045: // Access denied
|
|
||||||
clearPassword = true;
|
|
||||||
newErr = new Error(_('Bad login'));
|
|
||||||
newErr.code = 'BadLogin';
|
|
||||||
break;
|
|
||||||
case 2003: // Can't connect
|
|
||||||
newErr = new Error(_('Server can\'t be reached'));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
errorMsg = dbError.description;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbErrors.clear();
|
|
||||||
throw newErr;
|
|
||||||
} else
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
var sql = "SELECT version FROM versiones WHERE programa = '"+ this.module +"'";
|
|
||||||
var rs = mysqlConn.execute(sql);
|
|
||||||
|
|
||||||
var lastVersion = rs.EOF ? 0 : parseInt(rs.fields(0).value);
|
|
||||||
|
|
||||||
rs.close();
|
|
||||||
mysqlConn.close();
|
|
||||||
|
|
||||||
// Checks if the MDB exists
|
|
||||||
|
|
||||||
if (!this.fso.fileExists(this.mdbFile))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// Checks wether the MDB it's already open
|
|
||||||
|
|
||||||
if (this.fso.fileExists(this.lockFile))
|
|
||||||
try {
|
|
||||||
this.fso.deleteFile(this.lockFile);
|
|
||||||
return true;
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error(_('Application it\'s already open'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checks wether the MDB is abnormaly bigger so maybe it's corrupted
|
|
||||||
|
|
||||||
var file = this.fso.getFile(this.mdbFile);
|
|
||||||
|
|
||||||
if (file.size > Conf.maxSize * 1024 * 1024)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// Obtains the local version number from the MDB file
|
|
||||||
|
|
||||||
var localVersion = -1;
|
|
||||||
|
|
||||||
if (this.fso.fileExists(this.mdbFile) && !forcedlyClosed)
|
|
||||||
try {
|
|
||||||
var mdbConn = new ActiveXObject('ADODB.Connection');
|
|
||||||
mdbConn.open('Provider=Microsoft.Jet.OLEDB.4.0; Data Source='+ this.mdbFile +';');
|
|
||||||
|
|
||||||
var oRs = new ActiveXObject('ADODB.Recordset');
|
|
||||||
oRs.Open('SELECT Version FROM tblVariables', mdbConn);
|
|
||||||
localVersion = oRs.EOF ? -1 : parseInt(oRs('Version'));
|
|
||||||
|
|
||||||
oRs.close();
|
var mysqlConn = new ActiveXObject('ADODB.Connection');
|
||||||
mdbConn.close();
|
|
||||||
} catch (e) {}
|
try {
|
||||||
|
mysqlConn.open(Conf.dsName);
|
||||||
|
} catch (err) {
|
||||||
|
var dbErrors = mysqlConn.errors;
|
||||||
|
|
||||||
|
if (dbErrors.count > 0) {
|
||||||
|
var newErr;
|
||||||
|
var dbError = dbErrors.item(0);
|
||||||
|
|
||||||
|
switch (dbError.NativeError) {
|
||||||
|
case 1045: // Access denied
|
||||||
|
clearPassword = true;
|
||||||
|
newErr = new Error(_('Bad login'));
|
||||||
|
newErr.code = 'BadLogin';
|
||||||
|
break;
|
||||||
|
case 2003: // Can't connect
|
||||||
|
newErr = new Error(_('Server can\'t be reached'));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
errorMsg = dbError.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbErrors.clear();
|
||||||
|
throw newErr;
|
||||||
|
} else
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
// Compares the local version with the last version
|
var sql = "SELECT version FROM versiones WHERE programa = '"+ this.module +"'";
|
||||||
|
var rs = mysqlConn.execute(sql);
|
||||||
|
|
||||||
|
downloadVersion = rs.EOF ? 0 : parseInt(rs.fields(0).value);
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
mysqlConn.close();
|
||||||
|
|
||||||
|
if (this.$('previous-version').checked && downloadVersion > 1)
|
||||||
|
downloadVersion -= 1;
|
||||||
|
|
||||||
|
// Checks if it's already open
|
||||||
|
|
||||||
|
if (this.fso.fileExists(this.lockFile))
|
||||||
|
try {
|
||||||
|
this.fso.deleteFile(this.lockFile);
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(_('Application it\'s already open'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks if MDB exists
|
||||||
|
|
||||||
|
if (!this.fso.fileExists(this.mdbFile))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// If it's abnormaly biggerm, maybe is corrupted, so force download
|
||||||
|
|
||||||
|
var file = this.fso.getFile(this.mdbFile);
|
||||||
|
|
||||||
|
if (file.size > Conf.maxSize * 1024 * 1024)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Obtains the local version number from the MDB file
|
||||||
|
|
||||||
|
var localVersion = -1;
|
||||||
|
|
||||||
return localVersion < lastVersion;
|
try {
|
||||||
|
var mdbConn = new ActiveXObject('ADODB.Connection');
|
||||||
|
mdbConn.open('Provider=Microsoft.Jet.OLEDB.4.0; Data Source='+ this.mdbFile +';');
|
||||||
|
|
||||||
|
var oRs = new ActiveXObject('ADODB.Recordset');
|
||||||
|
oRs.Open('SELECT Version FROM tblVariables', mdbConn);
|
||||||
|
localVersion = oRs.EOF ? -1 : parseInt(oRs('Version'));
|
||||||
|
|
||||||
|
oRs.close();
|
||||||
|
mdbConn.close();
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
// Compares the local version with the requested version
|
||||||
|
|
||||||
|
return localVersion != downloadVersion;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onRequestReady: function(request) {
|
onRequestReady: function(request) {
|
||||||
|
@ -393,7 +404,7 @@ var App = {
|
||||||
var messageDiv = this.$('message');
|
var messageDiv = this.$('message');
|
||||||
messageDiv.innerHTML = message;
|
messageDiv.innerHTML = message;
|
||||||
messageDiv.style.display = 'block';
|
messageDiv.style.display = 'block';
|
||||||
this.messageTimeout = setTimeout(function() {App.hideMessage();}, 10000);
|
this.messageTimeout = setTimeout(function() { App.hideMessage(); }, 10000);
|
||||||
},
|
},
|
||||||
|
|
||||||
onBodyClick: function() {
|
onBodyClick: function() {
|
||||||
|
|
|
@ -5,11 +5,18 @@ body {
|
||||||
color: #222;
|
color: #222;
|
||||||
font-family: Tahoma;
|
font-family: Tahoma;
|
||||||
}
|
}
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #44f;
|
||||||
|
}
|
||||||
|
|
||||||
/* Login form */
|
/* Login form */
|
||||||
|
|
||||||
#logo {
|
#logo {
|
||||||
|
display: block;
|
||||||
|
margin: 0 auto;
|
||||||
margin-bottom: .5em;
|
margin-bottom: .5em;
|
||||||
|
width: 80%;
|
||||||
}
|
}
|
||||||
button,
|
button,
|
||||||
input,
|
input,
|
||||||
|
@ -17,48 +24,56 @@ select {
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
}
|
}
|
||||||
#fields {
|
#fields {
|
||||||
max-width: 10em;
|
max-width: 11em;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
#fields > div {
|
#inputs > div {
|
||||||
margin-top: .5em;
|
margin-top: 1em;
|
||||||
}
|
}
|
||||||
#fields > div > * {
|
#inputs > div > * {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
label {
|
label {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-size: .9em;
|
font-size: .9em;
|
||||||
}
|
}
|
||||||
|
#inputs label {
|
||||||
|
color: #666;
|
||||||
|
font-size: .8em;
|
||||||
|
}
|
||||||
input[type='text'],
|
input[type='text'],
|
||||||
input[type='password'] {
|
input[type='password'] {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: none;
|
border: none;
|
||||||
border-bottom: 1px solid #888;
|
border-bottom: 1px solid #888;
|
||||||
font-size: .9em;
|
font-size: .9em;
|
||||||
color: #666;
|
color: #333;
|
||||||
padding: .3em;
|
padding: .3em;
|
||||||
|
max-width: auto;
|
||||||
}
|
}
|
||||||
#checkbox {
|
#checkbox {
|
||||||
margin-top: .8em;
|
margin-top: 1em;
|
||||||
}
|
}
|
||||||
#submit {
|
#submit {
|
||||||
margin-top: .5em;
|
margin-top: 1em;
|
||||||
|
}
|
||||||
|
#clean {
|
||||||
|
margin-top: .5em;
|
||||||
|
font-size: .8em;
|
||||||
}
|
}
|
||||||
#checkbox,
|
|
||||||
#submit,
|
#submit,
|
||||||
#clean {
|
#clean {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
button {
|
button {
|
||||||
border: none;
|
border: none;
|
||||||
color: #008D77;
|
color: white;
|
||||||
background-color: transparent;
|
background-color: #f7931e;
|
||||||
padding: .4em;
|
padding: .3em;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
button:hover {
|
button:hover {
|
||||||
background-color: #EEE;
|
background-color: #f7b33e;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,19 +31,25 @@
|
||||||
src="verdnatura.png"
|
src="verdnatura.png"
|
||||||
alt="Verdnatura"/>
|
alt="Verdnatura"/>
|
||||||
<div id="fields">
|
<div id="fields">
|
||||||
<div>
|
<div id="inputs">
|
||||||
<label for="user">Usuario</label>
|
<div>
|
||||||
<input id="user" type="text"/>
|
<label for="user">Usuario</label>
|
||||||
|
<input id="user" type="text"/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="password">Contraseña</label>
|
||||||
|
<input id="password" type="password"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="checkbox">
|
||||||
|
<input id="remember" type="checkbox"/>
|
||||||
|
<label for="remember">Recuérdame</label>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label for="password">Contraseña</label>
|
<input id="previous-version" type="checkbox"/>
|
||||||
<input id="password" type="password"/>
|
<label for="previous-version">Usar versión anterior</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="checkbox">
|
|
||||||
<input id="remember" type="checkbox"/>
|
|
||||||
<label for="remember">Recuérdame</label>
|
|
||||||
</div>
|
|
||||||
<div id="submit">
|
<div id="submit">
|
||||||
<button
|
<button
|
||||||
id="enter"
|
id="enter"
|
||||||
|
@ -53,6 +59,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="clean">
|
<div id="clean">
|
||||||
<a
|
<a
|
||||||
|
href="#"
|
||||||
onclick="App.onCleanCacheClick()">
|
onclick="App.onCleanCacheClick()">
|
||||||
Limpiar caché
|
Limpiar caché
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Reference in New Issue