Commit 7de575a8 by Valera Rozuvan Committed by Alexander Kryklia

GST work in progress.

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