Commit 4801018c authored by Romain Courteaud's avatar Romain Courteaud Committed by Jérome Perrin

Publish static version.

parent 734aabb1
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
<script src="InputModule_viewAddDocumentDialog.js" type="text/javascript"></script> <script src="InputModule_viewAddDocumentDialog.js" type="text/javascript"></script>
</head> </head>
<body> <body>
<form class="new_form">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline ui-icon-plus ui-btn-icon-right">Empty</button>
</form>
<form class="import_form"> <form class="import_form">
<input id="dream_import" type="file" required="" <input id="dream_import" type="file" required=""
name="dream_import"> name="dream_import">
......
...@@ -2,29 +2,30 @@ ...@@ -2,29 +2,30 @@
initGadgetMixin */ initGadgetMixin */
(function(window, rJS, RSVP, promiseEventListener, promiseReadAsText, initGadgetMixin) { (function(window, rJS, RSVP, promiseEventListener, promiseReadAsText, initGadgetMixin) {
"use strict"; "use strict";
var gadget_klass = rJS(window); function createDocument(gadget, name) {
initGadgetMixin(gadget_klass); var now = new Date();
gadget_klass.declareAcquiredMethod("aq_post", "jio_post").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantToDisplayThisDocument", "whoWantToDisplayThisDocument").declareMethod("startService", function() { // Create jIO document
var gadget = this, json_data, name; return gadget.aq_post({
title: name,
type: "Dream",
format: "application/json",
modified: now.toUTCString(),
date: now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate()
});
}
function waitForImport(gadget) {
var json_data, name;
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
return promiseEventListener(gadget.props.element.getElementsByClassName("import_form")[0], "submit", false); return promiseEventListener(gadget.props.element.getElementsByClassName("import_form")[0], "submit", false);
}).push(function(evt) { }).push(function(evt) {
// Prevent double click // Prevent double click
gadget.props.element.getElementsByClassName("ui-btn")[0].disabled = true; evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
var file = evt.target.dream_import.files[0]; var file = evt.target.dream_import.files[0];
name = file.name; name = file.name;
return promiseReadAsText(file); return promiseReadAsText(file);
}).push(function(json) { }).push(function(json) {
var now = new Date();
json_data = json; json_data = json;
// Create jIO document return createDocument(gadget, name);
return gadget.aq_post({
title: name,
type: "Dream",
format: "application/json",
modified: now.toUTCString(),
date: now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate()
});
}).push(function(jio_document) { }).push(function(jio_document) {
// Add JSON as attachment // Add JSON as attachment
return gadget.aq_putAttachment({ return gadget.aq_putAttachment({
...@@ -33,6 +34,40 @@ ...@@ -33,6 +34,40 @@
_data: json_data, _data: json_data,
_mimetype: "application/json" _mimetype: "application/json"
}); });
});
}
function waitForNew(gadget) {
var json_data = {
nodes: {},
edges: {},
preference: {},
general: {},
wip_part_spreadsheet: [ [ "Order ID", "Due Date", "Priority", "Project Manager", "Part", "Part Type", "Sequence", "Processing Times", "Prerequisites Parts" ] ],
shift_spreadsheet: [ [ "Day", "Machines", // XXX more generic name ?
"Start", "End" ] ]
}, name = "FromScratch";
return new RSVP.Queue().push(function() {
return promiseEventListener(gadget.props.element.getElementsByClassName("new_form")[0], "submit", false);
}).push(function(evt) {
// Prevent double click
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
return createDocument(gadget, name);
}).push(function(jio_document) {
// Add JSON as attachment
return gadget.aq_putAttachment({
_id: jio_document.id,
_attachment: "body.json",
_data: JSON.stringify(json_data),
_mimetype: "application/json"
});
});
}
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_post", "jio_post").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantToDisplayThisDocument", "whoWantToDisplayThisDocument").declareMethod("startService", function() {
var gadget = this;
return new RSVP.Queue().push(function() {
return RSVP.any([ waitForImport(gadget), waitForNew(gadget) ]);
}).push(function(result) { }).push(function(result) {
return gadget.whoWantToDisplayThisDocument(result.id); return gadget.whoWantToDisplayThisDocument(result.id);
}).push(function(url) { }).push(function(url) {
......
...@@ -19,6 +19,10 @@ ...@@ -19,6 +19,10 @@
}), gadget.getDeclaredGadget("productionline_graph") ]); }), gadget.getDeclaredGadget("productionline_graph") ]);
}).push(function(result_list) { }).push(function(result_list) {
return result_list[1].render(result_list[0]); return result_list[1].render(result_list[0]);
}).push(function() {
return gadget.getDeclaredGadget("productionline_toolbox");
}).push(function(toolbox_gadget) {
toolbox_gadget.render();
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
var g = this; var g = this;
......
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Edit Wip Part Spreadsheet</title> <title>Edit Shift Spreadsheet</title>
<script src="../lib/rsvp.min.js" type="text/javascript"></script> <script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script> <script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="../lib/jquery.js" type="text/javascript"></script>
<script src="../lib/jquerymobile.js" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script> <script src="mixin_gadget.js" type="text/javascript"></script>
<script src="Input_viewShiftSpreadsheet.js" type="text/javascript"></script> <script src="Input_viewShiftSpreadsheet.js" type="text/javascript"></script>
...@@ -13,5 +15,9 @@ ...@@ -13,5 +15,9 @@
<body> <body>
<div data-gadget-url="../handsontable/index.html" <div data-gadget-url="../handsontable/index.html"
data-gadget-scope="tableeditor"></div> data-gadget-scope="tableeditor"></div>
<form class="save_form">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right">Save</button>
</form>
</body> </body>
</html> </html>
/*global rJS, RSVP, initGadgetMixin */ /*global rJS, RSVP, initGadgetMixin, loopEventListener */
(function(window, rJS, RSVP, initGadgetMixin) { (function(window, rJS, RSVP, initGadgetMixin, loopEventListener) {
"use strict"; "use strict";
function saveSpreadsheet(evt) {
var gadget = this, editor_data, editor_gadget;
return new RSVP.Queue().push(function() {
// Prevent double click
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
return gadget.getDeclaredGadget("tableeditor");
}).push(function(tablegadget) {
editor_gadget = tablegadget;
return editor_gadget.getData();
}).push(function(data) {
editor_data = data;
// Always get a fresh version, to prevent deleting spreadsheet & co
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json"
});
}).push(function(body) {
var data = JSON.parse(body);
data.shift_spreadsheet = JSON.parse(editor_data);
return gadget.aq_putAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json",
_data: JSON.stringify(data, null, 2),
_mimetype: "application/json"
});
}).push(function() {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
});
}
function waitForSave(gadget) {
return loopEventListener(gadget.props.element.getElementsByClassName("save_form")[0], "submit", false, saveSpreadsheet.bind(gadget));
}
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) { gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) {
...@@ -15,8 +47,9 @@ ...@@ -15,8 +47,9 @@
return result_list[1].render(JSON.stringify(JSON.parse(result_list[0]).shift_spreadsheet)); return result_list[1].render(JSON.stringify(JSON.parse(result_list[0]).shift_spreadsheet));
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
var gadget = this;
return this.getDeclaredGadget("tableeditor").push(function(tableeditor) { return this.getDeclaredGadget("tableeditor").push(function(tableeditor) {
return tableeditor.startService(); return RSVP.all([ tableeditor.startService(), waitForSave(gadget) ]);
}); });
}); });
})(window, rJS, RSVP, initGadgetMixin); })(window, rJS, RSVP, initGadgetMixin, loopEventListener);
\ No newline at end of file \ No newline at end of file
...@@ -19,11 +19,9 @@ ...@@ -19,11 +19,9 @@
<script src="Input_viewSimulation.js" type="text/javascript"></script> <script src="Input_viewSimulation.js" type="text/javascript"></script>
</head> </head>
<body> <body>
<form> <form class="save_form">
<fieldset class="simulation_parameters"> <fieldset class="simulation_parameters">
</fieldset> </fieldset>
</form>
<form class="run_form">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline <button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-refresh ui-btn-icon-right">Run Simulation</button> ui-icon-refresh ui-btn-icon-right">Run Simulation</button>
</form> </form>
......
...@@ -3,6 +3,97 @@ ...@@ -3,6 +3,97 @@
/*jslint nomen: true */ /*jslint nomen: true */
(function(window, rJS, RSVP, $, Handlebars, promiseEventListener, initGadgetMixin) { (function(window, rJS, RSVP, $, Handlebars, promiseEventListener, initGadgetMixin) {
"use strict"; "use strict";
function saveForm(gadget) {
var general = {};
return new RSVP.Queue().push(function() {
var i, promise_list = [];
for (i = 0; i < gadget.props.gadget_list.length; i += 1) {
promise_list.push(gadget.props.gadget_list[i].getContent());
}
return RSVP.all(promise_list);
}).push(function(result_list) {
var i, result, key;
for (i = 0; i < result_list.length; i += 1) {
result = result_list[i];
for (key in result) {
if (result.hasOwnProperty(key)) {
// Drop empty
if (result[key]) {
general[key] = result[key];
}
}
}
}
// Always get a fresh version, to prevent deleting spreadsheet & co
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json"
});
}).push(function(body) {
var data = JSON.parse(body);
data.general = general;
return gadget.aq_putAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json",
_data: JSON.stringify(data, null, 2),
_mimetype: "application/json"
});
});
}
function runSimulation(gadget) {
return new RSVP.Queue().push(function() {
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json"
});
}).push(function(body_json) {
// XXX Hardcoded relative URL
return gadget.aq_ajax({
url: "../../runSimulation",
type: "POST",
data: body_json,
headers: {
"Content-Type": "application/json"
}
});
}).push(function(evt) {
var json_data = JSON.parse(evt.target.responseText);
if (json_data.success !== true) {
throw new Error(json_data.error);
}
return gadget.aq_putAttachment({
_id: gadget.props.jio_key,
_attachment: "simulation.json",
_data: JSON.stringify(json_data.data, null, 2),
_mimetype: "application/json"
});
}).push(function() {
return gadget.whoWantToDisplayThisDocument(gadget.props.jio_key, "view_result");
}).push(function(url) {
return gadget.pleaseRedirectMyHash(url);
});
}
function waitForRunSimulation(gadget) {
var submit_evt;
return new RSVP.Queue().push(function() {
return promiseEventListener(gadget.props.element.getElementsByClassName("save_form")[0], "submit", false);
}).push(function(evt) {
submit_evt = evt;
// Prevent double click
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
$.mobile.loading("show");
return saveForm(gadget);
}).push(function() {
return runSimulation(gadget);
}).push(undefined, function(error) {
// Always drop the loader
$.mobile.loading("hide");
throw error;
}).push(function() {
submit_evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
$.mobile.loading("hide");
});
}
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Handlebars // Handlebars
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -18,6 +109,9 @@ ...@@ -18,6 +109,9 @@
parent_element.insertAdjacentHTML("beforeend", label_template({ parent_element.insertAdjacentHTML("beforeend", label_template({
label: property.name || property.id label: property.name || property.id
})); }));
if (property.type === "number") {
return gadget.declareGadget("../number_field/index.html");
}
return gadget.declareGadget("../string_field/index.html"); return gadget.declareGadget("../string_field/index.html");
}).push(function(gg) { }).push(function(gg) {
sub_gadget = gg; sub_gadget = gg;
...@@ -33,6 +127,7 @@ ...@@ -33,6 +127,7 @@
return sub_gadget.getElement(); return sub_gadget.getElement();
}).push(function(sub_element) { }).push(function(sub_element) {
parent_element.appendChild(sub_element); parent_element.appendChild(sub_element);
gadget.props.gadget_list.push(sub_gadget);
}); });
} }
queue = gadget.aq_getAttachment({ queue = gadget.aq_getAttachment({
...@@ -43,6 +138,7 @@ ...@@ -43,6 +138,7 @@
return gadget.aq_getConfigurationDict(); return gadget.aq_getConfigurationDict();
}).push(function(configuration_dict) { }).push(function(configuration_dict) {
var property_list = configuration_dict["Dream-Configuration"].property_list; var property_list = configuration_dict["Dream-Configuration"].property_list;
gadget.props.gadget_list = [];
for (i = 0; i < property_list.length; i += 1) { for (i = 0; i < property_list.length; i += 1) {
property = property_list[i]; property = property_list[i];
if (property._class === "Dream.Property") { if (property._class === "Dream.Property") {
...@@ -53,47 +149,6 @@ ...@@ -53,47 +149,6 @@
}); });
return queue; return queue;
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
var gadget = this; return waitForRunSimulation(this);
return new RSVP.Queue().push(function() {
return promiseEventListener(gadget.props.element.getElementsByClassName("run_form")[0], "submit", false);
}).push(function() {
// Prevent double click
gadget.props.element.getElementsByClassName("ui-btn")[0].disabled = true;
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json"
});
}).push(function(body_json) {
$.mobile.loading("show");
// XXX Hardcoded relative URL
return gadget.aq_ajax({
url: "../../runSimulation",
type: "POST",
data: body_json,
headers: {
"Content-Type": "application/json"
}
});
}).push(undefined, function(error) {
// Always drop the loader
$.mobile.loading("hide");
throw error;
}).push(function(evt) {
$.mobile.loading("hide");
var json_data = JSON.parse(evt.target.responseText);
if (json_data.success !== true) {
throw new Error(json_data.error);
}
return gadget.aq_putAttachment({
_id: gadget.props.jio_key,
_attachment: "simulation.json",
_data: JSON.stringify(json_data.data, null, 2),
_mimetype: "application/json"
});
}).push(function() {
return gadget.whoWantToDisplayThisDocument(gadget.props.jio_key, "view_result");
}).push(function(url) {
return gadget.pleaseRedirectMyHash(url);
});
}); });
})(window, rJS, RSVP, jQuery, Handlebars, promiseEventListener, initGadgetMixin); })(window, rJS, RSVP, jQuery, Handlebars, promiseEventListener, initGadgetMixin);
\ No newline at end of file
...@@ -6,12 +6,19 @@ ...@@ -6,12 +6,19 @@
<title>Edit Wip Part Spreadsheet</title> <title>Edit Wip Part Spreadsheet</title>
<script src="../lib/rsvp.min.js" type="text/javascript"></script> <script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script> <script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="../lib/jquery.js" type="text/javascript"></script>
<script src="../lib/jquerymobile.js" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script> <script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_promise.js" type="text/javascript"></script>
<script src="Input_viewWipPartSpreadsheet.js" type="text/javascript"></script> <script src="Input_viewWipPartSpreadsheet.js" type="text/javascript"></script>
</head> </head>
<body> <body>
<div data-gadget-url="../handsontable/index.html" <div data-gadget-url="../handsontable/index.html"
data-gadget-scope="tableeditor"></div> data-gadget-scope="tableeditor"></div>
<form class="save_form">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right">Save</button>
</form>
</body> </body>
</html> </html>
/*global rJS, RSVP, initGadgetMixin */ /*global rJS, RSVP, initGadgetMixin, loopEventListener */
(function(window, rJS, RSVP, initGadgetMixin) { (function(window, rJS, RSVP, initGadgetMixin, loopEventListener) {
"use strict"; "use strict";
function saveSpreadsheet(evt) {
var gadget = this, editor_data, editor_gadget;
return new RSVP.Queue().push(function() {
// Prevent double click
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
return gadget.getDeclaredGadget("tableeditor");
}).push(function(tablegadget) {
editor_gadget = tablegadget;
return editor_gadget.getData();
}).push(function(data) {
editor_data = data;
// Always get a fresh version, to prevent deleting spreadsheet & co
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json"
});
}).push(function(body) {
var data = JSON.parse(body);
data.wip_part_spreadsheet = JSON.parse(editor_data);
return gadget.aq_putAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json",
_data: JSON.stringify(data, null, 2),
_mimetype: "application/json"
});
}).push(function() {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
});
}
function waitForSave(gadget) {
return loopEventListener(gadget.props.element.getElementsByClassName("save_form")[0], "submit", false, saveSpreadsheet.bind(gadget));
}
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareMethod("render", function(options) { gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareMethod("render", function(options) {
var jio_key = options.id, gadget = this; var jio_key = options.id, gadget = this;
gadget.props.jio_key = jio_key; gadget.props.jio_key = jio_key;
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
...@@ -15,8 +47,9 @@ ...@@ -15,8 +47,9 @@
return result_list[1].render(JSON.stringify(JSON.parse(result_list[0]).wip_part_spreadsheet)); return result_list[1].render(JSON.stringify(JSON.parse(result_list[0]).wip_part_spreadsheet));
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
var gadget = this;
return this.getDeclaredGadget("tableeditor").push(function(tableeditor) { return this.getDeclaredGadget("tableeditor").push(function(tableeditor) {
return tableeditor.startService(); return RSVP.all([ tableeditor.startService(), waitForSave(gadget) ]);
}); });
}); });
})(window, rJS, RSVP, initGadgetMixin); })(window, rJS, RSVP, initGadgetMixin, loopEventListener);
\ No newline at end of file \ No newline at end of file
/*global RSVP, FileReader */ /*global RSVP, FileReader */
/*jslint unparam: true */
(function(window, RSVP, FileReader) { (function(window, RSVP, FileReader) {
"use strict"; "use strict";
window.loopEventListener = function(target, type, useCapture, callback) {
//////////////////////////
// Infinite event listener (promise is never resolved)
// eventListener is removed when promise is cancelled/rejected
//////////////////////////
var handle_event_callback, callback_promise;
function cancelResolver() {
if (callback_promise !== undefined && typeof callback_promise.cancel === "function") {
callback_promise.cancel();
}
}
function canceller() {
if (handle_event_callback !== undefined) {
target.removeEventListener(type, handle_event_callback, useCapture);
}
cancelResolver();
}
function itsANonResolvableTrap(resolve, reject) {
handle_event_callback = function(evt) {
evt.stopPropagation();
evt.preventDefault();
cancelResolver();
callback_promise = new RSVP.Queue().push(function() {
return callback(evt);
}).push(undefined, function(error) {
if (!(error instanceof RSVP.CancellationError)) {
canceller();
reject(error);
}
});
};
target.addEventListener(type, handle_event_callback, useCapture);
}
return new RSVP.Promise(itsANonResolvableTrap, canceller);
};
window.promiseEventListener = function(target, type, useCapture) { window.promiseEventListener = function(target, type, useCapture) {
////////////////////////// //////////////////////////
// Resolve the promise as soon as the event is triggered // Resolve the promise as soon as the event is triggered
......
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>Number field</title>
<!-- renderjs -->
<script src="../lib/rsvp.min.js"></script>
<script src="../lib/renderjs.min.js"></script>
<!-- custom script -->
<script src="numberfield.js" type="text/javascript"></script>
</head>
<body>
<input type='number' step="any" data-mini="true" />
</body>
</html>
/*global window, rJS */
(function(window, rJS) {
"use strict";
rJS(window).ready(function(gadget) {
return gadget.getElement().push(function(element) {
gadget.element = element;
});
}).declareMethod("render", function(options) {
var input = this.element.querySelector("input"), field_json = options.field_json || {};
input.setAttribute("value", field_json.value);
input.setAttribute("name", field_json.key);
input.setAttribute("title", field_json.title);
}).declareMethod("getContent", function() {
var input = this.element.querySelector("input"), result = {};
if (input.value !== "") {
result[input.getAttribute("name")] = parseFloat(input.value);
} else {
result[input.getAttribute("name")] = null;
}
return result;
});
})(window, rJS);
\ No newline at end of file
...@@ -9,12 +9,19 @@ ...@@ -9,12 +9,19 @@
<script src="../lib/jquery-ui.js"></script> <script src="../lib/jquery-ui.js"></script>
<script src="../lib/rsvp.min.js"></script> <script src="../lib/rsvp.min.js"></script>
<script src="../lib/renderjs.min.js"></script> <script src="../lib/renderjs.min.js"></script>
<script src="../lib/handlebars.min.js"></script>
<script id="tool-template" type="text/x-handlebars-template">
<div id="{{key}}"
class="tool {{key}}">
{{name}}
<ul/>
</div>
</script>
<script src="toolbox.js"></script> <script src="toolbox.js"></script>
</head> </head>
<body> <body>
<div id="tools"> <div class="tools"></div>
<div id="tools-container"></div>
</div>
</body> </body>
</html> </html>
#tools{border:1px solid #999;margin:20px 0;border-radius:10px;padding-bottom:20px}#tools-container{margin-bottom:4px}#tools .ui-button{margin:4px 0}.tool{border:1px solid #d3d3d3;box-shadow:1px 1px 2px #aaa;min-width:7em;height:3em;z-index:10001;color:gray;font-family:serif;font-style:italic;font-size:.9em;margin:.8em;display:inline-block;border-radius:5px;text-align:center;padding-top:1.3em}.Dream-Source,.Dream-BatchSource{border:1px solid #bbc;background-color:#ffe;background-image:linear-gradient(to bottom,#ffe 0,#dde 100%)}.Dream-Machine,.Dream-MachineJobShop,.Dream-BatchScrapMachine,.Dream-MachineManagedJob,.Dream-MouldAssembly{border:1px solid #cbc;background-color:#fef;background-image:linear-gradient(to bottom,#fef 0,#ede 100%)}.Dream-Queue,.Dream-QueueJobShop,.Dream-LineClearance,.Dream-QueueManagedJob,.Dream-ConditionalBuffer,.Dream-OrderDecomposition,.Dream-MouldAssemblyBuffer{border:1px solid #bcc;background-color:#eff;background-image:linear-gradient(to bottom,#eff 0,#dee 100%)}.Dream-Exit,.Dream-ExitJobShop{border:1px solid #ccb;background-color:#eef;background-image:linear-gradient(to bottom,#eef 0,#dde 100%)}.Dream-EventGenerator{border:1px solid #cba;background-color:#fdc;background-image:linear-gradient(to bottom,#fdc 0,#ecb 100%)}.Dream-BatchDecomposition,.Dream-BatchDecompositionStartTime,.Dream-BatchReassembly{border:1px solid #bcb;background-color:#dfd;background-image:linear-gradient(to bottom,#dfd 0,#cec 100%)}.Dream-Repairman{border:1px solid #cbb;background-color:#fdd;background-image:linear-gradient(to bottom,#fdd 0,#dcc 100%)} .tools{border:1px solid #999;margin:20px 0;border-radius:10px;padding-bottom:20px}.tools-container{margin-bottom:4px}.tools .ui-button{margin:4px 0}.tool{border:1px solid #d3d3d3;box-shadow:1px 1px 2px #aaa;min-width:7em;height:3em;z-index:10001;color:gray;font-family:serif;font-style:italic;font-size:.9em;margin:.8em;display:inline-block;border-radius:5px;text-align:center;padding-top:1.3em}.Dream-Source,.Dream-BatchSource{border:1px solid #bbc;background-color:#ffe;background-image:linear-gradient(to bottom,#ffe 0,#dde 100%)}.Dream-Machine,.Dream-MachineJobShop,.Dream-BatchScrapMachine,.Dream-MachineManagedJob,.Dream-MouldAssembly{border:1px solid #cbc;background-color:#fef;background-image:linear-gradient(to bottom,#fef 0,#ede 100%)}.Dream-Queue,.Dream-QueueJobShop,.Dream-LineClearance,.Dream-QueueManagedJob,.Dream-ConditionalBuffer,.Dream-OrderDecomposition,.Dream-MouldAssemblyBuffer{border:1px solid #bcc;background-color:#eff;background-image:linear-gradient(to bottom,#eff 0,#dee 100%)}.Dream-Exit,.Dream-ExitJobShop{border:1px solid #ccb;background-color:#eef;background-image:linear-gradient(to bottom,#eef 0,#dde 100%)}.Dream-EventGenerator{border:1px solid #cba;background-color:#fdc;background-image:linear-gradient(to bottom,#fdc 0,#ecb 100%)}.Dream-BatchDecomposition,.Dream-BatchDecompositionStartTime,.Dream-BatchReassembly{border:1px solid #bcb;background-color:#dfd;background-image:linear-gradient(to bottom,#dfd 0,#cec 100%)}.Dream-Repairman{border:1px solid #cbb;background-color:#fdd;background-image:linear-gradient(to bottom,#fdd 0,#dcc 100%)}
\ No newline at end of file \ No newline at end of file
/*global window, RSVP, $, rJS*/ /*global window, document, RSVP, rJS, Handlebars*/
(function(window, RSVP, $, rJS) { (function(window, document, RSVP, rJS, Handlebars) {
"use strict"; "use strict";
rJS(window).declareAcquiredMethod("getConfigurationDict", "getConfigurationDict").declareMethod("startService", function() { /*jslint nomen: true*/
var gadget_klass = rJS(window), tool_template_source = gadget_klass.__template_element.getElementById("tool-template").innerHTML, tool_template = Handlebars.compile(tool_template_source);
gadget_klass.declareAcquiredMethod("getConfigurationDict", "getConfigurationDict").declareMethod("render", function() {
var g = this; var g = this;
return RSVP.all([ g.getElement(), g.getConfigurationDict() ]).then(function(result) { return new RSVP.Queue().push(function() {
var render_element = $(result[0]).find("#tools-container"); return g.getConfigurationDict();
$.each(result[1], function(key, val) { }).push(function(config) {
var name = val.name || key.split("-")[1]; g.tools_container = document.createElement("div");
g.tools_container.className = "tools-container";
Object.keys(config).forEach(function(key) {
var name = config[key].name || key.split("-")[1];
if (key !== "Dream-Configuration") { if (key !== "Dream-Configuration") {
render_element.append('<div id="' + key + '" class="tool ' + key + '">' + name + "<ul/></div>"); g.tools_container.innerHTML += tool_template({
key: key,
name: name
});
} }
}); });
}); });
}).declareMethod("startService", function() {
var g = this;
return g.getElement().then(function(element) {
element.querySelector(".tools").appendChild(g.tools_container);
});
}); });
})(window, RSVP, $, rJS); })(window, document, RSVP, rJS, Handlebars);
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment