Merge pull request #371 from cweider/page-initialization

Page initialization
This commit is contained in:
Peter 'Pita' Martischka 2012-01-30 01:56:02 -08:00
commit 4d714cee94
17 changed files with 300 additions and 237 deletions

View file

@ -306,11 +306,6 @@ function tarCode(filesInOrder, files, write) {
write("\n\n\n/*** File: static/js/" + filename + " ***/\n\n\n"); write("\n\n\n/*** File: static/js/" + filename + " ***/\n\n\n");
write(isolateJS(files[filename], filename)); write(isolateJS(files[filename], filename));
} }
for(var i = 0, ii = filesInOrder.length; i < filesInOrder.length; i++) {
var filename = filesInOrder[i];
write('require(' + JSON.stringify('/' + filename.replace(/^\/+/, '')) + ');\n');
}
} }
// Wrap the following code in a self executing function and assign exports to // Wrap the following code in a self executing function and assign exports to

View file

@ -1,6 +1,7 @@
{ {
"pad.js": [ "pad.js": [
"jquery.js" "jquery.js"
, "pad.js"
, "ace2_common.js" , "ace2_common.js"
, "pad_utils.js" , "pad_utils.js"
, "plugins.js" , "plugins.js"
@ -17,7 +18,6 @@
, "pad_impexp.js" , "pad_impexp.js"
, "pad_savedrevs.js" , "pad_savedrevs.js"
, "pad_connectionstatus.js" , "pad_connectionstatus.js"
, "pad2.js"
, "jquery-ui.js" , "jquery-ui.js"
, "chat.js" , "chat.js"
, "excanvas.js" , "excanvas.js"
@ -46,5 +46,6 @@
, "broadcast.js" , "broadcast.js"
, "broadcast_slider.js" , "broadcast_slider.js"
, "broadcast_revisions.js" , "broadcast_revisions.js"
, "timeslider.js"
] ]
} }

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

