From 6451c1bd0654ed885d788094c68582b2d72071fc Mon Sep 17 00:00:00 2001 From: Darren Date: Wed, 22 May 2013 19:54:31 +0100 Subject: [PATCH] Client: Removing obsolete code --- client/assets/src/applets/nickserv.js | 38 ---- client/assets/src/build.js | 1 - client/assets/src/index.html.tmpl | 1 - client/assets/src/utils.js | 276 +------------------------- 4 files changed, 1 insertion(+), 315 deletions(-) delete mode 100644 client/assets/src/applets/nickserv.js diff --git a/client/assets/src/applets/nickserv.js b/client/assets/src/applets/nickserv.js deleted file mode 100644 index fea82c4..0000000 --- a/client/assets/src/applets/nickserv.js +++ /dev/null @@ -1,38 +0,0 @@ -(function () { - var View = Backbone.View.extend({ - events: { - 'click .save': 'saveSettings' - }, - - initialize: function (options) { - this.$el = $($('#tmpl_applet_settings').html()); - }, - - saveSettings: function () { - var theme = $('.theme', this.$el).val(), - containers = $('#kiwi .panels > .panel_container'); - - // Clear any current theme - containers.removeClass(function (i, css) { - return (css.match (/\btheme_\S+/g) || []).join(' '); - }); - - if (theme) containers.addClass('theme_' + theme); - } - }); - - - - _kiwi.applets.nickserv = Backbone.Model.extend({ - initialize: function () { - this.set('title', 'Nickserv Login'); - //this.view = new View(); - - _kiwi.global.control.on('command:login', this.loginCommand, this); - }, - - loginCommand: function (event) { - console.log('waheeyy'); - } - }); -})(); \ No newline at end of file diff --git a/client/assets/src/build.js b/client/assets/src/build.js index 9e48813..d8ceedf 100644 --- a/client/assets/src/build.js +++ b/client/assets/src/build.js @@ -47,7 +47,6 @@ var src = concat([ __dirname + '/models/datastore.js', __dirname + '/applets/settings.js', - __dirname + '/applets/nickserv.js', __dirname + '/applets/chanlist.js', __dirname + '/applets/scripteditor.js', diff --git a/client/assets/src/index.html.tmpl b/client/assets/src/index.html.tmpl index ed3d233..17f1bba 100644 --- a/client/assets/src/index.html.tmpl +++ b/client/assets/src/index.html.tmpl @@ -311,7 +311,6 @@ [ 'src/applets/settings.js', - 'src/applets/nickserv.js', 'src/applets/chanlist.js', 'src/applets/scripteditor.js' ], diff --git a/client/assets/src/utils.js b/client/assets/src/utils.js index bf10e67..1560d34 100644 --- a/client/assets/src/utils.js +++ b/client/assets/src/utils.js @@ -399,278 +399,4 @@ function formatIRCMsg (msg) { function formatDate (d) { d = d || new Date(); return d.toLocaleDateString() + ', ' + d.getHours().toString() + ':' + d.getMinutes().toString() + ':' + d.getSeconds().toString(); -} - - - - - - - - -/* - PLUGINS - Each function in each object is looped through and ran. The resulting text - is expected to be returned. -*/ -var plugins = [ - { - name: "images", - onaddmsg: function (event, opts) { - if (!event.msg) { - return event; - } - - event.msg = event.msg.replace(/^((https?\:\/\/|ftp\:\/\/)|(www\.))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?(\.jpg|\.jpeg|\.gif|\.bmp|\.png)$/gi, function (url) { - // Don't let any future plugins change it (ie. html_safe plugins) - event.event_bubbles = false; - - var img = ''; - return '' + img + '
'; - }); - - return event; - } - }, - - { - name: "html_safe", - onaddmsg: function (event, opts) { - event.msg = $('
').text(event.msg).html(); - event.nick = $('
').text(event.nick).html(); - - return event; - } - }, - - { - name: "activity", - onaddmsg: function (event, opts) { - //if (_kiwi.front.cur_channel.name.toLowerCase() !== _kiwi.front.tabviews[event.tabview.toLowerCase()].name) { - // _kiwi.front.tabviews[event.tabview].activity(); - //} - - return event; - } - }, - - { - name: "highlight", - onaddmsg: function (event, opts) { - //var tab = Tabviews.getTab(event.tabview.toLowerCase()); - - // If we have a highlight... - //if (event.msg.toLowerCase().indexOf(_kiwi.gateway.nick.toLowerCase()) > -1) { - // if (Tabview.getCurrentTab() !== tab) { - // tab.highlight(); - // } - // if (_kiwi.front.isChannel(tab.name)) { - // event.msg = '' + event.msg + ''; - // } - //} - - // If it's a PM, highlight - //if (!_kiwi.front.isChannel(tab.name) && tab.name !== "server" - // && Tabview.getCurrentTab().name.toLowerCase() !== tab.name - //) { - // tab.highlight(); - //} - - return event; - } - }, - - - - { - //Following method taken from: http://snipplr.com/view/13533/convert-text-urls-into-links/ - name: "linkify_plain", - onaddmsg: function (event, opts) { - if (!event.msg) { - return event; - } - - event.msg = event.msg.replace(/((https?\:\/\/|ftp\:\/\/)|(www\.))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi, function (url) { - var nice; - // If it's any of the supported images in the images plugin, skip it - if (url.match(/(\.jpg|\.jpeg|\.gif|\.bmp|\.png)$/)) { - return url; - } - - nice = url; - if (url.match('^https?:\/\/')) { - //nice = nice.replace(/^https?:\/\//i,'') - nice = url; // Shutting up JSLint... - } else { - url = 'http://' + url; - } - - //return '' + nice + '
'; - return '' + nice + ''; - }); - - return event; - } - }, - - { - name: "lftobr", - onaddmsg: function (event, opts) { - if (!event.msg) { - return event; - } - - event.msg = event.msg.replace(/\n/gi, function (txt) { - return '
'; - }); - - return event; - } - }, - - - /* - * Disabled due to many websites closing kiwi with iframe busting - { - name: "inBrowser", - oninit: function (event, opts) { - $('#windows a.link_ext').live('mouseover', this.mouseover); - $('#windows a.link_ext').live('mouseout', this.mouseout); - $('#windows a.link_ext').live('click', this.mouseclick); - }, - - onunload: function (event, opts) { - // TODO: make this work (remove all .link_ext_browser as created in mouseover()) - $('#windows a.link_ext').die('mouseover', this.mouseover); - $('#windows a.link_ext').die('mouseout', this.mouseout); - $('#windows a.link_ext').die('click', this.mouseclick); - }, - - - - mouseover: function (e) { - var a = $(this), - tt = $('.tt', a), - tooltip; - - if (tt.text() === '') { - tooltip = $('Open in _kiwi..'); - tt.append(tooltip); - } - - tt.css('top', -tt.outerHeight() + 'px'); - tt.css('left', (a.outerWidth() / 2) - (tt.outerWidth() / 2)); - }, - - mouseout: function (e) { - var a = $(this), - tt = $('.tt', a); - }, - - mouseclick: function (e) { - var a = $(this), - t; - - switch (e.target.className) { - case 'link_ext': - case 'link_img_a': - return true; - //break; - case 'link_ext_browser': - t = new Utilityview('Browser'); - t.topic = a.attr('href'); - - t.iframe = $(''); - t.iframe.attr('src', a.attr('href')); - t.div.append(t.iframe); - t.show(); - break; - } - return false; - - } - }, - */ - - { - name: "nick_colour", - onaddmsg: function (event, opts) { - if (!event.msg) { - return event; - } - - //if (typeof _kiwi.front.tabviews[event.tabview].nick_colours === 'undefined') { - // _kiwi.front.tabviews[event.tabview].nick_colours = {}; - //} - - //if (typeof _kiwi.front.tabviews[event.tabview].nick_colours[event.nick] === 'undefined') { - // _kiwi.front.tabviews[event.tabview].nick_colours[event.nick] = this.randColour(); - //} - - //var c = _kiwi.front.tabviews[event.tabview].nick_colours[event.nick]; - var c = this.randColour(); - event.nick = '' + event.nick + ''; - - return event; - }, - - - - randColour: function () { - var h = this.rand(-250, 0), - s = this.rand(30, 100), - l = this.rand(20, 70); - return 'hsl(' + h + ',' + s + '%,' + l + '%)'; - }, - - - rand: function (min, max) { - return parseInt(Math.random() * (max - min + 1), 10) + min; - } - }, - - { - name: "kiwitest", - oninit: function (event, opts) { - console.log('registering namespace'); - $(gateway).bind("_kiwi.lol.browser", function (e, data) { - console.log('YAY kiwitest'); - console.log(data); - }); - } - } -]; - - - - - - - - -/** -* @constructor -* @param {String} data_namespace The namespace for the data store -*/ -_kiwi.dataStore = function (data_namespace) { - var namespace = data_namespace; - - this.get = function (key) { - return $.jStorage.get(data_namespace + '_' + key); - }; - - this.set = function (key, value) { - return $.jStorage.set(data_namespace + '_' + key, value); - }; -}; - -_kiwi.data = new _kiwi.dataStore('kiwi'); - - - - -/* - * jQuery jStorage plugin - * https://github.com/andris9/jStorage/ - */ -(function(f){if(!f||!(f.toJSON||Object.toJSON||window.JSON)){throw new Error("jQuery, MooTools or Prototype needs to be loaded before jStorage!")}var g={},d={jStorage:"{}"},h=null,j=0,l=f.toJSON||Object.toJSON||(window.JSON&&(JSON.encode||JSON.stringify)),e=f.evalJSON||(window.JSON&&(JSON.decode||JSON.parse))||function(m){return String(m).evalJSON()},i=false;_XMLService={isXML:function(n){var m=(n?n.ownerDocument||n:0).documentElement;return m?m.nodeName!=="HTML":false},encode:function(n){if(!this.isXML(n)){return false}try{return new XMLSerializer().serializeToString(n)}catch(m){try{return n.xml}catch(o){}}return false},decode:function(n){var m=("DOMParser" in window&&(new DOMParser()).parseFromString)||(window.ActiveXObject&&function(p){var q=new ActiveXObject("Microsoft.XMLDOM");q.async="false";q.loadXML(p);return q}),o;if(!m){return false}o=m.call("DOMParser" in window&&(new DOMParser())||window,n,"text/xml");return this.isXML(o)?o:false}};function k(){if("localStorage" in window){try{if(window.localStorage){d=window.localStorage;i="localStorage"}}catch(p){}}else{if("globalStorage" in window){try{if(window.globalStorage){d=window.globalStorage[window.location.hostname];i="globalStorage"}}catch(o){}}else{h=document.createElement("link");if(h.addBehavior){h.style.behavior="url(#default#userData)";document.getElementsByTagName("head")[0].appendChild(h);h.load("jStorage");var n="{}";try{n=h.getAttribute("jStorage")}catch(m){}d.jStorage=n;i="userDataBehavior"}else{h=null;return}}}b()}function b(){if(d.jStorage){try{g=e(String(d.jStorage))}catch(m){d.jStorage="{}"}}else{d.jStorage="{}"}j=d.jStorage?String(d.jStorage).length:0}function c(){try{d.jStorage=l(g);if(h){h.setAttribute("jStorage",d.jStorage);h.save("jStorage")}j=d.jStorage?String(d.jStorage).length:0}catch(m){}}function a(m){if(!m||(typeof m!="string"&&typeof m!="number")){throw new TypeError("Key name must be string or numeric")}return true}f.jStorage={version:"0.1.5.1",set:function(m,n){a(m);if(_XMLService.isXML(n)){n={_is_xml:true,xml:_XMLService.encode(n)}}g[m]=n;c();return n},get:function(m,n){a(m);if(m in g){if(g[m]&&typeof g[m]=="object"&&g[m]._is_xml&&g[m]._is_xml){return _XMLService.decode(g[m].xml)}else{return g[m]}}return typeof(n)=="undefined"?null:n},deleteKey:function(m){a(m);if(m in g){delete g[m];c();return true}return false},flush:function(){g={};c();return true},storageObj:function(){function m(){}m.prototype=g;return new m()},index:function(){var m=[],n;for(n in g){if(g.hasOwnProperty(n)){m.push(n)}}return m},storageSize:function(){return j},currentBackend:function(){return i},storageAvailable:function(){return !!i},reInit:function(){var m,o;if(h&&h.addBehavior){m=document.createElement("link");h.parentNode.replaceChild(m,h);h=m;h.style.behavior="url(#default#userData)";document.getElementsByTagName("head")[0].appendChild(h);h.load("jStorage");o="{}";try{o=h.getAttribute("jStorage")}catch(n){}d.jStorage=o;i="userDataBehavior"}b()}};k()})(window.jQuery||window.$); \ No newline at end of file +} \ No newline at end of file -- 2.25.1