diff --git a/static/js/broadcast.js b/static/js/broadcast.js index b49b185a..2aa0b5d0 100644 --- a/static/js/broadcast.js +++ b/static/js/broadcast.js @@ -20,16 +20,17 @@ * limitations under the License. */ -var global = this; - var makeCSSManager = require('/cssmanager_client').makeCSSManager; var domline = require('/domline_client').domline; var Changeset = require('/easysync2_client').Changeset; var AttribPool = require('/easysync2_client').AttribPool; var linestylefilter = require('/linestylefilter_client').linestylefilter; -function loadBroadcastJS() +// These parameters were global, now they are injected. A reference to the +// Timeslider controller would probably be more appropriate. +function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, BroadcastSlider) { + var changesetLoader = undefined; // just in case... (todo: this must be somewhere else in the client code.) // Below Array#map code was direct pasted by AppJet/Etherpad, licence unknown. Possible source: http://www.tutorialspoint.com/javascript/array_map.htm if (!Array.prototype.map) @@ -423,7 +424,7 @@ function loadBroadcastJS() })); } - global.changesetLoader = { + changesetLoader = { running: false, resolved: [], requestQueue1: [], @@ -763,6 +764,8 @@ function loadBroadcastJS() } receiveAuthorData(clientVars.historicalAuthorData); + + return changesetLoader; } exports.loadBroadcastJS = loadBroadcastJS; diff --git a/static/js/broadcast_revisions.js b/static/js/broadcast_revisions.js index 364ac3e8..19f3f5ff 100644 --- a/static/js/broadcast_revisions.js +++ b/static/js/broadcast_revisions.js @@ -22,7 +22,6 @@ // revision info is a skip list whos entries represent a particular revision // of the document. These revisions are connected together by various // changesets, or deltas, between any two revisions. -var global = this; function loadBroadcastRevisionsJS() { diff --git a/static/js/broadcast_slider.js b/static/js/broadcast_slider.js index 972190ac..0bdc2cab 100644 --- a/static/js/broadcast_slider.js +++ b/static/js/broadcast_slider.js @@ -19,10 +19,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -var global = this; -function loadBroadcastSliderJS() + // These parameters were global, now they are injected. A reference to the + // Timeslider controller would probably be more appropriate. +function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded) { + var BroadcastSlider; (function() { // wrap this code in its own namespace @@ -203,7 +205,7 @@ function loadBroadcastSliderJS() } } - global.BroadcastSlider = { + BroadcastSlider = { onSlider: onSlider, getSliderPosition: getSliderPosition, setSliderPosition: setSliderPosition, @@ -495,6 +497,8 @@ function loadBroadcastSliderJS() { $("#viewlatest").html(loc == BroadcastSlider.getSliderLength() ? "Viewing latest content" : "View latest content"); }) + + return BroadcastSlider; } exports.loadBroadcastSliderJS = loadBroadcastSliderJS; diff --git a/static/timeslider.html b/static/timeslider.html index 4e85047e..8b66729d 100644 --- a/static/timeslider.html +++ b/static/timeslider.html @@ -140,15 +140,16 @@ var fireWhenAllScriptsAreLoaded = []; + var BroadcastSlider, changesetLoader; function handleClientVars(message) { //save the client Vars clientVars = message.data; //load all script that doesn't work without the clientVars - require('/broadcast_slider').loadBroadcastSliderJS(); + BroadcastSlider = require('/broadcast_slider').loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded); require('/broadcast_revisions').loadBroadcastRevisionsJS(); - require('/broadcast').loadBroadcastJS(); + changesetLoader = require('/broadcast').loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, BroadcastSlider); //initialize export ui padimpexp.init();