summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data_structures_correct/DOLLAR.js27
-rw-r--r--data_structures_correct/DOLLAR_f.js27
-rw-r--r--data_structures_correct/DOLLAR_m.js27
-rw-r--r--data_structures_correct/Diode.js36
-rw-r--r--data_structures_correct/EVTGEN_f.js22
-rw-r--r--dependencies.js43
-rw-r--r--filenames.php27
-rw-r--r--index.html58
8 files changed, 223 insertions, 44 deletions
diff --git a/data_structures_correct/DOLLAR.js b/data_structures_correct/DOLLAR.js
new file mode 100644
index 0000000..5e6dffb
--- /dev/null
+++ b/data_structures_correct/DOLLAR.js
@@ -0,0 +1,27 @@
+function DOLLAR() {
+
+ DOLLAR.prototype.define = function DOLLAR() {
+ this.z = 0;
+ this.inh = 0;
+ this.in1 = 1;
+
+ var model = scicos_model();
+ model.sim = list(new ScilabString(["dollar4"]), new ScilabDouble([4]));
+ model.in = new ScilabDouble([this.in1]);
+ model.out = new ScilabDouble([this.in1]);
+ model.evtin = new ScilabDouble([1 - this.inh]);
+ model.dstate = new ScilabDouble([this.z]);
+ model.blocktype = new ScilabString(["d"]);
+ model.dep_ut = new ScilabBoolean([false, false]);
+
+ var exprs = new ScilabString([this.z], [this.inh]);
+
+ var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DOLLAR\",sz(1),sz(2));"]);
+ this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i);
+ return new BasicBlock(this.x);
+ }
+ DOLLAR.prototype.details = function DOLLAR() {
+ return this.x;
+ }
+}
+
diff --git a/data_structures_correct/DOLLAR_f.js b/data_structures_correct/DOLLAR_f.js
new file mode 100644
index 0000000..d4625b7
--- /dev/null
+++ b/data_structures_correct/DOLLAR_f.js
@@ -0,0 +1,27 @@
+function DOLLAR_f() {
+
+ DOLLAR_f.prototype.define = function DOLLAR_f() {
+ this.z = 0;
+ this.inh = 0;
+ this.in1 = 1;
+
+ var model = scicos_model();
+ model.sim = new ScilabString(["dollar"]);
+ model.in = new ScilabDouble([this.in1]);
+ model.out = new ScilabDouble([this.in1]);
+ model.evtin = new ScilabDouble([1 - this.inh]);
+ model.dstate = new ScilabDouble([this.z]);
+ model.blocktype = new ScilabString(["d"]);
+ model.dep_ut = new ScilabBoolean([false, false]);
+
+ var exprs = new ScilabString([this.z], [this.inh]);
+
+ var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DOLLAR_f\",sz(1),sz(2));"]);
+ this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i);
+ return new BasicBlock(this.x);
+ }
+ DOLLAR_f.prototype.details = function DOLLAR_f() {
+ return this.x;
+ }
+}
+
diff --git a/data_structures_correct/DOLLAR_m.js b/data_structures_correct/DOLLAR_m.js
new file mode 100644
index 0000000..d39a88f
--- /dev/null
+++ b/data_structures_correct/DOLLAR_m.js
@@ -0,0 +1,27 @@
+function DOLLAR_m() {
+
+ DOLLAR_m.prototype.define = function DOLLAR_m() {
+ this.z = 0;
+ this.inh = 0;
+ this.in1 = 1;
+
+ var model = scicos_model();
+ model.sim = list(new ScilabString(["dollar4"]), new ScilabDouble([4]));
+ model.in = new ScilabDouble([this.in1]);
+ model.out = new ScilabDouble([this.in1]);
+ model.evtin = new ScilabDouble([1 - this.inh]);
+ model.dstate = new ScilabDouble([this.z]);
+ model.blocktype = new ScilabString(["d"]);
+ model.dep_ut = new ScilabBoolean([false, false]);
+
+ var exprs = new ScilabString([this.z], [this.inh]);
+
+ var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"DOLLAR_m\",sz(1),sz(2));"]);
+ this.x = new standard_define(new ScilabDouble([2, 2]), model, exprs, gr_i);
+ return new BasicBlock(this.x);
+ }
+ DOLLAR_m.prototype.details = function DOLLAR_m() {
+ return this.x;
+ }
+}
+
diff --git a/data_structures_correct/Diode.js b/data_structures_correct/Diode.js
new file mode 100644
index 0000000..aab1eaf
--- /dev/null
+++ b/data_structures_correct/Diode.js
@@ -0,0 +1,36 @@
+function Diode() {
+
+ Diode.prototype.define = function Diode() {
+
+ this.Ids = 1.e-6;
+ this.Vt = 0.04;
+ this.Maxexp = 15;
+ this.R = 1.e8;
+
+ var model = scicos_model();
+ model.rpar = new ScilabDouble([this.Ids], [this.Vt], [this.Maxexp], [this.R]);
+ model.in = new ScilabDouble([1]);
+ model.out = new ScilabDouble([1]);
+ model.sim = new ScilabString(["Diode"]);
+ model.blocktype = new ScilabString(["c"]);
+ model.dep_ut = new ScilabBoolean([true, false]);
+
+ var mo = modelica();
+ mo.model = new ScilabString(["Diode"]);
+ mo.inputs = new ScilabString(["p"]);
+ mo.outputs = new ScilabString(["n"]);
+ mo.parameters = list(new ScilabString(["Ids", "Vt", "Maxexp", "R"]), list(new ScilabDouble([this.Ids]), new ScilabDouble([this.Vt]), new ScilabDouble([this.Maxexp]), new ScilabDouble([this.R])));
+ model.equations = mo;
+
+ var exprs = new ScilabString([this.Ids], [this.Vt], [this.Maxexp], [this.R]);
+
+ var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"Diode\",sz(1),sz(2));"]);
+ this.x = standard_define(new ScilabDouble([2, 1]), model, exprs, list(gr_i, 0));
+ this.x.graphics.in_implicit = new ScilabString(["I"]);
+ this.x.graphics.out_implicit = new ScilabString(["I"]);
+ return new BasicBlock(this.x);
+ }
+ Diode.prototype.details = function Diode() {
+ return this.x;
+ }
+}
diff --git a/data_structures_correct/EVTGEN_f.js b/data_structures_correct/EVTGEN_f.js
new file mode 100644
index 0000000..ba7197f
--- /dev/null
+++ b/data_structures_correct/EVTGEN_f.js
@@ -0,0 +1,22 @@
+function EVTGEN_f() {
+
+ EVTGEN_f.prototype.define = function EVTGEN_f() {
+ this.tt = 0;
+
+ var model = scicos_model();
+ model.sim = new ScilabString(["trash"]);
+ model.evtout = new ScilabDouble([1]);
+ model.blocktype = new ScilabString(["d"]);
+ model.firing = new ScilabDouble([this.tt]);
+ model.dep_ut = new ScilabBoolean([false, false]);
+
+ var exprs = new ScilabString([this.tt]);
+
+ var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"EVTGEN_f\",sz(1),sz(2));"]);
+ this.x = new standard_define(new ScilabDouble([3, 2]), model, exprs, gr_i);
+ return new BasicBlock(this.x);
+ }
+ EVTGEN_f.prototype.details = function EVTGEN_f() {
+ return this.x;
+ }
+}
diff --git a/dependencies.js b/dependencies.js
index 17c2184..5edd328 100644
--- a/dependencies.js
+++ b/dependencies.js
@@ -1,23 +1,28 @@
-var dir = ["data_structures_correct"];
-var fileextension = ".";
+$.getScript('math.js');
-var script = document.createElement("script");
- script.src = "math.js";
- document.head.appendChild(script);
-$.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);
- var script = document.createElement("script");
- script.src = filename;
- document.head.appendChild(script);
- });
- }
- });
+$.ajax({
+ type: "POST",
+
+ // Invoke filenames.php
+ url: "filenames.php",
+
+ // Receive the resultant filenames from the php script in JSON format
+ dataType: "json",
+
+ // Add url for the required folder
+ data: {
+ url: "/data_structures_correct/"
+ },
+ success: function (data) {
+
+ /*
+ * @Parameter: data will have the required filenames in the mentioned folder
+ * For each url, add the script to the body div element with getScript function
+ */
+ for (i in data) {
+ $.getScript(data[i]);
+ }
+ }
});
function AfficheBlock() {
diff --git a/filenames.php b/filenames.php
new file mode 100644
index 0000000..81ca89f
--- /dev/null
+++ b/filenames.php
@@ -0,0 +1,27 @@
+<?php
+
+/*
+ * @jiteshjha
+ * filenames.php returns the names of all the files in a given folder
+ */
+
+// Store the filenames
+$filenameArray = [];
+
+// Get the folder to be operated
+$url = $_POST['url'];
+
+// Reference: http://php.net/manual/en/function.opendir.php
+// Open the file directory and get the filehandle
+$handle = opendir(dirname(realpath(__FILE__)).$url);
+
+// For each file in the folder, push the filename to filenameArray
+while($file = readdir($handle)){
+ if($file !== '.' && $file !== '..'){
+ array_push($filenameArray, "$url$file");
+ }
+}
+
+// Return the file name array in JSON format
+echo json_encode($filenameArray);
+?>
diff --git a/index.html b/index.html
index ab55f38..9b464e8 100644
--- a/index.html
+++ b/index.html
@@ -412,13 +412,13 @@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// https://jgraph.github.io/mxgraph/docs/js-api/files/model/mxCell-js.html
// Uncomment this block to see XML tags work
- /*graph.convertValueToString = function(cell)
+ graph.convertValueToString = function(cell)
{
if (mxUtils.isNode(cell.value))
{
return cell.getAttribute('label', '');
}
- };*/
+ };
var cellLabelChanged = graph.cellLabelChanged;
graph.cellLabelChanged = function(cell, newValue, autoSize) {
@@ -2142,32 +2142,40 @@
</body>
<!-- It's good if this part happens after the entire page has loaded-->
<script type="text/javascript">
+
// Preload all images
- var dir = ["blocks", "images"];
- 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];
- }
+ var directory = ["/blocks/", "/images/", "/palettes/"];
+ for(folder in directory) {
+ $.ajax({
+ type: "POST",
+
+ // Invoke filenames.php
+ url: "filenames.php",
+
+ // Receive the resultant filenames from the php script in JSON format
+ dataType: "json",
+
+ // Add url for the required folder
+ data: {
+ url: directory[folder]
+ },
+ success: function (data) {
+ function preload(sources) {
+
+ /*
+ * @Parameter: sources will have the required filenames in the mentioned folder
+ * For each image url, make a new image to enable preloading
+ */
+ for (i in sources) {
+ var image = new Image();
+ image.src = sources[i];
}
- preload(blockImages);
}
- });
- });
+ preload(data);
+ }
+ });
+ }
+
//Find out more here: http://stackoverflow.com/questions/12843418/jquery-ui-accordion-expand-collapse-all
$(window).load(function() {
var headers = $('#sidebarContainer .accordion-header');