2016-03-14 08:23:40 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
var Conf = {
|
2017-09-22 12:36:15 +00:00
|
|
|
appName: 'Verdnatura'
|
|
|
|
,dsName: 'verdnatura'
|
|
|
|
,dsPath: 'HKCU\\Software\\ODBC\\ODBC.INI\\verdnatura'
|
|
|
|
,regPath: 'HKCU\\Software\\Verdnatura\\vn-access'
|
|
|
|
,remoteUrl: 'https://verdnatura.es/vn-access'
|
|
|
|
,dbHost: 'db.verdnatura.es'
|
|
|
|
,defaultModule: 'tpv'
|
|
|
|
,defaultLocale: 'es'
|
2020-02-28 14:18:58 +00:00
|
|
|
,dbName: 'vn2008'
|
|
|
|
,maxSize: 500
|
2017-09-22 12:36:15 +00:00
|
|
|
};
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
var Locale = {
|
2017-09-22 12:36:15 +00:00
|
|
|
es: {
|
|
|
|
"Enter a user name":
|
2017-09-25 11:34:25 +00:00
|
|
|
"Introduce un nombre de usuario"
|
|
|
|
,"Enter a password":
|
|
|
|
"Introduce una contraseña"
|
|
|
|
,"Server can't be reached":
|
|
|
|
"No se ha podido conectar con el servidor"
|
|
|
|
,"Updating":
|
|
|
|
"Actualizando"
|
|
|
|
,"Bad login":
|
|
|
|
"Usuario o contraseña incorrectos"
|
2020-02-28 14:18:58 +00:00
|
|
|
,"Application it's already open":
|
|
|
|
"La aplicación ya está abierta"
|
2017-09-25 11:34:25 +00:00
|
|
|
,"Loading":
|
|
|
|
"Cargando"
|
|
|
|
,"Error while updating":
|
|
|
|
"Error al actualizar"
|
|
|
|
,"Microsoft Access 2003 is not installed":
|
|
|
|
"Microsoft Access 2003 no está instalado en el sistema"
|
2017-10-06 10:36:46 +00:00
|
|
|
,"MDB file not found":
|
|
|
|
"No se encontro el fichero MDB"
|
2020-02-28 16:29:07 +00:00
|
|
|
,"Cache files have been deleted":
|
|
|
|
"Se han borrado todos los ficheros cacheados"
|
2020-02-28 14:18:58 +00:00
|
|
|
}
|
2016-03-31 10:51:45 +00:00
|
|
|
};
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
var App = {
|
|
|
|
shell: new ActiveXObject('WScript.Shell'),
|
|
|
|
fso: new ActiveXObject('scripting.filesystemobject'),
|
2016-03-14 08:23:40 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
init: function() {
|
2016-03-14 08:23:40 +00:00
|
|
|
var width = 420;
|
2020-02-28 16:05:09 +00:00
|
|
|
var height = 420;
|
2016-03-14 08:23:40 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
window.resizeTo(width, height);
|
|
|
|
window.moveTo((screen.width - width) / 2, (screen.height - height) / 2);
|
2016-03-14 08:23:40 +00:00
|
|
|
},
|
|
|
|
|
2020-02-28 14:18:58 +00:00
|
|
|
onLoad: function() {
|
2017-09-22 11:11:55 +00:00
|
|
|
// Initializes the global variables
|
2016-03-14 08:23:40 +00:00
|
|
|
|
|
|
|
var split = Verdnatura.commandLine.match(/(?:[^\s"]+|"[^"]*")+/g);
|
|
|
|
|
|
|
|
if (split.length > 1)
|
2017-10-06 10:55:13 +00:00
|
|
|
this.module = split[1].replace(/^"+|"+$/g, '');
|
2016-03-31 10:51:45 +00:00
|
|
|
if (!this.module)
|
|
|
|
this.module = Conf.defaultModule;
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
this.appDir = this.getEnv('ProgramFiles') +'\\'+ Conf.appName;
|
|
|
|
this.moduleDir = this.shell.SpecialFolders('AppData') +'\\'+ Conf.appName;
|
|
|
|
this.compressFile = this.getEnv('TEMP') +'\\'+ this.module +'.7z';
|
2016-03-31 10:51:45 +00:00
|
|
|
this.mdbFile = this.moduleDir +'\\'+ this.module +'.mdb';
|
2020-02-28 14:18:58 +00:00
|
|
|
this.lockFile = this.moduleDir +'\\'+ this.module +'.ldb';
|
2016-03-31 10:51:45 +00:00
|
|
|
|
2017-09-22 11:11:55 +00:00
|
|
|
// Creates the necessary registry entries
|
2016-03-14 08:23:40 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
var configured = this.regRead(Conf.regPath, 'configured');
|
2016-03-14 08:23:40 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
if (!configured) {
|
2016-03-14 08:23:40 +00:00
|
|
|
var path;
|
|
|
|
|
2017-09-22 11:11:55 +00:00
|
|
|
// Creates the Access configuration entries
|
2016-03-14 08:23:40 +00:00
|
|
|
|
|
|
|
path = 'HKCU\\Software\\Microsoft\\Office\\11.0\\Access\\Settings';
|
2017-10-06 10:55:13 +00:00
|
|
|
this.regWrites(path, 'REG_DWORD', {
|
2016-03-14 08:23:40 +00:00
|
|
|
'Confirm Document Deletions' : 0,
|
|
|
|
'Confirm Action Queries' : 0,
|
2016-04-14 13:16:19 +00:00
|
|
|
'Confirm Record Changes' : 0
|
2016-03-14 08:23:40 +00:00
|
|
|
});
|
|
|
|
|
2016-03-14 11:01:40 +00:00
|
|
|
path = 'HKCU\\Software\\Microsoft\\Office\\11.0\\Access\\Security';
|
2017-10-06 10:55:13 +00:00
|
|
|
this.regWrite(path, 'Level', 1, 'REG_DWORD');
|
2016-03-14 11:01:40 +00:00
|
|
|
|
2017-09-22 11:11:55 +00:00
|
|
|
// Creates the MySQL ODBC connection
|
2016-03-18 13:12:24 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
var driverPath = this.getEnv('ProgramFiles')
|
2016-03-14 08:23:40 +00:00
|
|
|
+'\\MySQL\\Connector ODBC 5.1\\myodbc5.dll';
|
2016-03-18 13:12:24 +00:00
|
|
|
|
|
|
|
var params = {
|
|
|
|
'Driver' : driverPath,
|
2016-03-31 10:51:45 +00:00
|
|
|
'DESCRIPTION' : Conf.appName,
|
|
|
|
'SERVER' : Conf.dbHost,
|
2020-02-28 14:18:58 +00:00
|
|
|
'DATABASE' : Conf.dbName,
|
2016-03-14 08:23:40 +00:00
|
|
|
'SSLCA' : this.appDir +'\\cacert.pem',
|
|
|
|
'SSLVERIFY' : 1,
|
|
|
|
'AUTO_RECONNECT' : 1
|
2016-03-18 13:12:24 +00:00
|
|
|
};
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
this.createOdbc(
|
2016-03-31 10:51:45 +00:00
|
|
|
Conf.dsName,
|
2016-03-18 13:12:24 +00:00
|
|
|
'Mysql ODBC 5.1 Driver',
|
|
|
|
params
|
|
|
|
);
|
|
|
|
|
2017-09-22 11:11:55 +00:00
|
|
|
// Marks the application as configured
|
2016-03-14 08:23:40 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
this.regWrite(Conf.regPath, 'configured', 1, 'REG_DWORD');
|
2016-03-14 08:23:40 +00:00
|
|
|
}
|
|
|
|
|
2017-09-22 11:11:55 +00:00
|
|
|
// Loads the form data
|
2016-03-14 08:23:40 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
var user = this.regRead(Conf.dsPath, 'UID');
|
|
|
|
var password = this.regRead(Conf.dsPath, 'PWD');
|
|
|
|
var remember = this.regRead(Conf.regPath, 'remember');
|
2016-03-14 08:23:40 +00:00
|
|
|
|
|
|
|
if (user)
|
|
|
|
this.$('user').value = user;
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
if (remember && password) {
|
2016-03-14 08:23:40 +00:00
|
|
|
this.$('password').value = password;
|
|
|
|
this.$('remember').checked = true;
|
2020-02-28 14:18:58 +00:00
|
|
|
this.onEnterClick();
|
2017-10-06 10:55:13 +00:00
|
|
|
} else
|
|
|
|
this.resetForm(true);
|
2016-03-14 08:23:40 +00:00
|
|
|
},
|
2016-03-18 13:12:24 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
resetForm: function(clearPassword) {
|
|
|
|
if (clearPassword)
|
|
|
|
this.$('password').value = '';
|
|
|
|
|
|
|
|
this.$('user').focus();
|
|
|
|
this.$('user').select();
|
|
|
|
},
|
|
|
|
|
|
|
|
createOdbc: function(dsName, driverName, params) {
|
2016-03-18 13:12:24 +00:00
|
|
|
var odbcPath = 'HKCU\\Software\\ODBC\\ODBC.INI\\';
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
this.regWrites(odbcPath + dsName, 'REG_SZ', params);
|
|
|
|
this.regWrite(odbcPath + 'ODBC Data Sources',
|
2016-03-18 13:12:24 +00:00
|
|
|
dsName, driverName, 'REG_SZ');
|
|
|
|
},
|
2016-03-14 08:23:40 +00:00
|
|
|
|
2020-02-28 14:18:58 +00:00
|
|
|
disableUi: function(disabled, loadMessage) {
|
2016-03-14 08:23:40 +00:00
|
|
|
if (disabled)
|
2020-02-28 14:18:58 +00:00
|
|
|
this.hideMessage();
|
2016-03-14 08:23:40 +00:00
|
|
|
else
|
|
|
|
loadMessage = '';
|
|
|
|
|
|
|
|
this.$('loading-message').innerHTML = loadMessage;
|
|
|
|
|
|
|
|
this.$('user').disabled = disabled;
|
|
|
|
this.$('password').disabled = disabled;
|
|
|
|
this.$('remember').disabled = disabled;
|
|
|
|
this.$('enter').disabled = disabled;
|
|
|
|
|
|
|
|
var display = disabled ? 'block' : 'none';
|
|
|
|
this.$('background').style.display = display;
|
|
|
|
this.$('spinner').style.display = display;
|
|
|
|
},
|
2020-02-28 14:18:58 +00:00
|
|
|
|
|
|
|
onCleanCacheClick: function() {
|
2020-02-28 16:05:09 +00:00
|
|
|
setTimeout(function() { App.cleanCache(); });
|
|
|
|
},
|
|
|
|
|
|
|
|
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) {}
|
|
|
|
}
|
2020-02-28 14:18:58 +00:00
|
|
|
}
|
|
|
|
|
2020-02-28 16:29:07 +00:00
|
|
|
this.showMessage(_('Cache files have been deleted'), 'notice');
|
2020-02-28 14:18:58 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onKeyPress: function(event) {
|
|
|
|
switch (event.keyCode) {
|
2016-03-14 08:23:40 +00:00
|
|
|
case 13: // Enter
|
2020-02-28 14:18:58 +00:00
|
|
|
this.onEnterPress(event);
|
2016-03-14 08:23:40 +00:00
|
|
|
break;
|
|
|
|
case 27: // Esc
|
2017-10-06 10:55:13 +00:00
|
|
|
window.close();
|
2016-03-14 08:23:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
2017-09-11 14:25:54 +00:00
|
|
|
|
2020-02-28 14:18:58 +00:00
|
|
|
onEnterPress: function(event) {
|
2017-09-25 11:34:25 +00:00
|
|
|
var target = event.target || event.srcElement;
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
if (target && target.id == 'user' && this.$('password').value == '') {
|
|
|
|
this.$('password').focus();
|
2017-09-11 14:25:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-28 14:18:58 +00:00
|
|
|
this.onEnterClick();
|
2017-09-11 14:25:54 +00:00
|
|
|
},
|
2016-03-14 08:23:40 +00:00
|
|
|
|
2020-02-28 14:18:58 +00:00
|
|
|
onEnterClick: function() {
|
|
|
|
this.disableUi(true, _('Loading'));
|
2020-02-28 16:05:09 +00:00
|
|
|
setTimeout(function() { App.login(); }, 0);
|
2016-03-14 08:23:40 +00:00
|
|
|
},
|
|
|
|
|
2020-02-28 14:18:58 +00:00
|
|
|
login: function() {
|
2020-02-28 16:05:09 +00:00
|
|
|
var downloadVersion;
|
|
|
|
|
2016-03-14 08:23:40 +00:00
|
|
|
try {
|
2017-10-06 10:36:46 +00:00
|
|
|
var user = this.$('user').value;
|
|
|
|
var password = this.$('password').value;
|
|
|
|
|
2016-03-14 08:23:40 +00:00
|
|
|
if (!user || user === '')
|
2017-10-06 10:55:13 +00:00
|
|
|
throw new Error(_('Enter a user name'));
|
2016-03-14 08:23:40 +00:00
|
|
|
if (!password || password === '')
|
2017-10-06 10:55:13 +00:00
|
|
|
throw new Error(_('Enter a password'));
|
2016-03-14 08:23:40 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
this.regWrite(Conf.dsPath, 'UID', user, 'REG_SZ');
|
|
|
|
this.regWrite(Conf.dsPath, 'PWD', password, 'REG_SZ');
|
2016-03-14 08:23:40 +00:00
|
|
|
|
2020-02-28 16:05:09 +00:00
|
|
|
if (hasToUpdate.call(this)) {
|
2020-02-28 14:18:58 +00:00
|
|
|
this.disableUi(true, _('Updating'));
|
2020-02-28 16:05:09 +00:00
|
|
|
var remoteFile = Conf.remoteUrl;
|
|
|
|
remoteFile += downloadVersion
|
|
|
|
? '/.archive/'+ this.module +'/'+ downloadVersion
|
|
|
|
: '/'+ this.module;
|
|
|
|
remoteFile += '.7z';
|
2020-02-28 14:18:58 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
var request = new ActiveXObject('MSXML2.XMLHTTP');
|
2020-02-28 16:05:09 +00:00
|
|
|
request.open('GET', remoteFile, true);
|
2017-10-06 10:55:13 +00:00
|
|
|
request.onreadystatechange = function() {
|
2020-02-28 14:18:58 +00:00
|
|
|
App.onRequestReady(request);
|
2017-09-22 11:11:55 +00:00
|
|
|
};
|
2017-10-06 10:55:13 +00:00
|
|
|
request.send();
|
|
|
|
} else
|
|
|
|
this.openMdb();
|
2020-02-28 14:18:58 +00:00
|
|
|
} catch (err) {
|
|
|
|
this.catchError(err);
|
|
|
|
}
|
|
|
|
|
2020-02-28 16:05:09 +00:00
|
|
|
function hasToUpdate() {
|
|
|
|
// Gets the last version number using the MySQL ODBC connection
|
|
|
|
|
|
|
|
var mysqlConn = new ActiveXObject('ADODB.Connection');
|
2020-02-28 14:18:58 +00:00
|
|
|
|
2020-02-28 16:05:09 +00:00
|
|
|
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;
|
|
|
|
}
|
2020-02-28 14:18:58 +00:00
|
|
|
|
2020-02-28 16:05:09 +00:00
|
|
|
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;
|
|
|
|
|
2020-02-28 16:30:42 +00:00
|
|
|
// If it's abnormaly bigger, maybe is corrupted, so force download
|
2020-02-28 16:05:09 +00:00
|
|
|
|
|
|
|
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;
|
2020-02-28 14:18:58 +00:00
|
|
|
|
2020-02-28 16:05:09 +00:00
|
|
|
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) {}
|
2020-02-28 14:18:58 +00:00
|
|
|
|
2020-02-28 16:05:09 +00:00
|
|
|
// Compares the local version with the requested version
|
2020-02-28 14:18:58 +00:00
|
|
|
|
2020-02-28 16:05:09 +00:00
|
|
|
return localVersion != downloadVersion;
|
|
|
|
}
|
2016-03-14 08:23:40 +00:00
|
|
|
},
|
|
|
|
|
2020-02-28 14:18:58 +00:00
|
|
|
onRequestReady: function(request) {
|
2016-03-14 08:23:40 +00:00
|
|
|
if (request.readyState !== 4)
|
|
|
|
return;
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (request.status !== 200)
|
2017-10-06 10:55:13 +00:00
|
|
|
throw new Error('HTTP: '+ request.statusText);
|
2016-03-14 08:23:40 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
if (this.fso.fileExists(this.compressFile))
|
|
|
|
this.fso.deleteFile(this.compressFile);
|
2016-03-14 08:23:40 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
var stream = new ActiveXObject('ADODB.Stream');
|
|
|
|
stream.open();
|
2016-03-14 08:23:40 +00:00
|
|
|
stream.Type = 1; //adTypeBinary
|
2017-10-06 10:55:13 +00:00
|
|
|
stream.write(request.responseBody);
|
2016-03-14 08:23:40 +00:00
|
|
|
stream.Position = 0;
|
2017-10-06 10:55:13 +00:00
|
|
|
stream.saveToFile(this.compressFile, 2);
|
|
|
|
stream.close();
|
2016-03-14 08:23:40 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
if (this.fso.fileExists(this.mdbFile))
|
|
|
|
this.fso.deleteFile(this.mdbFile);
|
2016-03-31 10:51:45 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
this.run('7za e "'+ this.compressFile +'" -o"'+ this.moduleDir +'"', true);
|
|
|
|
this.fso.deleteFile(this.compressFile);
|
|
|
|
} catch (e) {
|
|
|
|
alert(_('Error while updating') +': '+ e.message);
|
2016-03-14 08:23:40 +00:00
|
|
|
}
|
|
|
|
|
2017-09-25 11:45:26 +00:00
|
|
|
try {
|
2017-10-06 10:55:13 +00:00
|
|
|
if (!this.fso.fileExists(this.mdbFile))
|
|
|
|
throw new Error(_('MDB file not found'));
|
2017-10-06 10:36:46 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
this.openMdb();
|
|
|
|
} catch (e) {
|
2020-02-28 14:18:58 +00:00
|
|
|
this.catchError(e);
|
2017-09-25 11:45:26 +00:00
|
|
|
}
|
2017-10-06 10:36:46 +00:00
|
|
|
},
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
openMdb: function() {
|
2016-03-14 08:23:40 +00:00
|
|
|
var remember = this.$('remember').checked ? 1 : 0;
|
2017-10-06 10:55:13 +00:00
|
|
|
this.regWrite(Conf.regPath, 'remember', remember, 'REG_DWORD');
|
2017-09-25 11:34:25 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
var programFiles = this.getEnv('ProgramFiles');
|
2017-09-25 11:34:25 +00:00
|
|
|
var accessBin = programFiles +'\\Microsoft Office\\OFFICE11\\MSACCESS.EXE';
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
if (!this.fso.fileExists(accessBin))
|
|
|
|
throw new Error(_('Microsoft Access 2003 is not installed'));
|
2017-09-25 11:34:25 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
this.shell.exec('"'+ accessBin +'" "'+ this.mdbFile +'"');
|
|
|
|
window.close();
|
2016-03-14 08:23:40 +00:00
|
|
|
},
|
|
|
|
|
2020-02-28 14:18:58 +00:00
|
|
|
catchError: function(err) {
|
|
|
|
var clearPassword = err.code == 'BadLogin';
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
if (!this.$('remember').checked || clearPassword)
|
|
|
|
this.regWrite(Conf.dsPath, 'PWD', '', 'REG_SZ');
|
|
|
|
|
2020-02-28 14:18:58 +00:00
|
|
|
this.disableUi(false);
|
2020-02-28 16:29:07 +00:00
|
|
|
this.showMessage(err.message, 'error');
|
2017-10-06 10:55:13 +00:00
|
|
|
this.resetForm(clearPassword);
|
|
|
|
},
|
|
|
|
|
2020-02-28 16:29:07 +00:00
|
|
|
showMessage: function(message, className) {
|
2016-03-14 08:23:40 +00:00
|
|
|
if (this.messageTimeout)
|
2017-10-06 10:55:13 +00:00
|
|
|
clearTimeout(this.messageTimeout);
|
2016-03-14 08:23:40 +00:00
|
|
|
|
|
|
|
var messageDiv = this.$('message');
|
2020-02-28 16:29:07 +00:00
|
|
|
messageDiv.className = className;
|
2016-03-14 08:23:40 +00:00
|
|
|
messageDiv.innerHTML = message;
|
|
|
|
messageDiv.style.display = 'block';
|
2020-02-28 16:05:09 +00:00
|
|
|
this.messageTimeout = setTimeout(function() { App.hideMessage(); }, 10000);
|
2016-03-14 08:23:40 +00:00
|
|
|
},
|
|
|
|
|
2020-02-28 14:18:58 +00:00
|
|
|
onBodyClick: function() {
|
|
|
|
this.hideMessage();
|
2016-03-14 08:23:40 +00:00
|
|
|
},
|
|
|
|
|
2020-02-28 14:18:58 +00:00
|
|
|
hideMessage: function() {
|
2017-10-06 10:55:13 +00:00
|
|
|
if (this.messageTimeout) {
|
2016-03-14 08:23:40 +00:00
|
|
|
this.$('message').style.display = 'none';
|
2017-10-06 10:55:13 +00:00
|
|
|
clearTimeout(this.messageTimeout);
|
2016-03-14 08:23:40 +00:00
|
|
|
this.messageTimeout = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-02-28 14:18:58 +00:00
|
|
|
onUnload: function() {
|
|
|
|
this.disableUi(false);
|
2016-03-14 08:23:40 +00:00
|
|
|
},
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
$: function(id) {
|
|
|
|
return document.getElementById(id);
|
2016-03-14 08:23:40 +00:00
|
|
|
},
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
run: function(command, wait) {
|
2016-03-14 08:23:40 +00:00
|
|
|
if (!wait)
|
|
|
|
wait = false;
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
this.shell.run(command, 0, wait);
|
2016-03-14 08:23:40 +00:00
|
|
|
},
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
getEnv: function(varName) {
|
|
|
|
return this.shell.expandEnvironmentStrings('%'+ varName +'%');
|
2016-03-14 08:23:40 +00:00
|
|
|
},
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
regRead: function(path, key) {
|
2016-03-14 08:23:40 +00:00
|
|
|
try {
|
2017-10-06 10:55:13 +00:00
|
|
|
var value = this.shell.regRead(path +'\\'+ key);
|
|
|
|
} catch (e) {
|
2016-03-14 08:23:40 +00:00
|
|
|
var value = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
},
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
regWrite: function(path, key, value, type) {
|
|
|
|
this.shell.regWrite(path +'\\'+ key, value, type);
|
2016-03-14 08:23:40 +00:00
|
|
|
},
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
regWrites: function(path, type, values) {
|
|
|
|
for(var key in values)
|
|
|
|
this.regWrite(path, key, values[key], type);
|
2016-03-14 08:23:40 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
App.init();
|
2017-09-22 12:36:15 +00:00
|
|
|
|
2017-10-06 10:55:13 +00:00
|
|
|
function _(string) {
|
2017-09-22 12:36:15 +00:00
|
|
|
var translation = Locale[Conf.defaultLocale][string];
|
|
|
|
return translation ? translation : string;
|
|
|
|
}
|