Merge branch 'master' of /home/jose/etherpad-lite/

pull/85/merge
Peter 'Pita' Martischka 2011-08-13 19:05:20 +01:00
commit fd4bdeccb3
1 changed files with 60 additions and 18 deletions

View File

@ -17,21 +17,13 @@
/* global $, window */ /* global $, window */
var socket; var socket;
var LineNumbersDisabled = false;
$(document).ready(function() $(document).ready(function()
{ {
//test if the url is proper, means without any ? or # that doesn't belong to a url
//if it isn't proper, clean the url a do a redirect
var padId = document.location.pathname.substring(document.location.pathname.lastIndexOf("/") + 1);
var expectedURL = document.location.href.substring(0,document.location.href.lastIndexOf("/") ) + "/" + padId;
if(expectedURL != document.location.href)
{
document.location = expectedURL;
}
//start the costum js //start the costum js
if(typeof costumStart == "function") costumStart(); if(typeof costumStart == "function") costumStart();
getParams();
handshake(); handshake();
}); });
@ -78,6 +70,52 @@ function randomString()
return "t." + randomstring; return "t." + randomstring;
} }
function getParams()
{
var showControls = getUrlVars()["showControls"];
var showChat = getUrlVars()["showChat"];
var userName = getUrlVars()["userName"];
var showLineNumbers = getUrlVars()["showLineNumbers"];
if(showControls)
{
if(showControls == "false")
{
$('#editbar').hide();
$('#editorcontainer').css({"top":"0px"});
}
}
if(showChat)
{
if(showChat == "false")
{
$('#chaticon').hide();
}
}
if(showLineNumbers)
{
if(showLineNumbers == "false")
{
// pad.changeViewOption('showLineNumbers', false);
LineNumbersDisabled = true;
}
}
}
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
function handshake() function handshake()
{ {
var loc = document.location; var loc = document.location;
@ -95,7 +133,6 @@ function handshake()
socket.once('connect', function() socket.once('connect', function()
{ {
var padId = document.location.pathname.substring(document.location.pathname.lastIndexOf("/") + 1); var padId = document.location.pathname.substring(document.location.pathname.lastIndexOf("/") + 1);
document.title = document.title + " | " + padId; document.title = document.title + " | " + padId;
var token = readCookie("token"); var token = readCookie("token");
@ -112,7 +149,6 @@ function handshake()
"token": token, "token": token,
"protocolVersion": 2 "protocolVersion": 2
}; };
socket.json.send(msg); socket.json.send(msg);
}); });
@ -133,8 +169,11 @@ function handshake()
clientVars.collab_client_vars.clientAgent = "Anonymous"; clientVars.collab_client_vars.clientAgent = "Anonymous";
pad.init(); pad.init();
initalized = true; initalized = true;
if (LineNumbersDisabled == true)
{
pad.changeViewOption('showLineNumbers', false); $
}
} }
//This handles every Message after the clientVars //This handles every Message after the clientVars
else else
@ -348,12 +387,15 @@ var pad = {
}; };
options.view[key] = value; options.view[key] = value;
pad.handleOptionsChange(options); pad.handleOptionsChange(options);
pad.collabClient.sendClientMessage( if (key != "showLineNumbers")
{ {
type: 'padoptions', pad.collabClient.sendClientMessage(
options: options, {
changedBy: pad.myUserInfo.name || "unnamed" type: 'padoptions',
}); options: options,
changedBy: pad.myUserInfo.name || "unnamed"
});
}
}, },
handleOptionsChange: function(opts) handleOptionsChange: function(opts)
{ {