$( document ).ready(function() {
console.log( "Main ready!" );
- app.loadmodule("overview");
+ browserapp.loadmodule("overview");
console.log("After module load!");
});
console.log(navigator.platform);
console.log(location.protocol);
-var app = {
+var browserapp = {
loadmodule: function(modulename){
- var appdata = app.getconfig();
+ var appdata = browserapp.getconfig();
var params = "?";
for (var i in appdata){
params += "&" + i +"=" + encodeURIComponent(appdata[i]);
$("#moduleframe").attr("src","modules/"+modulename+"/index.html"+ params);
},
loadmodulepage: function(modulename,page,pageparams = null){
- var appdata = app.getconfig();
+ var appdata = browserapp.getconfig();
var params = "?";
for (var i in appdata){
params += "&" + i +"=" + encodeURIComponent(appdata[i]);
mainWindow.show()
// Open the DevTools.
mainWindow.webContents.openDevTools()
-
+
// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
})
}
+
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
--- /dev/null
+const { dialog } = require('electron').remote;
+const fs = require('fs');
+const os = require('os');
+var usersystem = {
+ profilepath: function(){
+ var ppath="";
+ if (os.platform() == "darwin"){
+ ppath = os.homedir() + '/Library/Application Support/invoicejournal/';
+ }
+ return ppath;
+ },
+ selectfile: function(dlgtitle,lastpath,filefilters=null){
+ return dialog.showOpenDialog({title: dlgtitle,defaultPath: lastpath, filters: filefilters, properties: ['openFile'] });
+ },
+ selectdir: function(dlgtitle,lastpath){
+ return dialog.showOpenDialog({title: dlgtitle,defaultPath: lastpath, filters: filefilters, properties: ['openDirectory'] });
+ },
+ showMessage: function(msgTitle,msg,msgdetail,msgtype,msgButtons=["OK"],defautlbtnid=0,cancelbtnid){
+ return dialog.showMessageBox({type: msgtype, //
+ title: msgTitle,
+ buttons:msgButtons,
+ message: msg,
+ detail: msgdetail,
+ defaultId: defautlbtnid,
+ cancelId: cancelbtnid});
+ },
+ showError: function(errtitle,errmsg){
+ dialog.showErrorBox(errtitle, errmsg);
+ },
+ setProperty(key,data){
+
+
+ if ((typeof data == 'object') || (typeof data == 'array')){
+ data = JSON.stringify(data);
+ }
+ fs.writeFile(this.profilepath() + key + ".json", data, (err) => {
+ if (err) {
+ this.showError("Error writing Preference!",err.message);
+ console.log(err);
+ return false;
+ }
+ return true;
+
+ });
+ return false;
+ },
+ getProperty(key){
+ var data = null;
+ fs.readFile(this.profilepath() + key + ".json", 'utf-8', (err, data) => {
+ if(err){
+ this.showError("Error reading Preference!",err.message);
+ return data;
+ }
+ if (data.startsWith("{") || data.startsWith("[")){
+ data = JSON.parse(data);
+ }
+ // Change how to handle the file content
+ console.log("The file content is : " + data);
+ return JSON.stringify(data);
+ });
+ return data;
+ },
+ getsysinfo(){
+ return {
+ "hostname": os.hostname(),
+ "userdir": os.homedir(),
+ "platform": os.platform(),
+ "userinfo":os.userInfo()
+ }
+ }
+}
+