5 Commits

7 changed files with 113 additions and 35 deletions

View File

@@ -5,9 +5,10 @@
<link rel="stylesheet" href="ZGUI.css">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<script src="TrimSPelec.js"></script>
<!script src="TrimSPWeb.js"></script>
<script src="TrimSPlib.js"></script>
<script src="myplots.js"></script>
<!script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<title>Trim.SP</title>
</head>
<body onresize="resizePl()" onload="adjust_table();adjust_scans();">
@@ -62,6 +63,7 @@
<option value="Mg-31">Mg-31</option>
<option value="H">H</option>
<option value="He">He</option>
<option value="Ar">Ar</option>
</select>
</td>
</tr>

View File

@@ -1424,9 +1424,22 @@ function startSequence() {
}
iScan++;
}
let seq_file = All["fileNamePrefix"]+"_Seq_Results.dat";
let data = readAsciiFile(All["workPath"]+"/"+"fort.33");
let LComp = "";
let chem_formula = "";
let place_holder = "";
let re = new RegExp(place_holder,"g");
for (let i=1;i<=All["numLayer"];i++) {
LComp = "L"+i+"Comp";
chem_formula = All[LComp];
place_holder = "impL"+i;
re = new RegExp(place_holder,"g");
data = data.replace(re, chem_formula);
}
let seq_file = All["workPath"]+"/"+All["fileNamePrefix"]+"_Seq_Results.dat";
writeAsciiFile(seq_file, data);
// Remove redundant files and change the name fort.33
if (!webOrApp) {
// cmd="cd " + All["workPath"] + ";rm -f eingabe1.inp; mv -f fort.33 " + seq_file;

View File

@@ -4,26 +4,70 @@ function writeAsciiFile(filename,content) {
// Write string content into ascii file filename
// Go via CGI script
//console.log(filename, content);
// Prepare CGI args
let cgiargs = "?fn="+filename;
// Prepare CGI args use POST for long files
let cgiargs = "fn="+filename; // POST
let lines = content.split(/\n/);
let prefix = filename.split(/\//);
for (let i=0; i<lines.length; i++) {
cgiargs += "&line" + i + "=" + lines[i];
cgiargs += "&line" + i + "=" + lines[i].replace(/\s\s+/g, ' ');
}
var xhttp;
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//console.log("resptext=",xhttp.responseText);
console.log("response=",xhttp.responseText);
} else if (this.readyState == 4) {
console.log(xhttp.status, xhttp.statusText);
}
}
let request = "/cgi-bin/singleTrimSP.cgi"+cgiargs;
xhttp.open("GET", request, false);
xhttp.send();
let request = "/cgi-bin/singleTrimSP.cgi"; //POST
xhttp.open("POST", request, false); //POST
//Send the proper header information along with the request
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); //POST
xhttp.send(cgiargs); //POST
// Now you can add a link to the files
let d = document.getElementById("linkDiv");
if (!d) {
d = document.createElement("div");
d.id = "linkDiv";
document.body.appendChild(d);
}
let htmlLink = "Download files: <a href='";
htmlLink += "/tmp/" + prefix[2] + ".tgz'>";
htmlLink += prefix[2] + ".tgz</a>";
d.innerHTML = htmlLink;
return(1);
}
function writeAsciiFile2(filename,content) {
// Write string content into ascii file filename
// Go via CGI script
//console.log(filename, content);
// Prepare CGI args use GET for short files
let cgiargs = "?fn="+filename; // GET
let lines = content.split(/\n/);
let prefix = filename.split(/\//);
for (let i=0; i<lines.length; i++) {
cgiargs += "&line" + i + "=" + lines[i].replace(/\s\s+/g, ' ');
}
var xhttp;
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log("response=",xhttp.responseText);
} else if (this.readyState == 4) {
console.log(xhttp.status, xhttp.statusText);
}
}
let request = "/cgi-bin/singleTrimSP.cgi"+cgiargs; // GET
xhttp.open("GET", request, false); //GET
//Send the proper header information along with the request
xhttp.send(); // GET
// Now you can add a link to the files
let d = document.getElementById("linkDiv");
if (!d) {
@@ -60,6 +104,7 @@ function readAsciiFile(filename) {
filename += "?" + Date();
//filename = "http://musruser.psi.ch" + filename;
xhttp.open("GET", filename, false);
xhttp.overrideMimeType("text/plain");
xhttp.send();
return(xhttp.responseText);
}

64
main.js
View File

@@ -34,8 +34,10 @@ function createWindow () {
console.log(result.canceled);
console.log(result.filePaths);
if (!result.canceled) {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('openFile',result.filePaths);
setImmediate(function() {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('openFile',result.filePaths);
});
}
}).catch(err => {
console.log(err);
@@ -51,9 +53,11 @@ function createWindow () {
defaultPath : app.getPath('temp'),
properties:["openDirectory"]}
).then(result => {
console.log(result.filePaths)
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('selectFolder',result.filePaths);
setImmediate(function() {
console.log(result.filePaths)
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('selectFolder',result.filePaths);
});
}).catch(err => {
console.log(err);
})
@@ -63,8 +67,10 @@ function createWindow () {
label: 'Save',
accelerator: 'CmdOrCtrl+S',
click () {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('saveFile','');
setImmediate(function() {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('saveFile','');
});
}
},
{
@@ -80,8 +86,10 @@ function createWindow () {
],
properties: ['showOverwriteConfirmation']}
).then(result => {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('saveFile',result.filePath);
setImmediate(function() {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('saveFile',result.filePath);
});
}).catch(err => {
console.log(err);
})
@@ -91,11 +99,13 @@ function createWindow () {
label: 'Print',
accelerator: 'CmdOrCtrl+P',
click () {
var focusedWindow = BrowserWindow.getFocusedWindow();
const options = {};
focusedWindow.webContents.print(options, (success, errorType) => {
if (!success) console.log(errorType)
})
setImmediate(function() {
var focusedWindow = BrowserWindow.getFocusedWindow();
const options = {};
focusedWindow.webContents.print(options, (success, errorType) => {
if (!success) console.log(errorType)
});
});
}
},
{
@@ -124,8 +134,10 @@ function createWindow () {
console.log(result.canceled);
console.log(result.filePaths);
if (!result.canceled) {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('plotProf',result.filePaths);
setImmediate(function() {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('plotProf',result.filePaths);
});
}
}).catch(err => {
console.log(err);
@@ -147,8 +159,10 @@ function createWindow () {
console.log(result.canceled);
console.log(result.filePaths);
if (!result.canceled) {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('plotFrac',result.filePaths);
setImmediate(function() {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('plotFrac',result.filePaths);
});
}
}).catch(err => {
console.log(err);
@@ -170,8 +184,10 @@ function createWindow () {
console.log(result.canceled);
console.log(result.filePaths);
if (!result.canceled) {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('plotMean',result.filePaths);
setImmediate(function() {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('plotMean',result.filePaths);
});
}
}).catch(err => {
console.log(err);
@@ -231,9 +247,11 @@ ipcMain.on('browseFolder', (event, args) => {
properties:["openDirectory"]}
).then(result => {
console.log(result)
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('browseFolder',result.filePaths);
app.setPath('temp',result.filePaths[0]);
setImmediate(function() {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('browseFolder',result.filePaths);
app.setPath('temp',result.filePaths[0]);
});
}).catch(err => {
console.log(err);
})

View File

@@ -1,6 +1,6 @@
{
"name": "TrimSP",
"version": "1.0.1",
"version": "1.0.2",
"description": "Trim.SP simulation to calculate stopping profile of implanted probes.",
"main": "main.js",
"scripts": {