From 0f7e6feda11a4c4c4ba0b9cca1a6bb895a6d3889 Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Sun, 15 Jan 2012 18:22:28 -0800 Subject: [PATCH] Remove individual settings in `pad2.js` from global. --- static/js/pad2.js | 40 +++++++++++++++++++++------------------- static/js/pad_editor.js | 6 +++--- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/static/js/pad2.js b/static/js/pad2.js index bbb385b3..ca4ef53f 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -23,12 +23,14 @@ /* global $, window */ var socket; -var LineNumbersDisabled = false; -var noColors = false; -var useMonospaceFontGlobal = false; -var globalUserName = false; -var hideQRCode = false; -var rtlIsTrue = false; + +var settings = {}; +settings.LineNumbersDisabled = false; +settings.noColors = false; +settings.useMonospaceFontGlobal = false; +settings.globalUserName = false; +settings.hideQRCode = false; +settings.rtlIsTrue = false; $(document).ready(function() { @@ -101,7 +103,7 @@ function getParams() { if(IsnoColors == "true") { - noColors = true; + settings.noColors = true; $('#clearAuthorship').hide(); } } @@ -124,20 +126,20 @@ function getParams() { if(showLineNumbers == "false") { - LineNumbersDisabled = true; + settings.LineNumbersDisabled = true; } } if(useMonospaceFont) { if(useMonospaceFont == "true") { - useMonospaceFontGlobal = true; + settings.useMonospaceFontGlobal = true; } } if(userName) { // If the username is set as a parameter we should set a global value that we can call once we have initiated the pad. - globalUserName = unescape(userName); + settings.globalUserName = unescape(userName); } if(hideQRCode) { @@ -147,7 +149,7 @@ function getParams() { if(rtl == "true") { - rtlIsTrue = true + settings.rtlIsTrue = true } } } @@ -298,33 +300,33 @@ function handshake() initalized = true; // If the LineNumbersDisabled value is set to true then we need to hide the Line Numbers - if (LineNumbersDisabled == true) + if (settings.LineNumbersDisabled == true) { pad.changeViewOption('showLineNumbers', false); } // If the noColors value is set to true then we need to hide the backround colors on the ace spans - if (noColors == true) + if (settings.noColors == true) { pad.changeViewOption('noColors', true); } - if (rtlIsTrue == true) + if (settings.rtlIsTrue == true) { pad.changeViewOption('rtl', true); } // If the Monospacefont value is set to true then change it to monospace. - if (useMonospaceFontGlobal == true) + if (settings.useMonospaceFontGlobal == true) { pad.changeViewOption('useMonospaceFont', true); } // if the globalUserName value is set we need to tell the server and the client about the new authorname - if (globalUserName !== false) + if (settings.globalUserName !== false) { - pad.notifyChangeName(globalUserName); // Notifies the server - pad.myUserInfo.name = globalUserName; - $('#myusernameedit').attr({"value":globalUserName}); // Updates the current users UI + pad.notifyChangeName(settings.globalUserName); // Notifies the server + pad.myUserInfo.name = settings.globalUserName; + $('#myusernameedit').attr({"value":settings.globalUserName}); // Updates the current users UI } } //This handles every Message after the clientVars diff --git a/static/js/pad_editor.js b/static/js/pad_editor.js index 183de948..6daf5e7d 100644 --- a/static/js/pad_editor.js +++ b/static/js/pad_editor.js @@ -68,7 +68,7 @@ var padeditor = (function() pad.changeViewOption('useMonospaceFont', $("#viewfontmenu").val() == 'monospace'); }); - noColors = !noColors; // Inversed so we can pass it to showauthorcolors + settings.noColors = !settings.noColors; // Inversed so we can pass it to showauthorcolors }, setViewOptions: function(newOptions) { @@ -93,9 +93,9 @@ var padeditor = (function() self.ace.setProperty("textface", (v ? "monospace" : "Arial, sans-serif")); $("#viewfontmenu").val(v ? "monospace" : "normal"); - self.ace.setProperty("showsauthorcolors", noColors); + self.ace.setProperty("showsauthorcolors", settings.noColors); - self.ace.setProperty("rtlIsTrue", rtlIsTrue); + self.ace.setProperty("rtlIsTrue", settings.rtlIsTrue); }, initViewZoom: function() {