diff options
author | adhitya | 2016-04-09 08:48:42 +0000 |
---|---|---|
committer | adhitya | 2016-04-09 08:48:42 +0000 |
commit | 6a5d6986858b90ed509b6a065f27419a97b2c97f (patch) | |
tree | be7bd758c805646134892cf7f5807f600d6cc687 | |
parent | 90dac8fcb85ec4d8c762a1c42ccebec3ebb864ff (diff) | |
download | xcos-on-web-6a5d6986858b90ed509b6a065f27419a97b2c97f.tar.gz xcos-on-web-6a5d6986858b90ed509b6a065f27419a97b2c97f.tar.bz2 xcos-on-web-6a5d6986858b90ed509b6a065f27419a97b2c97f.zip |
Images are preloaded
-rw-r--r-- | index.html | 43 | ||||
-rw-r--r-- | src/js/xcos/core/details.js | 23 | ||||
-rw-r--r-- | test.html | 16 |
3 files changed, 69 insertions, 13 deletions
@@ -96,9 +96,8 @@ // Sets the graph container and configures the editor editor.setGraphContainer(container); - var config = mxUtils.load( - 'config/keyhandler-commons.xml'). - getDocumentElement(); + //var config = mxUtils.load('config/editor-commons.xml').getDocumentElement(); + var config = mxUtils.load('config/keyhandler-commons.xml').getDocumentElement(); editor.configure(config); // Disables drag-and-drop into non-swimlanes. @@ -298,7 +297,37 @@ } } } - }; + + // Preload all images + + var dir = ["blocks","images","images/icons48"]; + var fileextension = "."; + var blockImages = []; + $.each(dir, function (index, value) { + $.ajax({ // http://stackoverflow.com/a/18480589 + url: value, + success: function (data) { + $(data).find("a:contains(" + fileextension + ")").each(function () { + var filename = this.href.replace(window.location.host, ""); + filename = filename.replace("https://", value); + filename = filename.replace("http://", value); + blockImages.push(filename); + }); + // Prevent multi-threading and have function within call! + function preload(sources) { + var images = []; + for (var i = 0, length = sources.length; i < length; ++i) { + images[i] = new Image(); + images[i].src = sources[i]; + } + } + preload(blockImages); + } + }); + }); + + + } function createButtonImage(button, image){ if (image != null) @@ -805,6 +834,12 @@ v1 = graph.insertVertex(parent, null, '<table><tr><td>+</td><td></td></tr><tr><td></td><td>OP</td></tr><tr><td>-</td><td></td></tr></table>', x, y, 80, 80,'OpAmp'); createPorts(graph, v1, ['IMPLICIT','IMPLICIT'], [], ['IMPLICIT'], []); } + + else if(name == 'TEXT_f'){ + v1 = graph.insertVertex(parent, null, '', x, y, 80, 80,'TEXT_f'); + createPorts(graph, v1, [], [], [], []); + } + v1.setConnectable(false); } diff --git a/src/js/xcos/core/details.js b/src/js/xcos/core/details.js index 437cf9d..2a4963b 100644 --- a/src/js/xcos/core/details.js +++ b/src/js/xcos/core/details.js @@ -59,6 +59,7 @@ function scicos_model() { this.uid = options.uid || ''; } +// This might also have to be overloaded function scicos_diagram() { this.props = new scicos_params(); this.objs = []; @@ -66,6 +67,7 @@ function scicos_diagram() { this.contrib = []; } +// This might also have to be overloaded function scicos_params() { this.props = new scicos_params(); this.wpar = [600, 450, 0, 0, 600, 450]; @@ -80,6 +82,7 @@ function scicos_params() { this.doc = []; } +// This might also have to be overloaded function default_options() { var options = new Object(); var col3d = [0.8, 0.8, 0.8]; @@ -147,18 +150,32 @@ function standard_define() { return new scicos_block(block_options); } +function scicos_link (){ + this.xx = []; + this.yy = []; + this.id = ''; + this.thick = [0, 0]; + this.ct = [1, 1]; + this.from = []; + this.to = []; +} + function ANDLOG_f(){ var model = new scicos_model(); model.sim = "andlog"; model.out = [1]; - model.out2 = [1]; - model.evtin = [-1,-1]; + model.out2 = [1]; // null -> 1 + model.evtin = [-1,-1]; // 1, 1 -> -1, -1 model.blocktype = "d"; model.firing = []; model.dep_ut = [false, false]; var gr_i = "xstringb(orig(1),orig(2),txt,sz(1),sz(2),'fill');"; - var block = new standard_define([80,80], model, '', gr_i); + var block = new standard_define([80,80], model, 'LOGICAL<BR>AND', gr_i); // 3 -> 80 + + // Style block.graphics.out_implicit = "E"; + block.graphics.out_style = "ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0"; + block.graphics.style = "ANDLOG_f"; return block; } @@ -1,14 +1,18 @@ <html> <head> -<title>Web Page Design</title> +<title>Testing Details</title> <script type="text/javascript" src="src/js/xcos/core/details.js"></script> <script type="text/javascript" src="json2.js"></script> -<script type="text/javascript"> - var obj = ANDLOG_f(); - var answer = JSON.stringify(obj); - console.log(answer); -</script> </head> <body> + <pre> + <code id=jsonPretty> + </code> + </pre> </body> +<script type="text/javascript"> + var obj = ANDLOG_f(); + var element = document.getElementById('jsonPretty'); + element.innerHTML = JSON.stringify(obj, undefined, '\t'); +</script> </html> |