Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

Commit

Permalink
Miscellaneous fixes. Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Amphiluke committed Jan 6, 2017
1 parent e0e9eb1 commit 3a6796d
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
vendor
build
build
dev/js/**/*.amd.js
2 changes: 1 addition & 1 deletion build/css/main.css

Large diffs are not rendered by default.

Binary file removed build/img/dot.gif
Binary file not shown.
21 changes: 10 additions & 11 deletions build/js/interface.amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ define("file-processing.amd.js", ["exports", "./utils.amd.js", "./structure.amd.
}
},
parse(fileStr) {
let molRE = /\n\s*mol\s+(\d+)([\s\S]+)\n\s*endmol\s+\1/g,
let molRE = /\n\s*mol\s+(\d+)([\s\S]+)\n\s*endmol\s+\1\b/g,
atmRE = /^atom\s+\d+\s+.+$/gm,
result = {
atoms: [],
Expand Down Expand Up @@ -1186,7 +1186,7 @@ define("components/menu.amd.js", ["exports", "jquery", "../eventful.amd.js", "..
},
exec(file) {
if (file) {
_fileProcessingAmd2.default.load(file);
_fileProcessingAmd2.default.load(file).then(() => _appAmd2.default.trigger("app:structure:loaded"));
}
}
});
Expand Down Expand Up @@ -1429,34 +1429,34 @@ define("worker.amd.js", ["exports", "./observer.amd.js", "./app.amd.js"], functi
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
let calcWorker = new Worker("js/calc.js");
let worker = new Worker("js/calc.js");
let blockingMethod = "ready";
_appAmd2.default.busy = true;
let worker = Object.assign(new _observerAmd2.default(), {invoke(method, data) {
let workerHelper = Object.assign(new _observerAmd2.default(), {invoke(method, data) {
if (blockingMethod) {
throw new Error(`Unable to run the method “${method}” as the blocking method “${blockingMethod}” is still running`);
}
blockingMethod = method;
_appAmd2.default.busy = true;
calcWorker.postMessage({
worker.postMessage({
method,
data
});
}});
calcWorker.addEventListener("message", ({data: {method,
worker.addEventListener("message", ({data: {method,
data} = {}}) => {
if (method) {
if (method === blockingMethod) {
_appAmd2.default.busy = false;
blockingMethod = null;
}
worker.trigger(method, data);
workerHelper.trigger(method, data);
}
});
calcWorker.addEventListener("error", (e) => {
worker.addEventListener("error", (e) => {
throw e;
});
exports.default = worker;
exports.default = workerHelper;
});

})();
Expand Down Expand Up @@ -1517,7 +1517,6 @@ define("structure.amd.js", ["exports", "./observer.amd.js", "./app.amd.js", "./u
}
this.trigger("updateStructure", rescanAtoms !== false);
if (fromWorker !== true) {
_appAmd2.default.trigger("app:structure:loaded");
syncWorker();
}
},
Expand Down Expand Up @@ -1948,7 +1947,7 @@ define("interface.amd.js", ["./structure.amd.js", "./app.amd.js", "./components/
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
_structureAmd2.default.on("app:structure:loaded", () => {
_appAmd2.default.on("app:structure:loaded", () => {
document.title = `${_structureAmd2.default.structure.name} - Open evolver`;
});
_appAmd2.default.on("app:stateChange", (busy) => {
Expand Down
5 changes: 5 additions & 0 deletions dev/css/dialogs/potentials.less
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,9 @@
width:100%;
}
}
label,
a {
display:inline-block;
vertical-align:middle;
}
}
2 changes: 1 addition & 1 deletion dev/css/main.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import (reference) "ui";

@import (less) "../../vendor/normalize.css";
@import (less) "../../node_modules/normalize.css/normalize.css";

body {
font:normal percentage(unit((@root-font-size / 16))) ~"/" unit((@root-line-height / @root-font-size)) @base-font-family;
Expand Down
Binary file removed dev/img/dot.gif
Binary file not shown.
2 changes: 1 addition & 1 deletion dev/js/components/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ app.addAction("load", {
},
exec(file) {
if (file) {
fileAPI.load(file);
fileAPI.load(file).then(() => app.trigger("app:structure:loaded"));
}
}
});
2 changes: 1 addition & 1 deletion dev/js/file-processing.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ formats.hin = {
},

parse(fileStr) {
let molRE = /\n\s*mol\s+(\d+)([\s\S]+)\n\s*endmol\s+\1/g,
let molRE = /\n\s*mol\s+(\d+)([\s\S]+)\n\s*endmol\s+\1\b/g,
atmRE = /^atom\s+\d+\s+.+$/gm,
result = {atoms: [], bonds: []},
mol = molRE.exec(fileStr);
Expand Down
2 changes: 1 addition & 1 deletion dev/js/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import "./components/menu.js";
import "./components/view.js";


structure.on("app:structure:loaded", () => {
app.on("app:structure:loaded", () => {
document.title = `${structure.structure.name} - Open evolver`;
});

Expand Down
1 change: 0 additions & 1 deletion dev/js/structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ let structureUtils = Object.assign(new Observer(), {
}
this.trigger("updateStructure", rescanAtoms !== false);
if (fromWorker !== true) {
app.trigger("app:structure:loaded");
syncWorker();
}
},
Expand Down
14 changes: 7 additions & 7 deletions dev/js/worker.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import Observer from "./observer.js";
import app from "./app.js";

let calcWorker = new Worker("js/calc.js");
let worker = new Worker("js/calc.js");
let blockingMethod = "ready";
app.busy = true; // calc worker needs some initialization before it can be used

let worker = Object.assign(new Observer(), {
let workerHelper = Object.assign(new Observer(), {
invoke(method, data) {
if (blockingMethod) {
throw new Error(`Unable to run the method “${method}” as the blocking method “${blockingMethod}” is still running`);
}
blockingMethod = method;
app.busy = true; // note that every worker invocation turns the application into busy state
calcWorker.postMessage({method, data});
worker.postMessage({method, data});
}
});

calcWorker.addEventListener("message", ({data: {method, data} = {}}) => {
worker.addEventListener("message", ({data: {method, data} = {}}) => {
if (method) {
if (method === blockingMethod) {
app.busy = false;
blockingMethod = null;
}
worker.trigger(method, data);
workerHelper.trigger(method, data);
}
});

calcWorker.addEventListener("error", e => {throw e;});
worker.addEventListener("error", e => {throw e;});

export default worker;
export default workerHelper;
3 changes: 1 addition & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ gulp.task("dependencies", () => {
let deps = [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/systemjs/dist/system.js",
"node_modules/three/build/three.min.js",
"node_modules/normalize.css/normalize.css"
"node_modules/three/build/three.min.js"
];
return gulp.src(deps).pipe(gulp.dest("vendor/"));
});
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "open-evolver",
"version": "2.0.0",
"version": "2.0.1",
"description": "Modeling quantum evolution at the nanoscale",
"author": "Amphiluke",
"scripts": {
Expand Down Expand Up @@ -32,6 +32,6 @@
"lodash": "^4.17.2",
"normalize.css": "^5.0.0",
"systemjs": "^0.19.41",
"three": "^0.82.1"
"three": "^0.83.0"
}
}

0 comments on commit 3a6796d

Please sign in to comment.