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 = '<img class="link_img_a" src="' + url + '" height="100%" width="100%" />';
- return '<a class="link_ext link_img" target="_blank" rel="nofollow" href="' + url + '" style="height:50px;width:50px;display:block">' + img + '<div class="tt box"></div></a>';
- });
-
- return event;
- }
- },
-
- {
- name: "html_safe",
- onaddmsg: function (event, opts) {
- event.msg = $('<div/>').text(event.msg).html();
- event.nick = $('<div/>').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 = '<span style="color:red;">' + event.msg + '</span>';
- // }
- //}
-
- // 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 '<a class="link_ext" target="_blank" rel="nofollow" href="' + url + '">' + nice + '<div class="tt box"></div></a>';
- return '<a class="link_ext" target="_blank" rel="nofollow" href="' + url + '">' + nice + '</a>';
- });
-
- return event;
- }
- },
-
- {
- name: "lftobr",
- onaddmsg: function (event, opts) {
- if (!event.msg) {
- return event;
- }
-
- event.msg = event.msg.replace(/\n/gi, function (txt) {
- return '<br/>';
- });
-
- 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 = $('<a class="link_ext_browser">Open in _kiwi..</a>');
- 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 = $('<iframe border="0" class="utility_view" src="" style="width:100%;height:100%;border:none;"></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 = '<span style="color:' + c + ';">' + event.nick + '</span>';
-
- 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