@ -24,13 +24,14 @@
var socket; var socket;
var settings = {}; // These jQuery things should create local references, but for now `require()`
settings.LineNumbersDisabled = false; // assigns to the global `$` and augments it with plugins.
settings.noColors = false; require('/jquery');
settings.useMonospaceFontGlobal = false; require('/jquery-ui');
settings.globalUserName = false; require('/farbtastic');
settings.hideQRCode = false; require('/excanvas');
settings.rtlIsTrue = false; require('/json2');
require('/undo-xpopup');
var chat = require('/chat').chat; var chat = require('/chat').chat;
var getCollabClient = require('/collab_client').getCollabClient; var getCollabClient = require('/collab_client').getCollabClient;
@ -45,19 +46,6 @@ var padsavedrevs = require('/pad_savedrevs').padsavedrevs;
var paduserlist = require('/pad_userlist').paduserlist; var paduserlist = require('/pad_userlist').paduserlist;
var padutils = require('/pad_utils').padutils; var padutils = require('/pad_utils').padutils;
$(document).ready(function()
{
//start the costum js
if(typeof costumStart == "function") costumStart();
getParams();
handshake();
});
$(window).unload(function()
{
pad.dispose();
});
function createCookie(name, value, days, path) function createCookie(name, value, days, path)
{ {
if (days) if (days)
@ -309,7 +297,7 @@ function handshake()
clientVars.collab_client_vars.clientAgent = "Anonymous"; clientVars.collab_client_vars.clientAgent = "Anonymous";
//initalize the pad //initalize the pad
pad.init(); pad._afterHandshake();
initalized = true; initalized = true;
// If the LineNumbersDisabled value is set to true then we need to hide the Line Numbers // If the LineNumbersDisabled value is set to true then we need to hide the Line Numbers
@ -421,6 +409,23 @@ var pad = {
}, },
init: function() init: function()
{
padutils.setupGlobalExceptionHandler();
$(document).ready(function()
{
//start the costum js
if(typeof costumStart == "function") costumStart();
getParams();
handshake();
});
$(window).unload(function()
{
pad.dispose();
});
},
_afterHandshake: function()
{ {
pad.clientTimeOffset = new Date().getTime() - clientVars.serverTimestamp; pad.clientTimeOffset = new Date().getTime() - clientVars.serverTimestamp;
@ -446,7 +451,7 @@ var pad = {
} }
// order of inits is important here: // order of inits is important here:
padcookie.init(clientVars.cookiePrefsToSet); padcookie.init(clientVars.cookiePrefsToSet, this);
$("#widthprefcheck").click(pad.toggleWidthPref); $("#widthprefcheck").click(pad.toggleWidthPref);
// $("#sidebarcheck").click(pad.togglewSidebar); // $("#sidebarcheck").click(pad.togglewSidebar);
@ -473,16 +478,16 @@ var pad = {
initialTitle: clientVars.initialTitle, initialTitle: clientVars.initialTitle,
initialPassword: clientVars.initialPassword, initialPassword: clientVars.initialPassword,
guestPolicy: pad.padOptions.guestPolicy guestPolicy: pad.padOptions.guestPolicy
}); }, this);
padimpexp.init(); padimpexp.init(this);
padsavedrevs.init(clientVars.initialRevisionList); padsavedrevs.init(clientVars.initialRevisionList, this);
padeditor.init(postAceInit, pad.padOptions.view || {}); padeditor.init(postAceInit, pad.padOptions.view || {}, this);
paduserlist.init(pad.myUserInfo); paduserlist.init(pad.myUserInfo, this);
// padchat.init(clientVars.chatHistory, pad.myUserInfo); // padchat.init(clientVars.chatHistory, pad.myUserInfo);
padconnectionstatus.init(); padconnectionstatus.init();
padmodals.init(); padmodals.init(this);
pad.collabClient = getCollabClient(padeditor.ace, clientVars.collab_client_vars, pad.myUserInfo, { pad.collabClient = getCollabClient(padeditor.ace, clientVars.collab_client_vars, pad.myUserInfo, {
colorPalette: pad.getColorPalette() colorPalette: pad.getColorPalette()
@ -981,6 +986,21 @@ var alertBar = (function()
return self; return self;
}()); }());
function init() {
return pad.init();
}
var settings = {
LineNumbersDisabled: false
, noColors: false
, useMonospaceFontGlobal: false
, globalUserName: false
, hideQRCode: false
, rtlIsTrue: false
};
pad.settings = settings;
exports.settings = settings; exports.settings = settings;
exports.createCookie = createCookie; exports.createCookie = createCookie;
exports.readCookie = readCookie; exports.readCookie = readCookie;
@ -990,4 +1010,5 @@ exports.getUrlVars = getUrlVars;
exports.savePassword = savePassword; exports.savePassword = savePassword;
exports.handshake = handshake; exports.handshake = handshake;
exports.pad = pad; exports.pad = pad;
exports.init = init;
exports.alertBar = alertBar; exports.alertBar = alertBar;

View file

@ -87,9 +87,9 @@ var padcookie = (function()
var pad = undefined; var pad = undefined;
var self = { var self = {
init: function(prefsToSet) init: function(prefsToSet, _pad)
{ {
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected). pad = _pad;
var rawCookie = getRawCookie(); var rawCookie = getRawCookie();
if (rawCookie) if (rawCookie)

View file

@ -118,9 +118,9 @@ var paddocbar = (function()
var self = { var self = {
title: null, title: null,
password: null, password: null,
init: function(opts) init: function(opts, _pad)
{ {
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected). pad = _pad;
panels = { panels = {
impexp: { impexp: {

View file

@ -32,11 +32,11 @@ var padeditor = (function()
ace: null, ace: null,
// this is accessed directly from other files // this is accessed directly from other files
viewZoom: 100, viewZoom: 100,
init: function(readyFunc, initialViewOptions) init: function(readyFunc, initialViewOptions, _pad)
{ {
Ace2Editor = require('/ace').Ace2Editor; Ace2Editor = require('/ace').Ace2Editor;
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected). pad = _pad;
settings = require('/pad2').settings; settings = pad.settings;
function aceReady() function aceReady()
{ {

View file

@ -236,13 +236,9 @@ var padimpexp = (function()
///// /////
var pad = undefined; var pad = undefined;
var self = { var self = {
init: function() init: function(_pad)
{ {
try { pad = _pad;
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected).
} catch (e) {
// skip (doesn't require pad when required by timeslider)
}
//get /p/padname //get /p/padname
var pad_root_path = new RegExp(/.*\/p\/[^\/]+/).exec(document.location.pathname) var pad_root_path = new RegExp(/.*\/p\/[^\/]+/).exec(document.location.pathname)

View file

@ -75,9 +75,9 @@ var padmodals = (function()
var pad = undefined; var pad = undefined;
var self = { var self = {
init: function() init: function(_pad)
{ {
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected). pad = _pad;
self.initFeedback(); self.initFeedback();
self.initShareBox(); self.initShareBox();

View file

@ -349,9 +349,9 @@ var padsavedrevs = (function()
var pad = undefined; var pad = undefined;
var self = { var self = {
init: function(initialRevisions) init: function(initialRevisions, _pad)
{ {
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected). pad = _pad;
self.newRevisionList(initialRevisions, true); self.newRevisionList(initialRevisions, true);
$("#savedrevs-savenow").click(function() $("#savedrevs-savenow").click(function()

View file

@ -464,9 +464,9 @@ var paduserlist = (function()
var pad = undefined; var pad = undefined;
var self = { var self = {
init: function(myInitialUserInfo) init: function(myInitialUserInfo, _pad)
{ {
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected). pad = _pad;
self.setMyUserInfo(myInitialUserInfo); self.setMyUserInfo(myInitialUserInfo);

View file

@ -34,7 +34,7 @@ var padutils = {
}, },
uniqueId: function() uniqueId: function()
{ {
var pad = require('/pad2').pad; // Sidestep circular dependency var pad = require('/pad').pad; // Sidestep circular dependency
function encodeNum(n, width) function encodeNum(n, width)
{ {
// returns string that is exactly 'width' chars, padding with zeros // returns string that is exactly 'width' chars, padding with zeros
@ -209,7 +209,7 @@ var padutils = {
}, },
timediff: function(d) timediff: function(d)
{ {
var pad = require('/pad2').pad; // Sidestep circular dependency var pad = require('/pad').pad; // Sidestep circular dependency
function format(n, word) function format(n, word)
{ {
n = Math.round(n); n = Math.round(n);
@ -459,17 +459,25 @@ var padutils = {
} }
}; };
//send javascript errors to the server var globalExceptionHandler = undefined;
window.onerror = function test (msg, url, linenumber) function setupGlobalExceptionHandler() {
{ //send javascript errors to the server
var errObj = {errorInfo: JSON.stringify({msg: msg, url: url, linenumber: linenumber, userAgent: navigator.userAgent})}; if (!globalExceptionHandler) {
var loc = document.location; globalExceptionHandler = function test (msg, url, linenumber)
var url = loc.protocol + "//" + loc.hostname + ":" + loc.port + "/" + loc.pathname.substr(1, loc.pathname.indexOf("/p/")) + "jserror"; {
var errObj = {errorInfo: JSON.stringify({msg: msg, url: url, linenumber: linenumber, userAgent: navigator.userAgent})};
var loc = document.location;
var url = loc.protocol + "//" + loc.hostname + ":" + loc.port + "/" + loc.pathname.substr(1, loc.pathname.indexOf("/p/")) + "jserror";
$.post(url, errObj); $.post(url, errObj);
return false; return false;
}; };
window.onerror = globalExceptionHandler;
}
}
padutils.setupGlobalExceptionHandler = setupGlobalExceptionHandler;
padutils.binarySearch = require('/ace2_common').binarySearch; padutils.binarySearch = require('/ace2_common').binarySearch;

184
static/js/timeslider.js Normal file
View file

@ -0,0 +1,184 @@
/**
* This code is mostly from the old Etherpad. Please help us to comment this code.
* This helps other people to understand this code better and helps them to improve it.
* TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED
*/
/**
* Copyright 2009 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// These jQuery things should create local references, but for now `require()`
// assigns to the global `$` and augments it with plugins.
require('/jquery');
require('/json2');
require('/undo-xpopup');
function createCookie(name,value,days)
{
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function randomString() {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var string_length = 20;
var randomstring = '';
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum,rnum+1);
}
return "t." + randomstring;
}
var socket, token, padId, export_links;
function init() {
$(document).ready(function ()
{
//start the costum js
if(typeof costumStart == "function") costumStart();
//get the padId out of the url
var urlParts= document.location.pathname.split("/");
padId = decodeURIComponent(urlParts[urlParts.length-2]);
//set the title
document.title = document.title + " | " + padId.replace(/_+/g, ' ');
//ensure we have a token
token = readCookie("token");
if(token == null)
{
token = randomString();
createCookie("token", token, 60);
}
var loc = document.location;
//get the correct port
var port = loc.port == "" ? (loc.protocol == "https:" ? 443 : 80) : loc.port;
//create the url
var url = loc.protocol + "//" + loc.hostname + ":" + port + "/";
//find out in which subfolder we are
var resource = loc.pathname.substr(1,loc.pathname.indexOf("/p/")) + "socket.io";
//build up the socket io connection
socket = io.connect(url, {resource: resource});
//send the ready message once we're connected
socket.on('connect', function()
{
sendSocketMsg("CLIENT_READY", {});
});
//route the incoming messages
socket.on('message', function(message)
{
if(window.console) console.log(message);
if(message.type == "CLIENT_VARS")
{
handleClientVars(message);
}
else if(message.type == "CHANGESET_REQ")
{
changesetLoader.handleSocketResponse(message);
}
else if(message.accessStatus)
{
$("body").html("<h2>You have no permission to access this pad</h2>")
}
});
//get all the export links
export_links = $('#export > .exportlink')
if(document.referrer.length > 0 && document.referrer.substring(document.referrer.lastIndexOf("/")-1,document.referrer.lastIndexOf("/")) === "p") {
$("#returnbutton").attr("href", document.referrer);
} else {
$("#returnbutton").attr("href", document.location.href.substring(0,document.location.href.lastIndexOf("/")));
}
});
}
//sends a message over the socket
function sendSocketMsg(type, data)
{
var sessionID = readCookie("sessionID");
var password = readCookie("password");
var msg = { "component" : "timeslider",
"type": type,
"data": data,
"padId": padId,
"token": token,
"sessionID": sessionID,
"password": password,
"protocolVersion": 2};
socket.json.send(msg);
}
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
BroadcastSlider = require('/broadcast_slider').loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded);
require('/broadcast_revisions').loadBroadcastRevisionsJS();
changesetLoader = require('/broadcast').loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, BroadcastSlider);
//initialize export ui
require('/pad_impexp').padimpexp.init();
//change export urls when the slider moves
var export_rev_regex = /(\/\d+)?\/export/
BroadcastSlider.onSlider(function(revno)
{
export_links.each(function()
{
this.setAttribute('href', this.href.replace(export_rev_regex, '/' + revno + '/export'));
});
});
//fire all start functions of these scripts, formerly fired with window.load
for(var i=0;i < fireWhenAllScriptsAreLoaded.length;i++)
{
fireWhenAllScriptsAreLoaded[i]();
}
}
exports.init = init;

View file

@ -298,10 +298,14 @@
<script> <script>
/* TODO: These globals shouldn't exist. */ /* TODO: These globals shouldn't exist. */
pad = require('/pad2').pad; pad = require('/pad').pad;
chat = require('/chat').chat; chat = require('/chat').chat;
padeditbar = require('/pad_editbar').padeditbar; padeditbar = require('/pad_editbar').padeditbar;
padimpexp = require('/pad_impexp').padimpexp; padimpexp = require('/pad_impexp').padimpexp;
(function () {
require('/pad').init();
}());
</script> </script>
</html> </html>

View file

@ -15,163 +15,6 @@
<link href="../../static/custom/timeslider.css" rel="stylesheet"> <link href="../../static/custom/timeslider.css" rel="stylesheet">
<script src="../../static/custom/timeslider.js"></script> <script src="../../static/custom/timeslider.js"></script>
<script>
// <![CDATA[
var clientVars = {};
/* TODO: These globals shouldn't exist. */
padeditbar = require('/pad_editbar').padeditbar;
padimpexp = require('/pad_impexp').padimpexp;
function createCookie(name,value,days)
{
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function randomString() {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var string_length = 20;
var randomstring = '';
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum,rnum+1);
}
return "t." + randomstring;
}
var socket, token, padId, export_links;
$(document).ready(function ()
{
//start the costum js
if(typeof costumStart == "function") costumStart();
//get the padId out of the url
var urlParts= document.location.pathname.split("/");
padId = decodeURIComponent(urlParts[urlParts.length-2]);
//set the title
document.title = document.title + " | " + padId.replace(/_+/g, ' ');
//ensure we have a token
token = readCookie("token");
if(token == null)
{
token = randomString();
createCookie("token", token, 60);
}
var loc = document.location;
//get the correct port
var port = loc.port == "" ? (loc.protocol == "https:" ? 443 : 80) : loc.port;
//create the url
var url = loc.protocol + "//" + loc.hostname + ":" + port + "/";
//find out in which subfolder we are
var resource = loc.pathname.substr(1,loc.pathname.indexOf("/p/")) + "socket.io";
//build up the socket io connection
socket = io.connect(url, {resource: resource});
//send the ready message once we're connected
socket.on('connect', function()
{
sendSocketMsg("CLIENT_READY", {});
});
//route the incoming messages
socket.on('message', function(message)
{
if(window.console) console.log(message);
if(message.type == "CLIENT_VARS")
{
handleClientVars(message);
}
else if(message.type == "CHANGESET_REQ")
{
changesetLoader.handleSocketResponse(message);
}
else if(message.accessStatus)
{
$("body").html("<h2>You have no permission to access this pad</h2>")
}
});
//get all the export links
export_links = $('#export > .exportlink')
});
//sends a message over the socket
function sendSocketMsg(type, data)
{
var sessionID = readCookie("sessionID");
var password = readCookie("password");
var msg = { "component" : "timeslider",
"type": type,
"data": data,
"padId": padId,
"token": token,
"sessionID": sessionID,
"password": password,
"protocolVersion": 2};
socket.json.send(msg);
}
var fireWhenAllScriptsAreLoaded = [];
function handleClientVars(message)
{
//save the client Vars
clientVars = message.data;
//load all script that doesn't work without the clientVars
require('/broadcast_slider').loadBroadcastSliderJS();
require('/broadcast_revisions').loadBroadcastRevisionsJS();
require('/broadcast').loadBroadcastJS();
//initialize export ui
padimpexp.init();
//change export urls when the slider moves
var export_rev_regex = /(\/\d+)?\/export/
BroadcastSlider.onSlider(function(revno)
{
export_links.each(function()
{
this.setAttribute('href', this.href.replace(export_rev_regex, '/' + revno + '/export'));
});
});
//fire all start functions of these scripts, formerly fired with window.load
for(var i=0;i < fireWhenAllScriptsAreLoaded.length;i++)
{
fireWhenAllScriptsAreLoaded[i]();
}
}
// ]]>
</script>
</head> </head>
<body id="padbody" class="timeslider limwidth nonpropad nonprouser"> <body id="padbody" class="timeslider limwidth nonpropad nonprouser">
@ -298,13 +141,6 @@
</li> </li>
</ul> </ul>
<a id = "returnbutton">Return to pad</a> <a id = "returnbutton">Return to pad</a>
<script>
if(document.referrer.length > 0 && document.referrer.substring(document.referrer.lastIndexOf("/")-1,document.referrer.lastIndexOf("/")) === "p") {
$("#returnbutton").attr("href", document.referrer);
} else {
$("#returnbutton").attr("href", document.location.href.substring(0,document.location.href.lastIndexOf("/")));
}
</script>
</div> </div>
<div id="editbarinner" class="editbarinner"> <div id="editbarinner" class="editbarinner">
@ -366,6 +202,18 @@
</form> </form>
</div> </div>
</div> </div>
<script>
var clientVars = {};
/* TODO: These globals shouldn't exist. */
padeditbar = require('/pad_editbar').padeditbar;
padimpexp = require('/pad_impexp').padimpexp;
(function () {
var TimeSlider = require('/timeslider').init();
})();
</script>
</body> </body>
</html> </html>