Bug fixes
This commit is contained in:
parent
6f0d4c4acd
commit
9265433bba
|
@ -15,7 +15,7 @@ AppPublisherURL={#MyAppURL}
|
|||
AppSupportURL={#MyAppURL}
|
||||
AppUpdatesURL={#MyAppURL}
|
||||
CreateAppDir=yes
|
||||
DefaultDirName={pf}\{#MyAppName}
|
||||
DefaultDirName={commonpf}\{#MyAppName}
|
||||
DefaultGroupName={#MyAppName}
|
||||
;LicenseFile=src\LICENSE.txt
|
||||
SetupIconFile=src\icon.ico
|
||||
|
|
207
src/main.js
207
src/main.js
|
@ -45,7 +45,7 @@ var App = {
|
|||
|
||||
init: function() {
|
||||
var width = 420;
|
||||
var height = 360;
|
||||
var height = 420;
|
||||
|
||||
window.resizeTo(width, height);
|
||||
window.moveTo((screen.width - width) / 2, (screen.height - height) / 2);
|
||||
|
@ -63,7 +63,6 @@ var App = {
|
|||
|
||||
this.appDir = this.getEnv('ProgramFiles') +'\\'+ 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.mdbFile = this.moduleDir +'\\'+ this.module +'.mdb';
|
||||
this.lockFile = this.moduleDir +'\\'+ this.module +'.ldb';
|
||||
|
@ -165,14 +164,21 @@ var App = {
|
|||
},
|
||||
|
||||
onCleanCacheClick: function() {
|
||||
var file;
|
||||
var folder = this.fso.getFolder(this.moduleDir);
|
||||
var files = new Enumerator(folder.files);
|
||||
setTimeout(function() { App.cleanCache(); });
|
||||
},
|
||||
|
||||
for (; !files.atEnd(); files.moveNext()) {
|
||||
var file = files.item();
|
||||
if (/\.mdb$/.test(file.name) && file.name != 'config.mdb')
|
||||
file.delete(file.name);
|
||||
cleanCache: function() {
|
||||
if (this.fso.folderExists(this.moduleDir)) {
|
||||
var folder = this.fso.getFolder(this.moduleDir);
|
||||
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'));
|
||||
|
@ -202,10 +208,12 @@ var App = {
|
|||
|
||||
onEnterClick: function() {
|
||||
this.disableUi(true, _('Loading'));
|
||||
setTimeout(function() {App.login();}, 0);
|
||||
setTimeout(function() { App.login(); }, 0);
|
||||
},
|
||||
|
||||
login: function() {
|
||||
var downloadVersion;
|
||||
|
||||
try {
|
||||
var user = this.$('user').value;
|
||||
var password = this.$('password').value;
|
||||
|
@ -218,15 +226,16 @@ var App = {
|
|||
this.regWrite(Conf.dsPath, 'UID', user, 'REG_SZ');
|
||||
this.regWrite(Conf.dsPath, 'PWD', password, 'REG_SZ');
|
||||
|
||||
if (this.hasToUpdate()) {
|
||||
if (hasToUpdate.call(this)) {
|
||||
this.disableUi(true, _('Updating'));
|
||||
|
||||
var queryString = lastVersion
|
||||
? 'v'+ lastVersion
|
||||
: new Date().getTime();
|
||||
var remoteFile = Conf.remoteUrl;
|
||||
remoteFile += downloadVersion
|
||||
? '/.archive/'+ this.module +'/'+ downloadVersion
|
||||
: '/'+ this.module;
|
||||
remoteFile += '.7z';
|
||||
|
||||
var request = new ActiveXObject('MSXML2.XMLHTTP');
|
||||
request.open('GET', this.remoteFile +'?'+ queryString, true);
|
||||
request.open('GET', remoteFile, true);
|
||||
request.onreadystatechange = function() {
|
||||
App.onRequestReady(request);
|
||||
};
|
||||
|
@ -236,91 +245,93 @@ var App = {
|
|||
} catch (err) {
|
||||
this.catchError(err);
|
||||
}
|
||||
},
|
||||
|
||||
hasToUpdate: function() {
|
||||
// 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'));
|
||||
function hasToUpdate() {
|
||||
// Gets the last version number using the MySQL ODBC connection
|
||||
|
||||
oRs.close();
|
||||
mdbConn.close();
|
||||
} catch (e) {}
|
||||
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;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
@ -393,7 +404,7 @@ var App = {
|
|||
var messageDiv = this.$('message');
|
||||
messageDiv.innerHTML = message;
|
||||
messageDiv.style.display = 'block';
|
||||
this.messageTimeout = setTimeout(function() {App.hideMessage();}, 10000);
|
||||
this.messageTimeout = setTimeout(function() { App.hideMessage(); }, 10000);
|
||||
},
|
||||
|
||||
onBodyClick: function() {
|
||||
|
|
|
@ -5,11 +5,18 @@ body {
|
|||
color: #222;
|
||||
font-family: Tahoma;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #44f;
|
||||
}
|
||||
|
||||
/* Login form */
|
||||
|
||||
#logo {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
margin-bottom: .5em;
|
||||
width: 80%;
|
||||
}
|
||||
button,
|
||||
input,
|
||||
|
@ -17,48 +24,56 @@ select {
|
|||
font-size: 1em;
|
||||
}
|
||||
#fields {
|
||||
max-width: 10em;
|
||||
max-width: 11em;
|
||||
margin: 0 auto;
|
||||
}
|
||||
#fields > div {
|
||||
margin-top: .5em;
|
||||
#inputs > div {
|
||||
margin-top: 1em;
|
||||
}
|
||||
#fields > div > * {
|
||||
#inputs > div > * {
|
||||
display: block;
|
||||
}
|
||||
label {
|
||||
font-weight: normal;
|
||||
font-size: .9em;
|
||||
}
|
||||
#inputs label {
|
||||
color: #666;
|
||||
font-size: .8em;
|
||||
}
|
||||
input[type='text'],
|
||||
input[type='password'] {
|
||||
width: 100%;
|
||||
border: none;
|
||||
border-bottom: 1px solid #888;
|
||||
font-size: .9em;
|
||||
color: #666;
|
||||
color: #333;
|
||||
padding: .3em;
|
||||
max-width: auto;
|
||||
}
|
||||
#checkbox {
|
||||
margin-top: .8em;
|
||||
margin-top: 1em;
|
||||
}
|
||||
#submit {
|
||||
margin-top: .5em;
|
||||
margin-top: 1em;
|
||||
}
|
||||
#clean {
|
||||
margin-top: .5em;
|
||||
font-size: .8em;
|
||||
}
|
||||
#checkbox,
|
||||
#submit,
|
||||
#clean {
|
||||
text-align: center;
|
||||
}
|
||||
button {
|
||||
border: none;
|
||||
color: #008D77;
|
||||
background-color: transparent;
|
||||
padding: .4em;
|
||||
color: white;
|
||||
background-color: #f7931e;
|
||||
padding: .3em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
button:hover {
|
||||
background-color: #EEE;
|
||||
background-color: #f7b33e;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,19 +31,25 @@
|
|||
src="verdnatura.png"
|
||||
alt="Verdnatura"/>
|
||||
<div id="fields">
|
||||
<div>
|
||||
<label for="user">Usuario</label>
|
||||
<input id="user" type="text"/>
|
||||
<div id="inputs">
|
||||
<div>
|
||||
<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>
|
||||
<label for="password">Contraseña</label>
|
||||
<input id="password" type="password"/>
|
||||
<input id="previous-version" type="checkbox"/>
|
||||
<label for="previous-version">Usar versión anterior</label>
|
||||
</div>
|
||||
</div>
|
||||
<div id="checkbox">
|
||||
<input id="remember" type="checkbox"/>
|
||||
<label for="remember">Recuérdame</label>
|
||||
</div>
|
||||
<div id="submit">
|
||||
<button
|
||||
id="enter"
|
||||
|
@ -53,6 +59,7 @@
|
|||
</div>
|
||||
<div id="clean">
|
||||
<a
|
||||
href="#"
|
||||
onclick="App.onCleanCacheClick()">
|
||||
Limpiar caché
|
||||
</a>
|
||||
|
|
Loading…
Reference in New Issue