beautified all static js files

This commit is contained in:
Peter 'Pita' Martischka 2011-07-07 18:59:34 +01:00
parent 2fa1d8768b
commit 271ee1776b
36 changed files with 9456 additions and 6035 deletions

View file

@ -1,12 +1,12 @@
/**
* 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.
@ -15,49 +15,61 @@
*/
var padcookie = (function(){
function getRawCookie() {
var padcookie = (function()
{
function getRawCookie()
{
// returns null if can't get cookie text
if (! document.cookie) {
if (!document.cookie)
{
return null;
}
// look for (start of string OR semicolon) followed by whitespace followed by prefs=(something);
var regexResult = document.cookie.match(/(?:^|;)\s*prefs=([^;]*)(?:;|$)/);
if ((! regexResult) || (! regexResult[1])) {
if ((!regexResult) || (!regexResult[1]))
{
return null;
}
return regexResult[1];
}
function setRawCookie(safeText) {
function setRawCookie(safeText)
{
var expiresDate = new Date();
expiresDate.setFullYear(3000);
document.cookie = ('prefs='+safeText+';expires='+expiresDate.toGMTString());
document.cookie = ('prefs=' + safeText + ';expires=' + expiresDate.toGMTString());
}
function parseCookie(text) {
// returns null if can't parse cookie.
try {
function parseCookie(text)
{
// returns null if can't parse cookie.
try
{
var cookieData = JSON.parse(unescape(text));
return cookieData;
}
catch (e) {
catch (e)
{
return null;
}
}
function stringifyCookie(data) {
function stringifyCookie(data)
{
return escape(JSON.stringify(data));
}
function saveCookie() {
if (! inited) {
function saveCookie()
{
if (!inited)
{
return;
}
setRawCookie(stringifyCookie(cookieData));
if (pad.getIsProPad() && (! getRawCookie()) && (! alreadyWarnedAboutNoCookies)) {
alert("Warning: it appears that your browser does not have cookies enabled."+
" EtherPad uses cookies to keep track of unique users for the purpose"+
" of putting a quota on the number of active users. Using EtherPad without "+
" cookies may fill up your server's user quota faster than expected.");
if (pad.getIsProPad() && (!getRawCookie()) && (!alreadyWarnedAboutNoCookies))
{
alert("Warning: it appears that your browser does not have cookies enabled." + " EtherPad uses cookies to keep track of unique users for the purpose" + " of putting a quota on the number of active users. Using EtherPad without " + " cookies may fill up your server's user quota faster than expected.");
alreadyWarnedAboutNoCookies = true;
}
}
@ -68,11 +80,14 @@ var padcookie = (function(){
var inited = false;
var self = {
init: function(prefsToSet) {
init: function(prefsToSet)
{
var rawCookie = getRawCookie();
if (rawCookie) {
if (rawCookie)
{
var cookieObj = parseCookie(rawCookie);
if (cookieObj) {
if (cookieObj)
{
wasNoCookie = false; // there was a cookie
delete cookieObj.userId;
delete cookieObj.name;
@ -81,21 +96,27 @@ var padcookie = (function(){
}
}
for(var k in prefsToSet) {
for (var k in prefsToSet)
{
cookieData[k] = prefsToSet[k];
}
inited = true;
saveCookie();
},
wasNoCookie: function() { return wasNoCookie; },
getPref: function(prefName) {
wasNoCookie: function()
{
return wasNoCookie;
},
getPref: function(prefName)
{
return cookieData[prefName];
},
setPref: function(prefName, value) {
setPref: function(prefName, value)
{
cookieData[prefName] = value;
saveCookie();
}
};
return self;
}());
}());