Created
July 8, 2010 19:44
-
-
Save jeiting/468490 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ========================================================================== | |
// Project: VariableViewer.appController | |
// Copyright: ©2009 My Company, Inc. | |
// ========================================================================== | |
/*globals VariableViewer SharedVariableEngine*/ | |
/** @class | |
(Document Your Controller Here) | |
@extends SC.Object | |
*/ | |
VariableViewer.appController = SC.ArrayController.create( | |
/** @scope VariableViewer.appController.prototype */ | |
{ | |
historyLengthBinding: 'VariableViewer.mainPage.mainPane.middleView.plotControl.minValue.historyLength', | |
historyLength: null, | |
minYBinding: 'VariableViewer.mainPage.mainPane.middleView.plotControl.minY.value', | |
minY: null, | |
maxYBinding: 'VariableViewer.mainPage.mainPane.middleView.plotControl.maxY.value', | |
maxY: null, | |
init: function() { | |
console.log('init app controller'); | |
var newArray = []; | |
// Look for pathed shared variables in url | |
var url = window.location.href; | |
var tokens = url.split('#'); | |
if (tokens.length > 1) { | |
var variableString = tokens[1]; | |
var variableStrings = variableString.split(':'); | |
for (var i = 0; i < variableStrings.length; i++ ) { | |
var sv = VariableViewer.PathedSharedVariable.create({ | |
path: variableStrings[i] | |
}); | |
newArray.pushObject(sv); | |
} | |
} | |
/* | |
this.get('content').forEach(function(item) { | |
var sv = VariableViewer.PathedSharedVariable.create({ | |
path: item | |
}); | |
newArray.pushObject(sv); | |
}); | |
*/ | |
this.set('content', newArray); | |
}, | |
selectionChanged: function() { | |
var selection = this.get('selection'); | |
}.observes('selection'), | |
newSV: function() { | |
var svPath = VariableViewer.mainPage.getPath('mainPane.topView.svPath.value'); | |
if (!svPath) { | |
return; | |
} | |
var newSV = VariableViewer.PathedSharedVariable.create({ | |
path: svPath | |
}); | |
this.addObject(newSV); | |
}, | |
rewriteURL: function () { | |
var url = window.location.href; | |
url = url.split('#')[0] + '#'; | |
var content = this.get('content'); | |
var paths = []; | |
for (var i = content.length - 1; i >= 0; i--){ | |
paths.push(content[i].get('path')); | |
} | |
paths.reverse(); | |
url += paths.join(':'); | |
window.location.href = url; | |
}.observes('content') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment