Commit 7de575a8 by Valera Rozuvan Committed by Alexander Kryklia

GST work in progress.

parent ce7a01dd
...@@ -19,22 +19,20 @@ define('Graph', ['logme'], function (logme) { ...@@ -19,22 +19,20 @@ define('Graph', ['logme'], function (logme) {
plotDiv.width(300); plotDiv.width(300);
plotDiv.height(300); plotDiv.height(300);
plotDiv.bind('update_plot', function (event, forGstId) { state.bindUpdatePlotEvent(plotDiv, onUpdatePlot);
if (forGstId !== gstId) {
logme('update_plot event not for current ID');
}
logme('redrawing plot');
generateData();
updatePlot();
});
generateData(); generateData();
updatePlot(); updatePlot();
return; return;
function onUpdatePlot(event) {
logme('redrawing plot');
generateData();
updatePlot();
}
function generateData() { function generateData() {
var a, b, c1; var a, b, c1;
......
...@@ -18,7 +18,7 @@ define('State', ['logme'], function (logme) { ...@@ -18,7 +18,7 @@ define('State', ['logme'], function (logme) {
* *
*/ */
function State(gstId, config) { function State(gstId, config) {
var constants, c1; var constants, c1, plotDiv;
constants = {}; constants = {};
...@@ -62,9 +62,16 @@ define('State', ['logme'], function (logme) { ...@@ -62,9 +62,16 @@ define('State', ['logme'], function (logme) {
// it's private properties. // it's private properties.
return { return {
'getConstValue': getConstValue, 'getConstValue': getConstValue,
'setConstValue': setConstValue 'setConstValue': setConstValue,
'bindUpdatePlotEvent': bindUpdatePlotEvent
}; };
function bindUpdatePlotEvent(newPlotDiv, callback) {
plotDiv = newPlotDiv;
plotDiv.bind('update_plot', callback);
}
function getConstValue(constName) { function getConstValue(constName) {
if (constants.hasOwnProperty(constName) === false) { if (constants.hasOwnProperty(constName) === false) {
// If the name of the constant is not tracked by state, return an // If the name of the constant is not tracked by state, return an
...@@ -76,8 +83,6 @@ define('State', ['logme'], function (logme) { ...@@ -76,8 +83,6 @@ define('State', ['logme'], function (logme) {
} }
function setConstValue(constName, constValue) { function setConstValue(constName, constValue) {
var plotDiv;
if (constants.hasOwnProperty(constName) === false) { if (constants.hasOwnProperty(constName) === false) {
// If the name of the constant is not tracked by state, return an // If the name of the constant is not tracked by state, return an
// 'undefined' value. // 'undefined' value.
...@@ -93,10 +98,8 @@ define('State', ['logme'], function (logme) { ...@@ -93,10 +98,8 @@ define('State', ['logme'], function (logme) {
logme('From setConstValue: new value for "' + constName + '" is ' + constValue); logme('From setConstValue: new value for "' + constName + '" is ' + constValue);
plotDiv = $('#' + gstId + '_plot'); if (plotDiv !== undefined) {
plotDiv.trigger('update_plot');
if (plotDiv.length === 1) {
plotDiv.trigger('update_plot', [gstId]);
} }
} }
......
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