Remove all global dependencies from broadcast modules.

This commit is contained in:
Chad Weider 2012-01-26 21:20:26 -08:00
parent cd86ef5600
commit d934fd6107
4 changed files with 17 additions and 10 deletions

View File

@ -20,16 +20,17 @@
* limitations under the License. * limitations under the License.
*/ */
var global = this;
var makeCSSManager = require('/cssmanager_client').makeCSSManager; var makeCSSManager = require('/cssmanager_client').makeCSSManager;
var domline = require('/domline_client').domline; var domline = require('/domline_client').domline;
var Changeset = require('/easysync2_client').Changeset; var Changeset = require('/easysync2_client').Changeset;
var AttribPool = require('/easysync2_client').AttribPool; var AttribPool = require('/easysync2_client').AttribPool;
var linestylefilter = require('/linestylefilter_client').linestylefilter; 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.) // 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 // 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) if (!Array.prototype.map)
@ -423,7 +424,7 @@ function loadBroadcastJS()
})); }));
} }
global.changesetLoader = { changesetLoader = {
running: false, running: false,
resolved: [], resolved: [],
requestQueue1: [], requestQueue1: [],
@ -763,6 +764,8 @@ function loadBroadcastJS()
} }
receiveAuthorData(clientVars.historicalAuthorData); receiveAuthorData(clientVars.historicalAuthorData);
return changesetLoader;
} }
exports.loadBroadcastJS = loadBroadcastJS; exports.loadBroadcastJS = loadBroadcastJS;

View File

@ -22,7 +22,6 @@
// revision info is a skip list whos entries represent a particular revision // revision info is a skip list whos entries represent a particular revision
// of the document. These revisions are connected together by various // of the document. These revisions are connected together by various
// changesets, or deltas, between any two revisions. // changesets, or deltas, between any two revisions.
var global = this;
function loadBroadcastRevisionsJS() function loadBroadcastRevisionsJS()
{ {

View File

@ -19,10 +19,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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() (function()
{ // wrap this code in its own namespace { // wrap this code in its own namespace
@ -203,7 +205,7 @@ function loadBroadcastSliderJS()
} }
} }
global.BroadcastSlider = { BroadcastSlider = {
onSlider: onSlider, onSlider: onSlider,
getSliderPosition: getSliderPosition, getSliderPosition: getSliderPosition,
setSliderPosition: setSliderPosition, setSliderPosition: setSliderPosition,
@ -495,6 +497,8 @@ function loadBroadcastSliderJS()
{ {
$("#viewlatest").html(loc == BroadcastSlider.getSliderLength() ? "Viewing latest content" : "View latest content"); $("#viewlatest").html(loc == BroadcastSlider.getSliderLength() ? "Viewing latest content" : "View latest content");
}) })
return BroadcastSlider;
} }
exports.loadBroadcastSliderJS = loadBroadcastSliderJS; exports.loadBroadcastSliderJS = loadBroadcastSliderJS;

View File

@ -140,15 +140,16 @@
var fireWhenAllScriptsAreLoaded = []; var fireWhenAllScriptsAreLoaded = [];
var BroadcastSlider, changesetLoader;
function handleClientVars(message) function handleClientVars(message)
{ {
//save the client Vars //save the client Vars
clientVars = message.data; clientVars = message.data;
//load all script that doesn't work without the clientVars //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_revisions').loadBroadcastRevisionsJS();
require('/broadcast').loadBroadcastJS(); changesetLoader = require('/broadcast').loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, BroadcastSlider);
//initialize export ui //initialize export ui
padimpexp.init(); padimpexp.init();