From e88c1084caa02c21c5c60582f155ade76323a98d Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Sun, 6 Oct 2013 12:34:41 +0200 Subject: [PATCH 01/26] Add notification support --- img/favicon.png | Bin 0 -> 1782 bytes index.html | 1 + js/websockets.js | 82 +++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 69 insertions(+), 14 deletions(-) create mode 100644 img/favicon.png diff --git a/img/favicon.png b/img/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..7eca5c8d6e06516fc48ba7e43acd40bb14221df8 GIT binary patch literal 1782 zcmVNAZT=Sa5^t9cV%T`Xkm0NZ*pfZasXu^ z000I_NklU2Igx703TG_wIVvi$B0N{)B|a#Xv|vf*^<-wW0>0L{*zSgo=_@ zNrfyG5v7Qfx2Q=3m0GE4m4`~aM5$USZKX!75{b4XSeBbQw$letW+^qqdWJ`+;e{CKj+R2aKGFy|KlS5Q^&@w&B)HJmLFqBUO(Ir zZ>p;g0+sL!VN8YE4t*6P7uaJK~2X05gPPKr=%TK@+n!kwn^%@O8k``S$_%H31HNd*53vTQ}}fT36Vm z5U^~C;uo%$o?N;U6vIpyC|`xz)xLJaKo^y-U1P{2BA=LiW7w;@dt}JhL_Yb(r<=to z0K5+1(20FV9@yJ`wBlR}2#&4&jI`aKup^4(WXruea&6H zb<(nIX~iL=z;A!h{|tb4)&V?q?r@z6%?E$`)r9TleAmtUdC&24MaOfDGVa{i{QCgh z%NM@&$kB6eUa;ax09^Ur&#eUM>CsLAIP~4u9&c>lx>H)QWaXci7Ur)F&AOSpcgpY9 z0Q~ulNuvXGDb?2S)|TDxOH(325cQ$!ScwfApY;pb z5df*qod-`wb5pgV34!#~=s1AcCrB39m;fThi<4s?8x>9gkZoV;Kknr;Kn&)R zcVQzvHFOJ%aR6xV8yGYy1?A}~K*r+r@o@n2wE)DHN1r}j%mg4RBLmDp=sN!VCqq{N z6n7mvw;kO4h?iC1a`eQImc+I9esLAR4FG7^y#IS{CIm5+#zYECUwPxN01E2>dizfu zk+F_$cU4t6XD~~w%uUZa=}$ibz;%f&2SYEmS@}9ri2xP?#mtRdc7AdQK=9!H!Dm3N zjm1?}QVD>tu(~jDM|sZJn%|}bAX^^z+Bbbi+guenGed|NZVg`=0x%m5-*hr4NDvu- zxs-}>~LY9`Zs*mDecP4oiV zU((An!&d?10d!ljZ3B_YfN7`_4^ zSO*Zg;cilmeV$W_stSOq-rn3hxE~_6lHBm%^P!spldeR@1Ta~4N8gXnbnb|sVFpx@ z5VDCBC{1HwdEyp>M{4amwzPVVhHe66bS3l4^vuAfo>MO~)5}bNn++CV!CGin4l*qsR!AGM?A~q(H1RNGT$%z}jafpUHU4#VnazmMOc!lvyT| z{=%5g7TH|C8XZ@7JwV_DSG0fa1UU6W<_&$|Sez&f!TBOlKF{Q2nR3g_&Jt7M9y6@~ zW*Mw9#9oHYvP0&d4v=>N_@!kwEJaM!`@nxYl*R${0B9-iEdW*l6srvL{d4^N@_$$U Y1seB0;07)3N&o-=07*qoM6N<$f|o=#y#N3J literal 0 HcmV?d00001 diff --git a/index.html b/index.html index 2f906d4..32879e0 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,7 @@ + diff --git a/js/websockets.js b/js/websockets.js index fa2475e..f57eaa9 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -205,6 +205,10 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ var prefix = colors.parse(message['objects'][0]['content'][0]['prefix']); var text = colors.parse(message['objects'][0]['content'][0]['message']); var buffer = message['objects'][0]['content'][0]['buffer']; + var tags_array = message['objects'][0]['content'][0]['tags_array']; + var displayed = message['objects'][0]['content'][0]['displayed']; + var highlight = message['objects'][0]['content'][0]['highlight']; + console.log(highlight, tags_array); var message = _.union(prefix, text); message =_.map(message, function(message) { if ('fg' in message) { @@ -212,19 +216,28 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ } return message; }); - buffer_line['message'] = message; + // Only react to line if its displayed + if (displayed) { + buffer_line['message'] = message; - if (!_isActiveBuffer(buffer)) { - $rootScope.buffers[buffer]['notification'] = true; + + if (!_isActiveBuffer(buffer)) { + $rootScope.buffers[buffer]['notification'] = true; + } + + var additionalContent = pluginManager.contentForMessage(text[0]['text']); + + if (additionalContent) { + buffer_line['metadata'] = additionalContent; + } + + $rootScope.buffers[buffer]['lines'].push(buffer_line); + + + if(highlight || _.contains(tags_array, 'notify_private')) { + $rootScope.createHighlight(prefix, text, message, buffer, additionalContent); + } } - - var additionalContent = pluginManager.contentForMessage(text[0]['text']); - - if (additionalContent) { - buffer_line['metadata'] = additionalContent; - } - - $rootScope.buffers[buffer]['lines'].push(buffer_line); } /* @@ -245,6 +258,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ } + /* * Handle answers to (bufinfo) messages * @@ -321,18 +335,20 @@ weechat.factory('connection', ['$rootScope', '$log', 'handlers', 'colors', funct websocket.binaryType = "arraybuffer" websocket.onopen = function (evt) { + var send = ""; // FIXME: does password need to be sent only if protocol is not weechat? if (proto == "weechat") { if (password) { - doSend("init compression=off,password=" + password + "\n"); + send += "init compression=off,password=" + password + "\n"; } - doSend("(bufinfo) hdata buffer:gui_buffers(*) full_name\n"); - doSend("sync\n"); + send += "(bufinfo) hdata buffer:gui_buffers(*) full_name\n"; + send += "sync\n"; } else { } $log.info("Connected to relay"); + doSend(send); $rootScope.connected = true; $rootScope.$apply(); } @@ -372,6 +388,21 @@ weechat.factory('connection', ['$rootScope', '$log', 'handlers', 'colors', funct }]); weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', 'connection', function ($rootScope, $scope, $store, connection) { + + // Request notification permission + Notification.requestPermission(function (status) { + console.log('Notification permission status:',status); + if (Notification.permission !== status) { + Notification.permission = status; + } + }); + if(window.webkitNotifications != undefined) { + if (window.webkitNotifications.checkPermission() == 0) { // 0 is PERMISSION_ALLOWED + console.log('Notification permission status:', window.webkitNotifications.checkPermission() == 0); + window.webkitNotifications.requestPermission(); + } + } + $rootScope.commands = [] $rootScope.buffer = [] @@ -402,5 +433,28 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', 'connection $scope.connect = function() { connection.connect($scope.hostport, $scope.proto, $scope.password); } + + + /* Function gets called from bufferLineAdded code if user should be notified */ + $rootScope.createHighlight = function(prefix, text, message, buffer, additionalContent) { + var prefixs = ""; + prefixs += prefix[0].text; + prefixs += prefix[1].text; + var messages = ""; + messages += text[0].text; + + var buffers = $rootScope.buffers[buffer]; + + var title = buffers.full_name; + var content = "<"+prefixs+">"+messages; + + var timeout = 15*1000; + console.log('Displaying notification:',title,',with timeout:',timeout); + var notification = new Notification(title, {body:content, icon:'img/favicon.png'}); + // Cancel notification automatically + notification.onshow = function() { + setTimeout(function() { notification.close() }, timeout); + } + }; }] ); From 8520c7251abaca11fa8c26564f1e5701d3547454 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Sun, 6 Oct 2013 13:42:45 +0200 Subject: [PATCH 02/26] Support weechat extended colors, sort buffers --- index.html | 4 +-- js/websockets.js | 79 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 75 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 32879e0..2fdabd1 100644 --- a/index.html +++ b/index.html @@ -46,12 +46,12 @@
- + {{ content.full_name }}
- + {{ part.text }} diff --git a/js/websockets.js b/js/websockets.js index f57eaa9..29a12b1 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -1,9 +1,77 @@ var weechat = angular.module('weechat', ['localStorage']); +weechat.filter('toArray', function () { + 'use strict'; + + return function (obj) { + if (!(obj instanceof Object)) { + return obj; + } + + return Object.keys(obj).map(function (key) { + return Object.defineProperty(obj[key], '$key', {__proto__: null, value: key}); + }); + } +}); weechat.factory('colors', [function($scope) { // http://weechat.org/files/doc/devel/weechat_dev.en.html#color_codes_in_strings var part, fg, bg, attrs, colors = ['', 'black', 'dark gray', 'dark red', 'light red', 'dark green', 'light green', 'brown', 'yellow', 'dark blue', 'light blue', 'dark magenta', 'light magenta', 'dark cyan', 'light cyan', 'gray', 'white']; + // XTerm 8-bit pallete + var colors = [ + '#000000', '#AA0000', '#00AA00', '#AA5500', '#0000AA', + '#AA00AA', '#00AAAA', '#AAAAAA', '#555555', '#FF5555', + '#55FF55', '#FFFF55', '#5555FF', '#FF55FF', '#55FFFF', + '#FFFFFF', '#000000', '#00005F', '#000087', '#0000AF', + '#0000D7', '#0000FF', '#005F00', '#005F5F', '#005F87', + '#005FAF', '#005FD7', '#005FFF', '#008700', '#00875F', + '#008787', '#0087AF', '#0087D7', '#00AF00', '#00AF5F', + '#00AF87', '#00AFAF', '#00AFD7', '#00AFFF', '#00D700', + '#00D75F', '#00D787', '#00D7AF', '#00D7D7', '#00D7FF', + '#00FF00', '#00FF5F', '#00FF87', '#00FFAF', '#00FFD7', + '#00FFFF', '#5F0000', '#5F005F', '#5F0087', '#5F00AF', + '#5F00D7', '#5F00FF', '#5F5F00', '#5F5F5F', '#5F5F87', + '#5F5FAF', '#5F5FD7', '#5F5FFF', '#5F8700', '#5F875F', + '#5F8787', '#5F87AF', '#5F87D7', '#5F87FF', '#5FAF00', + '#5FAF5F', '#5FAF87', '#5FAFAF', '#5FAFD7', '#5FAFFF', + '#5FD700', '#5FD75F', '#5FD787', '#5FD7AF', '#5FD7D7', + '#5FD7FF', '#5FFF00', '#5FFF5F', '#5FFF87', '#5FFFAF', + '#5FFFD7', '#5FFFFF', '#870000', '#87005F', '#870087', + '#8700AF', '#8700D7', '#8700FF', '#875F00', '#875F5F', + '#875F87', '#875FAF', '#875FD7', '#875FFF', '#878700', + '#87875F', '#878787', '#8787AF', '#8787D7', '#8787FF', + '#87AF00', '#87AF5F', '#87AF87', '#87AFAF', '#87AFD7', + '#87AFFF', '#87D700', '#87D75F', '#87D787', '#87D7AF', + '#87D7D7', '#87D7FF', '#87FF00', '#87FF5F', '#87FF87', + '#87FFAF', '#87FFD7', '#87FFFF', '#AF0000', '#AF005F', + '#AF0087', '#AF00AF', '#AF00D7', '#AF00FF', '#AF5F00', + '#AF5F5F', '#AF5F87', '#AF5FAF', '#AF5FD7', '#AF5FFF', + '#AF8700', '#AF875F', '#AF8787', '#AF87AF', '#AF87D7', + '#AF87FF', '#AFAF00', '#AFAF5F', '#AFAF87', '#AFAFAF', + '#AFAFD7', '#AFAFFF', '#AFD700', '#AFD75F', '#AFD787', + '#AFD7AF', '#AFD7D7', '#AFD7FF', '#AFFF00', '#AFFF5F', + '#AFFF87', '#AFFFAF', '#AFFFD7', '#AFFFFF', '#D70000', + '#D7005F', '#D70087', '#D700AF', '#D700D7', '#D700FF', + '#D75F00', '#D75F5F', '#D75F87', '#D75FAF', '#D75FD7', + '#D75FFF', '#D78700', '#D7875F', '#D78787', '#D787AF', + '#D787D7', '#D787FF', '#D7AF00', '#D7AF5F', '#D7AF87', + '#D7AFAF', '#D7AFD7', '#D7AFFF', '#D7D700', '#D7D75F', + '#D7D787', '#D7D7AF', '#D7D7D7', '#D7D7FF', '#D7FF00', + '#D7FF5F', '#D7FF87', '#D7FFAF', '#D7FFD7', '#D7FFFF', + '#FF0000', '#FF005F', '#FF0087', '#FF00AF', '#FF00D7', + '#FF00FF', '#FF5F00', '#FF5F5F', '#FF5F87', '#FF5FAF', + '#FF5FD7', '#FF5FFF', '#FF8700', '#FF875F', '#FF8787', + '#FF87AF', '#FF87D7', '#FF87FF', '#FFAF00', '#FFAF5F', + '#FFAF87', '#FFAFAF', '#FFAFD7', '#FFAFFF', '#FFD700', + '#FFD75F', '#FFD787', '#FFD7AF', '#FFD7D7', '#FFD7FF', + '#FFFF00', '#FFFF5F', '#FFFF87', '#FFFFAF', '#FFFFD7', + '#FFFFFF', '#080808', '#121212', '#1C1C1C', '#262626', + '#303030', '#3A3A3A', '#444444', '#4E4E4E', '#585858', + '#626262', '#6C6C6C', '#767676', '#808080', '#8A8A8A', + '#949494', '#9E9E9E', '#A8A8A8', '#B2B2B2', '#BCBCBC', + '#C6C6C6', '#D0D0D0', '#DADADA', '#E4E4E4', '#EEEEEE' + ] + function setAttrs() { while (part.match(/^[\*\/\_\|]/)) { @@ -15,8 +83,8 @@ weechat.factory('colors', [function($scope) { function getColor() { var c; if (part.match(/^@/)) { - c = part.slice(1, 5); - part = part.slice(5); + c = part.slice(1, 6); + part = part.slice(6); } else { c = part.slice(0, 2); part = part.slice(2); @@ -26,9 +94,9 @@ weechat.factory('colors', [function($scope) { function prepareCss(color) { /* - * Translates a weechat color string to CSS + * Translates a weechat color to CSS */ - return'color-' + color.replace(' ', '-'); + return 'color: ' + color; } var prefixes = { @@ -208,7 +276,6 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ var tags_array = message['objects'][0]['content'][0]['tags_array']; var displayed = message['objects'][0]['content'][0]['displayed']; var highlight = message['objects'][0]['content'][0]['highlight']; - console.log(highlight, tags_array); var message = _.union(prefix, text); message =_.map(message, function(message) { if ('fg' in message) { @@ -342,7 +409,7 @@ weechat.factory('connection', ['$rootScope', '$log', 'handlers', 'colors', funct send += "init compression=off,password=" + password + "\n"; } - send += "(bufinfo) hdata buffer:gui_buffers(*) full_name\n"; + send += "(bufinfo) hdata buffer:gui_buffers(*) number,full_name\n"; send += "sync\n"; } else { From 4db0a985c5b87983a18f74671d1a42db658e33a1 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Sun, 6 Oct 2013 13:59:34 +0200 Subject: [PATCH 03/26] Improve design of landing page --- index.html | 55 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/index.html b/index.html index 2fdabd1..b62397a 100644 --- a/index.html +++ b/index.html @@ -13,35 +13,42 @@
-
-
- Connection +
+

+ + glowing bear + + WeeChat web frontend + +

+
To start using, please enable relay in your WeeChat client: +
+            /set relay.network.password yourpassword
+            /relay add weechat 9001
+ Note: The communication goes directly between your browser and your weechat in clear text. + Connection settings are saved between sessions, including password, in your own browser. +
+

Connection settings

+
- Oh no! We cannot connect! + Oh no! We cannot connect!
-
- -
- +
+ + +

Enter the hostname and the port to the WeeChat relay, separated by a :

-
-
- -
- +
+ + +

Password will be stored in your browser session

-
-
- -
- +
+ + +

Default is fine.

-
-
-
- -
-
+
From 6455256b9ef8a97f58eae4f20c79c6eeb1390c75 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Sun, 6 Oct 2013 19:15:34 +0200 Subject: [PATCH 04/26] design improvements, and add time to each line --- css/glowingbear.css | 7 +++++-- index.html | 27 +++++++++++++++++++-------- js/websockets.js | 9 +++++++++ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 26fd773..54c312b 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -1,7 +1,10 @@ body { - font-family: monospace; background-color: black; color: white; + padding: 5px; +} +.bufferlines { + font-family: sans-serif; } .color-light-green { @@ -58,4 +61,4 @@ body { li.notification { color: green; -} \ No newline at end of file +} diff --git a/index.html b/index.html index b62397a..486050e 100644 --- a/index.html +++ b/index.html @@ -53,10 +53,15 @@
- - {{ content.full_name }} - -
+ +
+ + {{ bufferline.date }} + {{ part.text }} @@ -77,10 +82,16 @@
-
- - -
+
diff --git a/js/websockets.js b/js/websockets.js index 29a12b1..c7b3482 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -1,3 +1,7 @@ +Number.prototype.pad = function (len) { + return (new Array(len+1).join("0") + this).slice(-len); +} + var weechat = angular.module('weechat', ['localStorage']); weechat.filter('toArray', function () { 'use strict'; @@ -270,6 +274,9 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ var handleBufferLineAdded = function(message) { var buffer_line = {} + var date = message['objects'][0]['content'][0]['date']; + date = new Date(parseInt(date, 10) * 1000); + var datestring = date.getHours().pad(2) + ':' + date.getMinutes().pad(2); var prefix = colors.parse(message['objects'][0]['content'][0]['prefix']); var text = colors.parse(message['objects'][0]['content'][0]['message']); var buffer = message['objects'][0]['content'][0]['buffer']; @@ -300,6 +307,8 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ $rootScope.buffers[buffer]['lines'].push(buffer_line); + buffer_line['date'] = datestring; + if(highlight || _.contains(tags_array, 'notify_private')) { $rootScope.createHighlight(prefix, text, message, buffer, additionalContent); From 7230e7a3ee2526773c357b728ac1833c169a49a3 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Sun, 6 Oct 2013 20:20:34 +0200 Subject: [PATCH 05/26] Sync initial lines --- js/websockets.js | 66 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/js/websockets.js b/js/websockets.js index c7b3482..db36551 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -272,20 +272,20 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ $rootScope.closeBuffer(buffer_pointer); } - var handleBufferLineAdded = function(message) { + var handleLine = function(line) { var buffer_line = {} - var date = message['objects'][0]['content'][0]['date']; + var date = line['date']; date = new Date(parseInt(date, 10) * 1000); var datestring = date.getHours().pad(2) + ':' + date.getMinutes().pad(2); - var prefix = colors.parse(message['objects'][0]['content'][0]['prefix']); - var text = colors.parse(message['objects'][0]['content'][0]['message']); - var buffer = message['objects'][0]['content'][0]['buffer']; - var tags_array = message['objects'][0]['content'][0]['tags_array']; - var displayed = message['objects'][0]['content'][0]['displayed']; - var highlight = message['objects'][0]['content'][0]['highlight']; + var prefix = colors.parse(line['prefix']); + var text = colors.parse(line['message']); + var buffer = line['buffer']; + var tags_array = line['tags_array']; + var displayed = line['displayed']; + var highlight = line['highlight']; var message = _.union(prefix, text); message =_.map(message, function(message) { - if ('fg' in message) { + if (message != "" && 'fg' in message) { message['fg'] = colors.prepareCss(message['fg']); } return message; @@ -299,23 +299,30 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ $rootScope.buffers[buffer]['notification'] = true; } - var additionalContent = pluginManager.contentForMessage(text[0]['text']); + if (text[0] != undefined) { + var additionalContent = pluginManager.contentForMessage(text[0]['text']); - if (additionalContent) { - buffer_line['metadata'] = additionalContent; + if (additionalContent) { + buffer_line['metadata'] = additionalContent; + } } $rootScope.buffers[buffer]['lines'].push(buffer_line); buffer_line['date'] = datestring; - if(highlight || _.contains(tags_array, 'notify_private')) { $rootScope.createHighlight(prefix, text, message, buffer, additionalContent); } } } + var handleBufferLineAdded = function(message) { + message['objects'][0]['content'].forEach(function(l) { + handleLine(l); + }); + } + /* * Returns whether or not this buffer is the active buffer */ @@ -358,6 +365,22 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ } } $rootScope.buffers = buffers; + + // Request latest buffer lines for each buffer + $rootScope.getLines(); + } + + + /* + * Handle answers to (lineinfo) messages + * + * (lineinfo) messages are specified by this client. It is request after bufinfo completes + */ + var handleLineInfo = function(message) { + var lines = message['objects'][0]['content'].reverse(); + lines.forEach(function(l) { + handleLine(l); + }); } var handleEvent = function(event) { @@ -378,6 +401,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ var eventHandlers = { bufinfo: handleBufferInfo, + lineinfo: handleLineInfo, _buffer_closing: handleBufferClosing, _buffer_line_added: handleBufferLineAdded, _buffer_opened: handleBufferOpened @@ -457,7 +481,14 @@ weechat.factory('connection', ['$rootScope', '$log', 'handlers', 'colors', funct doSend(message); } + var getLines = function(count) { + var message = "(lineinfo) hdata buffer:gui_buffers(*)/own_lines/last_line(-"+count+")/data\n"; + doSend(message) + } + return { + send: doSend, + getLines: getLines, connect: connect, sendMessage: sendMessage } @@ -509,13 +540,18 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', 'connection $scope.connect = function() { connection.connect($scope.hostport, $scope.proto, $scope.password); } - + $rootScope.getLines = function() { + var count = 20; + connection.getLines(20); + } /* Function gets called from bufferLineAdded code if user should be notified */ $rootScope.createHighlight = function(prefix, text, message, buffer, additionalContent) { var prefixs = ""; prefixs += prefix[0].text; - prefixs += prefix[1].text; + if(prefix[1] != undefined) { + prefixs += prefix[1].text; + } var messages = ""; messages += text[0].text; From 2100fabf24de4b1fe9ca134a351f4796da2fc876 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Sun, 6 Oct 2013 23:59:34 +0200 Subject: [PATCH 06/26] handle initial sync and no notification, use short_name --- index.html | 8 ++++---- js/websockets.js | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/index.html b/index.html index 486050e..b7eaedd 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,5 @@ - + @@ -11,7 +11,7 @@ - +

@@ -55,11 +55,11 @@
- + {{ bufferline.date }} diff --git a/js/websockets.js b/js/websockets.js index db36551..e90e832 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -272,7 +272,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ $rootScope.closeBuffer(buffer_pointer); } - var handleLine = function(line) { + var handleLine = function(line, initial) { var buffer_line = {} var date = line['date']; date = new Date(parseInt(date, 10) * 1000); @@ -295,7 +295,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ buffer_line['message'] = message; - if (!_isActiveBuffer(buffer)) { + if (!_isActiveBuffer(buffer) && !initial) { $rootScope.buffers[buffer]['notification'] = true; } @@ -311,7 +311,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ buffer_line['date'] = datestring; - if(highlight || _.contains(tags_array, 'notify_private')) { + if(!initial && (highlight || _.contains(tags_array, 'notify_private')) ) { $rootScope.createHighlight(prefix, text, message, buffer, additionalContent); } } @@ -319,7 +319,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ var handleBufferLineAdded = function(message) { message['objects'][0]['content'].forEach(function(l) { - handleLine(l); + handleLine(l, false); }); } @@ -335,9 +335,13 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ } var handleBufferOpened = function(message) { - var fullName = message['objects'][0]['content'][0]['full_name'] - var buffer = message['objects'][0]['content'][0]['pointers'][0] - $rootScope.buffers[buffer] = { 'id': buffer, 'lines':[], 'full_name':fullName } + var obj = message['objects'][0]['content'][0]; + var fullName = obj['full_name']; + var buffer = obj['pointers'][0]; + var short_name = obj['short_name']; + var title = obj['title']; + + $rootScope.buffers[buffer] = { 'id': buffer, 'lines':[], 'full_name':fullName, 'short_name':short_name, 'title':title } } @@ -379,7 +383,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ var handleLineInfo = function(message) { var lines = message['objects'][0]['content'].reverse(); lines.forEach(function(l) { - handleLine(l); + handleLine(l, true); }); } @@ -442,7 +446,7 @@ weechat.factory('connection', ['$rootScope', '$log', 'handlers', 'colors', funct send += "init compression=off,password=" + password + "\n"; } - send += "(bufinfo) hdata buffer:gui_buffers(*) number,full_name\n"; + send += "(bufinfo) hdata buffer:gui_buffers(*) number,full_name,short_name,title\n"; send += "sync\n"; } else { From 02d0c25c12e155dde4bde85e3f176b31c16b20a7 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Mon, 7 Oct 2013 00:12:44 +0200 Subject: [PATCH 07/26] handle pagetitle, use better background color --- css/glowingbear.css | 2 +- index.html | 9 +++++++-- js/websockets.js | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 54c312b..54e6ad8 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -1,6 +1,6 @@ body { - background-color: black; color: white; + background-color: #222; padding: 5px; } .bufferlines { diff --git a/index.html b/index.html index b7eaedd..922bf6a 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,11 @@ - + + + + + + @@ -54,7 +59,7 @@
diff --git a/js/websockets.js b/js/websockets.js index e90e832..feb0e8f 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -534,6 +534,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', 'connection $scope.setActiveBuffer = function(key) { $rootScope.buffers[key]['notification'] = false; $rootScope.activeBuffer = $rootScope.buffers[key]; + $rootScope.pageTitle = $rootScope.activeBuffer['short_name'] + ' | ' + $rootScope.activeBuffer['title']; }; $scope.sendMessage = function() { From 452fc3adfabb20b78481adb8bb0c73261f8ef102 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Mon, 7 Oct 2013 00:24:18 +0200 Subject: [PATCH 08/26] handle buffer title changed --- js/websockets.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/js/websockets.js b/js/websockets.js index feb0e8f..8ff9e91 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -345,6 +345,15 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ } + var handleBufferTitleChanged = function(message) { + var obj = message['objects'][0]['content'][0]; + var buffer = obj['pointers'][0]; + var old = $rootScope.buffers[buffer]; + old['full_name'] = obj['full_name']; + old['short_name'] = obj['short_name']; + old['title'] = obj['title']; + } + /* * Handle answers to (bufinfo) messages @@ -408,7 +417,8 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ lineinfo: handleLineInfo, _buffer_closing: handleBufferClosing, _buffer_line_added: handleBufferLineAdded, - _buffer_opened: handleBufferOpened + _buffer_opened: handleBufferOpened, + _buffer_title_changed: handleBufferTitleChanged, } return { @@ -532,7 +542,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', 'connection } $scope.setActiveBuffer = function(key) { - $rootScope.buffers[key]['notification'] = false; + $rootScope.activeBuffer['notification'] = false; + $rootScope.buffers[key]['notification'] = true; $rootScope.activeBuffer = $rootScope.buffers[key]; $rootScope.pageTitle = $rootScope.activeBuffer['short_name'] + ' | ' + $rootScope.activeBuffer['title']; }; From 8c69511b5f978a17f7de185c5ce050664bcd1fef Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Mon, 7 Oct 2013 00:41:32 +0200 Subject: [PATCH 09/26] Improve date handling --- index.html | 2 +- js/websockets.js | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 922bf6a..80e2574 100644 --- a/index.html +++ b/index.html @@ -65,7 +65,7 @@
- {{ bufferline.date }} + {{ bufferline.date | date:'HH:mm' }} diff --git a/js/websockets.js b/js/websockets.js index 8ff9e91..587531b 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -1,7 +1,3 @@ -Number.prototype.pad = function (len) { - return (new Array(len+1).join("0") + this).slice(-len); -} - var weechat = angular.module('weechat', ['localStorage']); weechat.filter('toArray', function () { 'use strict'; @@ -275,8 +271,6 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ var handleLine = function(line, initial) { var buffer_line = {} var date = line['date']; - date = new Date(parseInt(date, 10) * 1000); - var datestring = date.getHours().pad(2) + ':' + date.getMinutes().pad(2); var prefix = colors.parse(line['prefix']); var text = colors.parse(line['message']); var buffer = line['buffer']; @@ -309,7 +303,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ $rootScope.buffers[buffer]['lines'].push(buffer_line); - buffer_line['date'] = datestring; + buffer_line['date'] = date; if(!initial && (highlight || _.contains(tags_array, 'notify_private')) ) { $rootScope.createHighlight(prefix, text, message, buffer, additionalContent); From e7adbffa479cc92cb3c5d36965d086b79aba2712 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Mon, 7 Oct 2013 00:49:20 +0200 Subject: [PATCH 10/26] improve chatpanes with scrolling and fix nav --- css/glowingbear.css | 7 +++++- index.html | 58 +++++++++++++++++++++++---------------------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 54e6ad8..c2de348 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -4,9 +4,14 @@ body { padding: 5px; } .bufferlines { - font-family: sans-serif; + font-family: monospace; + overflow: scroll-y; + height: 100%; } +.navbar-fixed-bottom { + margin: 5px; +} .color-light-green { color: chartreuse; } diff --git a/index.html b/index.html index 80e2574..f0b3e27 100644 --- a/index.html +++ b/index.html @@ -58,35 +58,37 @@
- -
- - {{ bufferline.date | date:'HH:mm' }} - - - - {{ part.text }} - - - - - - + +
+
+ + {{ bufferline.date | date:'HH:mm' }} + + + + {{ part.text }} + + + +
+
+

To start using, please enable relay in your WeeChat client:
-            /set relay.network.password yourpassword
-            /relay add weechat 9001
+/set relay.network.password yourpassword +/relay add weechat 9001 Note: The communication goes directly between your browser and your weechat in clear text. Connection settings are saved between sessions, including password, in your own browser.
From 34b5d84d53b12979c28554f6302b89460e7f2748 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Mon, 7 Oct 2013 12:14:19 +0200 Subject: [PATCH 17/26] do not trigger unread for lines tagged with notify_none --- js/websockets.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/websockets.js b/js/websockets.js index 7e3b1cc..592abdb 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -289,7 +289,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ buffer_line['message'] = message; - if (!_isActiveBuffer(buffer) && !initial) { + if (!_isActiveBuffer(buffer) && !initial && !_.contains(tags_array, 'notify_none')) { if ($rootScope.buffers[buffer]['unread'] == '') { $rootScope.buffers[buffer]['unread'] = 1; From 8d8800705fe87c94f127195d25f6f78296d61ab6 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Mon, 7 Oct 2013 12:48:53 +0200 Subject: [PATCH 18/26] GH pages --- COPYING | 674 +++++++++++++++ README.md | 10 + css/glowingbear.css | 76 ++ img/favicon.png | Bin 0 -> 1782 bytes img/glyphicons-halflings-white.png | Bin 0 -> 8777 bytes img/glyphicons-halflings.png | Bin 0 -> 12799 bytes index.html | 115 +++ js/angular.min.js | 160 ++++ js/localstorage.js | 113 +++ js/protocol.js | 180 ++++ js/underscore.js | 1246 ++++++++++++++++++++++++++++ js/websockets.js | 599 +++++++++++++ 12 files changed, 3173 insertions(+) create mode 100644 COPYING create mode 100644 README.md create mode 100644 css/glowingbear.css create mode 100644 img/favicon.png create mode 100644 img/glyphicons-halflings-white.png create mode 100644 img/glyphicons-halflings.png create mode 100644 index.html create mode 100644 js/angular.min.js create mode 100644 js/localstorage.js create mode 100644 js/protocol.js create mode 100644 js/underscore.js create mode 100644 js/websockets.js diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0c45e08 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +A web client for WeeChat +======================== + +To use the web interface you first need to set a relay and a password: + + /relay add weechat 9001 + /set relay.network.password YOURPASSWORD + +Then you can point your browser to the +[Glowing Bear](http://cormier.github.io/glowing-bear) ! diff --git a/css/glowingbear.css b/css/glowingbear.css new file mode 100644 index 0000000..d013eee --- /dev/null +++ b/css/glowingbear.css @@ -0,0 +1,76 @@ +body { + color: white; + background-color: #222; + padding-left: 5px; + padding-right: 5px; + padding-bottom:70px; + padding-top: 70px; +} +.bufferlines { + font-family: monospace; + overflow: scroll-y; + height: 100%; +} + +.navbar-fixed-bottom { + margin: 5px; +} +.color-light-green { + color: chartreuse; +} + +.color-27 { + color: deepskyblue; +} + +.danger { + background-color: rgb(217, 83, 79); +} + +.color-28 { + color: greenyellow; +} + +.color-00 { + color: coral; +} + +.color-yellow { + color: yellow; +} + +.color-dark-red { + color: darkred; +} + +.color-dark-green { + color: green; +} + +.color-dark-blue { + color: darkblue; +} + +.color-dark-gray { + color: gray; +} + +.color-gray { + color: lightgray; +} + +.color-brown { + color: brown; +} + +.color-cyan { + color: cyan; +} + +.color-dark-cyan { + color: darkcyan; +} + +li.notification { + color: green; +} diff --git a/img/favicon.png b/img/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..7eca5c8d6e06516fc48ba7e43acd40bb14221df8 GIT binary patch literal 1782 zcmVNAZT=Sa5^t9cV%T`Xkm0NZ*pfZasXu^ z000I_NklU2Igx703TG_wIVvi$B0N{)B|a#Xv|vf*^<-wW0>0L{*zSgo=_@ zNrfyG5v7Qfx2Q=3m0GE4m4`~aM5$USZKX!75{b4XSeBbQw$letW+^qqdWJ`+;e{CKj+R2aKGFy|KlS5Q^&@w&B)HJmLFqBUO(Ir zZ>p;g0+sL!VN8YE4t*6P7uaJK~2X05gPPKr=%TK@+n!kwn^%@O8k``S$_%H31HNd*53vTQ}}fT36Vm z5U^~C;uo%$o?N;U6vIpyC|`xz)xLJaKo^y-U1P{2BA=LiW7w;@dt}JhL_Yb(r<=to z0K5+1(20FV9@yJ`wBlR}2#&4&jI`aKup^4(WXruea&6H zb<(nIX~iL=z;A!h{|tb4)&V?q?r@z6%?E$`)r9TleAmtUdC&24MaOfDGVa{i{QCgh z%NM@&$kB6eUa;ax09^Ur&#eUM>CsLAIP~4u9&c>lx>H)QWaXci7Ur)F&AOSpcgpY9 z0Q~ulNuvXGDb?2S)|TDxOH(325cQ$!ScwfApY;pb z5df*qod-`wb5pgV34!#~=s1AcCrB39m;fThi<4s?8x>9gkZoV;Kknr;Kn&)R zcVQzvHFOJ%aR6xV8yGYy1?A}~K*r+r@o@n2wE)DHN1r}j%mg4RBLmDp=sN!VCqq{N z6n7mvw;kO4h?iC1a`eQImc+I9esLAR4FG7^y#IS{CIm5+#zYECUwPxN01E2>dizfu zk+F_$cU4t6XD~~w%uUZa=}$ibz;%f&2SYEmS@}9ri2xP?#mtRdc7AdQK=9!H!Dm3N zjm1?}QVD>tu(~jDM|sZJn%|}bAX^^z+Bbbi+guenGed|NZVg`=0x%m5-*hr4NDvu- zxs-}>~LY9`Zs*mDecP4oiV zU((An!&d?10d!ljZ3B_YfN7`_4^ zSO*Zg;cilmeV$W_stSOq-rn3hxE~_6lHBm%^P!spldeR@1Ta~4N8gXnbnb|sVFpx@ z5VDCBC{1HwdEyp>M{4amwzPVVhHe66bS3l4^vuAfo>MO~)5}bNn++CV!CGin4l*qsR!AGM?A~q(H1RNGT$%z}jafpUHU4#VnazmMOc!lvyT| z{=%5g7TH|C8XZ@7JwV_DSG0fa1UU6W<_&$|Sez&f!TBOlKF{Q2nR3g_&Jt7M9y6@~ zW*Mw9#9oHYvP0&d4v=>N_@!kwEJaM!`@nxYl*R${0B9-iEdW*l6srvL{d4^N@_$$U Y1seB0;07)3N&o-=07*qoM6N<$f|o=#y#N3J literal 0 HcmV?d00001 diff --git a/img/glyphicons-halflings-white.png b/img/glyphicons-halflings-white.png new file mode 100644 index 0000000000000000000000000000000000000000..3bf6484a29d8da269f9bc874b25493a45fae3bae GIT binary patch literal 8777 zcmZvC1yGz#v+m*$LXcp=A$ZWB0fL7wNbp_U*$~{_gL`my3oP#L!5tQYy99Ta`+g_q zKlj|KJ2f@c)ARJx{q*bbkhN_!|Wn*Vos8{TEhUT@5e;_WJsIMMcG5%>DiS&dv_N`4@J0cnAQ-#>RjZ z00W5t&tJ^l-QC*ST1-p~00u^9XJ=AUl7oW-;2a+x2k__T=grN{+1c4XK0ZL~^z^i$ zp&>vEhr@4fZWb380S18T&!0cQ3IKpHF)?v=b_NIm0Q>vwY7D0baZ)n z31Fa5sELUQARIVaU0nqf0XzT+fB_63aA;@<$l~wse|mcA;^G1TmX?-)e)jkGPfkuA z92@|!<>h5S_4f8QP-JRq>d&7)^Yin8l7K8gED$&_FaV?gY+wLjpoW%~7NDe=nHfMG z5DO3j{R9kv5GbssrUpO)OyvVrlx>u0UKD0i;Dpm5S5dY16(DL5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0 HcmV?d00001 diff --git a/img/glyphicons-halflings.png b/img/glyphicons-halflings.png new file mode 100644 index 0000000000000000000000000000000000000000..a9969993201f9cee63cf9f49217646347297b643 GIT binary patch literal 12799 zcma*OWmH^Ivn@*S;K3nSf_t!#;0f+&pm7Po8`nk}2q8f5;M%x$SdAkd9FAvlc$ zx660V9e3Ox@4WZ^?7jZ%QFGU-T~%||Ug4iK6bbQY@zBuF2$hxOw9wF=A)nUSxR_5@ zEX>HBryGrjyuOFFv$Y4<+|3H@gQfEqD<)+}a~mryD|1U9*I_FOG&F%+Ww{SJ-V2BR zjt<81Ek$}Yb*95D4RS0HCps|uLyovt;P05hchQb-u2bzLtmog&f2}1VlNhxXV);S9 zM2buBg~!q9PtF)&KGRgf3#z7B(hm5WlNClaCWFs!-P!4-u*u5+=+D|ZE9e`KvhTHT zJBnLwGM%!u&vlE%1ytJ=!xt~y_YkFLQb6bS!E+s8l7PiPGSt9xrmg?LV&&SL?J~cI zS(e9TF1?SGyh+M_p@o1dyWu7o7_6p;N6hO!;4~ z2B`I;y`;$ZdtBpvK5%oQ^p4eR2L)BH>B$FQeC*t)c`L71gXHPUa|vyu`Bnz)H$ZcXGve(}XvR!+*8a>BLV;+ryG1kt0=)ytl zNJxFUN{V7P?#|Cp85QTa@(*Q3%K-R(Pkv1N8YU*(d(Y}9?PQ(j;NzWoEVWRD-~H$=f>j9~PN^BM2okI(gY-&_&BCV6RP&I$FnSEM3d=0fCxbxA6~l>54-upTrw zYgX@%m>jsSGi`0cQt6b8cX~+02IghVlNblR7eI;0ps}mpWUcxty1yG56C5rh%ep(X z?)#2d?C<4t-KLc*EAn>>M8%HvC1TyBSoPNg(4id~H8JwO#I)Bf;N*y6ai6K9_bA`4 z_g9(-R;qyH&6I$`b42v|0V3Z8IXN*p*8g$gE98+JpXNY+jXxU0zsR^W$#V=KP z3AEFp@OL}WqwOfsV<)A^UTF4&HF1vQecz?LWE@p^Z2){=KEC_3Iopx_eS42>DeiDG zWMXGbYfG~W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z61w35^sN1=IFw&Oc!Nah+8@qhJ0UEGr;JplaxOGI82OVqZHsqfX ze1}r{jy;G?&}Da}a7>SCDsFDuzuseeCKof|Dz2BPsP8? zY;a)Tkr2P~0^2BeO?wnzF_Ul-ekY=-w26VnU%U3f19Z-pj&2 z4J_a|o4Dci+MO)mPQIM>kdPG1xydiR9@#8m zh27D7GF{p|a{8({Q-Pr-;#jV{2zHR>lGoFtIfIpoMo?exuQyX_A;;l0AP4!)JEM$EwMInZkj+8*IHP4vKRd zKx_l-i*>A*C@{u%ct`y~s6MWAfO{@FPIX&sg8H{GMDc{4M3%$@c8&RAlw0-R<4DO3 trJqdc$mBpWeznn?E0M$F`|3v=`3%T2A17h;rxP7$%JLd=6(2u;`(N3pt&so# literal 0 HcmV?d00001 diff --git a/index.html b/index.html new file mode 100644 index 0000000..a445ae2 --- /dev/null +++ b/index.html @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + +
+
+

+ + glowing bear + + WeeChat web frontend + +

+
To start using, please enable relay in your WeeChat client: +
+/set relay.network.password yourpassword
+/relay add weechat 9001
+ Note: The communication goes directly between your browser and your weechat in clear text. + Connection settings are saved between sessions, including password, in your own browser. +
+

Connection settings

+
+
+ Oh no! We cannot connect! +
+
+ + +

Enter the hostname and the port to the WeeChat relay, separated by a :

+
+
+ + +

Password will be stored in your browser session

+
+
+ + +

Default is fine.

+
+ +
+
+
+ +
+
+ + {{ bufferline.date | date:'HH:mm' }} + + + + {{ part.text }} + + + +
+
+ + +
+
+ + diff --git a/js/angular.min.js b/js/angular.min.js new file mode 100644 index 0000000..569325c --- /dev/null +++ b/js/angular.min.js @@ -0,0 +1,160 @@ +/* + AngularJS v1.0.4 + (c) 2010-2012 Google, Inc. http://angularjs.org + License: MIT +*/ +(function(T,Y,p){'use strict';function m(b,a,c){var d;if(b)if(L(b))for(d in b)d!="prototype"&&d!="length"&&d!="name"&&b.hasOwnProperty(d)&&a.call(c,b[d],d);else if(b.forEach&&b.forEach!==m)b.forEach(a,c);else if(M(b)&&va(b.length))for(d=0;d=0&&b.splice(c,1);return a}function U(b,a){if(oa(b)||b&&b.$evalAsync&&b.$watch)throw u("Can't copy Window or Scope");if(a){if(b===a)throw u("Can't copy equivalent objects or arrays");if(I(b)){for(;a.length;)a.pop();for(var c=0;c2?ia.call(arguments,2):[];return L(a)&&!(a instanceof RegExp)?c.length?function(){return arguments.length?a.apply(b,c.concat(ia.call(arguments,0))):a.apply(b,c)}:function(){return arguments.length?a.apply(b, +arguments):a.call(b)}:a}function ic(b,a){var c=a;/^\$+/.test(b)?c=p:oa(a)?c="$WINDOW":a&&Y===a?c="$DOCUMENT":a&&a.$evalAsync&&a.$watch&&(c="$SCOPE");return c}function da(b,a){return JSON.stringify(b,ic,a?" ":null)}function ob(b){return E(b)?JSON.parse(b):b}function Wa(b){b&&b.length!==0?(b=D(""+b),b=!(b=="f"||b=="0"||b=="false"||b=="no"||b=="n"||b=="[]")):b=!1;return b}function pa(b){b=z(b).clone();try{b.html("")}catch(a){}return z("
").append(b).html().match(/^(<[^>]+>)/)[1].replace(/^<([\w\-]+)/, +function(a,b){return"<"+D(b)})}function Xa(b){var a={},c,d;m((b||"").split("&"),function(b){b&&(c=b.split("="),d=decodeURIComponent(c[0]),a[d]=v(c[1])?decodeURIComponent(c[1]):!0)});return a}function pb(b){var a=[];m(b,function(b,d){a.push(Ya(d,!0)+(b===!0?"":"="+Ya(b,!0)))});return a.length?a.join("&"):""}function Za(b){return Ya(b,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+")}function Ya(b,a){return encodeURIComponent(b).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g, +"$").replace(/%2C/gi,",").replace(a?null:/%20/g,"+")}function jc(b,a){function c(a){a&&d.push(a)}var d=[b],e,g,i=["ng:app","ng-app","x-ng-app","data-ng-app"],f=/\sng[:\-]app(:\s*([\w\d_]+);?)?\s/;m(i,function(a){i[a]=!0;c(Y.getElementById(a));a=a.replace(":","\\:");b.querySelectorAll&&(m(b.querySelectorAll("."+a),c),m(b.querySelectorAll("."+a+"\\:"),c),m(b.querySelectorAll("["+a+"]"),c))});m(d,function(a){if(!e){var b=f.exec(" "+a.className+" ");b?(e=a,g=(b[2]||"").replace(/\s+/g,",")):m(a.attributes, +function(b){if(!e&&i[b.name])e=a,g=b.value})}});e&&a(e,g?[g]:[])}function qb(b,a){b=z(b);a=a||[];a.unshift(["$provide",function(a){a.value("$rootElement",b)}]);a.unshift("ng");var c=rb(a);c.invoke(["$rootScope","$rootElement","$compile","$injector",function(a,b,c,i){a.$apply(function(){b.data("$injector",i);c(b)(a)})}]);return c}function $a(b,a){a=a||"_";return b.replace(kc,function(b,d){return(d?a:"")+b.toLowerCase()})}function ab(b,a,c){if(!b)throw new u("Argument '"+(a||"?")+"' is "+(c||"required")); +return b}function qa(b,a,c){c&&I(b)&&(b=b[b.length-1]);ab(L(b),a,"not a function, got "+(b&&typeof b=="object"?b.constructor.name||"Object":typeof b));return b}function lc(b){function a(a,b,e){return a[b]||(a[b]=e())}return a(a(b,"angular",Object),"module",function(){var b={};return function(d,e,g){e&&b.hasOwnProperty(d)&&(b[d]=null);return a(b,d,function(){function a(c,d,e){return function(){b[e||"push"]([c,d,arguments]);return k}}if(!e)throw u("No module: "+d);var b=[],c=[],j=a("$injector","invoke"), +k={_invokeQueue:b,_runBlocks:c,requires:e,name:d,provider:a("$provide","provider"),factory:a("$provide","factory"),service:a("$provide","service"),value:a("$provide","value"),constant:a("$provide","constant","unshift"),filter:a("$filterProvider","register"),controller:a("$controllerProvider","register"),directive:a("$compileProvider","directive"),config:j,run:function(a){c.push(a);return this}};g&&j(g);return k})}})}function sb(b){return b.replace(mc,function(a,b,d,e){return e?d.toUpperCase():d}).replace(nc, +"Moz$1")}function bb(b,a){function c(){var e;for(var b=[this],c=a,i,f,h,j,k,l;b.length;){i=b.shift();f=0;for(h=i.length;f-1}function wb(b,a){a&&m(a.split(" "),function(a){b.className=Q((" "+b.className+" ").replace(/[\n\t]/g," ").replace(" "+Q(a)+" "," "))})}function xb(b,a){a&&m(a.split(" "), +function(a){if(!Ba(b,a))b.className=Q(b.className+" "+Q(a))})}function cb(b,a){if(a)for(var a=!a.nodeName&&v(a.length)&&!oa(a)?a:[a],c=0;c4096&&c.warn("Cookie '"+a+"' possibly not set or overflowed because it was too large ("+d+" > 4096 bytes)!")}else{if(h.cookie!==P){P=h.cookie;d=P.split("; ");ba={};for(f=0;f0&&(ba[unescape(e.substring(0,j))]=unescape(e.substring(j+1)))}return ba}};f.defer=function(a,b){var c;n++;c=l(function(){delete r[c]; +e(a)},b||0);r[c]=!0;return c};f.defer.cancel=function(a){return r[a]?(delete r[a],o(a),e(C),!0):!1}}function wc(){this.$get=["$window","$log","$sniffer","$document",function(b,a,c,d){return new vc(b,d,a,c)}]}function xc(){this.$get=function(){function b(b,d){function e(a){if(a!=l){if(o){if(o==a)o=a.n}else o=a;g(a.n,a.p);g(a,l);l=a;l.n=null}}function g(a,b){if(a!=b){if(a)a.p=b;if(b)b.n=a}}if(b in a)throw u("cacheId "+b+" taken");var i=0,f=y({},d,{id:b}),h={},j=d&&d.capacity||Number.MAX_VALUE,k={}, +l=null,o=null;return a[b]={put:function(a,b){var c=k[a]||(k[a]={key:a});e(c);t(b)||(a in h||i++,h[a]=b,i>j&&this.remove(o.key))},get:function(a){var b=k[a];if(b)return e(b),h[a]},remove:function(a){var b=k[a];if(b){if(b==l)l=b.p;if(b==o)o=b.n;g(b.n,b.p);delete k[a];delete h[a];i--}},removeAll:function(){h={};i=0;k={};l=o=null},destroy:function(){k=f=h=null;delete a[b]},info:function(){return y({},f,{size:i})}}}var a={};b.info=function(){var b={};m(a,function(a,e){b[e]=a.info()});return b};b.get=function(b){return a[b]}; +return b}}function yc(){this.$get=["$cacheFactory",function(b){return b("templates")}]}function Cb(b){var a={},c="Directive",d=/^\s*directive\:\s*([\d\w\-_]+)\s+(.*)$/,e=/(([\d\w\-_]+)(?:\:([^;]+))?;?)/,g="Template must have exactly one root element. was: ";this.directive=function f(d,e){E(d)?(ab(e,"directive"),a.hasOwnProperty(d)||(a[d]=[],b.factory(d+c,["$injector","$exceptionHandler",function(b,c){var e=[];m(a[d],function(a){try{var f=b.invoke(a);if(L(f))f={compile:H(f)};else if(!f.compile&&f.link)f.compile= +H(f.link);f.priority=f.priority||0;f.name=f.name||d;f.require=f.require||f.controller&&f.name;f.restrict=f.restrict||"A";e.push(f)}catch(j){c(j)}});return e}])),a[d].push(e)):m(d,nb(f));return this};this.$get=["$injector","$interpolate","$exceptionHandler","$http","$templateCache","$parse","$controller","$rootScope",function(b,h,j,k,l,o,r,n){function w(a,b,c){a instanceof z||(a=z(a));m(a,function(b,c){b.nodeType==3&&b.nodeValue.match(/\S+/)&&(a[c]=z(b).wrap("").parent()[0])});var d=x(a, +b,a,c);return function(b,c){ab(b,"scope");var e=c?ta.clone.call(a):a;e.data("$scope",b);q(e,"ng-scope");c&&c(e,b);d&&d(b,e,e);return e}}function q(a,b){try{a.addClass(b)}catch(c){}}function x(a,b,c,d){function e(a,c,d,j){var g,h,k,n,o,l,r,q=[];o=0;for(l=c.length;oB.priority)break;if(W=B.scope)K("isolated scope",A,B,s),M(W)&&(q(s,"ng-isolate-scope"),A=B),q(s,"ng-scope"),x=x||B;G= +B.name;if(W=B.controller)t=t||{},K("'"+G+"' controller",t[G],B,s),t[G]=B;if(W=B.transclude)K("transclusion",C,B,s),C=B,n=B.priority,W=="element"?(V=z(b),s=c.$$element=z(Y.createComment(" "+G+": "+c[G]+" ")),b=s[0],Fa(e,z(V[0]),b),v=w(V,d,n)):(V=z(db(b)).contents(),s.html(""),v=w(V,d));if(W=B.template)if(K("template",P,B,s),P=B,W=Ha(W),B.replace){V=z("
"+Q(W)+"
").contents();b=V[0];if(V.length!=1||b.nodeType!==1)throw new u(g+W);Fa(e,s,b);G={$attr:{}};a=a.concat(X(b,a.splice(D+1,a.length- +(D+1)),G));J(c,G);F=a.length}else s.html(W);if(B.templateUrl)K("template",P,B,s),P=B,k=ba(a.splice(D,a.length-D),k,s,c,e,B.replace,v),F=a.length;else if(B.compile)try{y=B.compile(s,c,v),L(y)?f(null,y):y&&f(y.pre,y.post)}catch(H){j(H,pa(s))}if(B.terminal)k.terminal=!0,n=Math.max(n,B.priority)}k.scope=x&&x.scope;k.transclude=C&&v;return k}function s(d,e,g,h){var k=!1;if(a.hasOwnProperty(e))for(var n,e=b.get(e+c),o=0,l=e.length;on.priority)&&n.restrict.indexOf(g)!=-1)d.push(n), +k=!0}catch(r){j(r)}return k}function J(a,b){var c=b.$attr,d=a.$attr,e=a.$$element;m(a,function(d,e){e.charAt(0)!="$"&&(b[e]&&(d+=(e==="style"?";":" ")+b[e]),a.$set(e,d,!0,c[e]))});m(b,function(b,f){f=="class"?(q(e,b),a["class"]=(a["class"]?a["class"]+" ":"")+b):f=="style"?e.attr("style",e.attr("style")+";"+b):f.charAt(0)!="$"&&!a.hasOwnProperty(f)&&(a[f]=b,d[f]=c[f])})}function ba(a,b,c,d,e,f,j){var h=[],n,o,r=c[0],q=a.shift(),w=y({},q,{controller:null,templateUrl:null,transclude:null,scope:null}); +c.html("");k.get(q.templateUrl,{cache:l}).success(function(k){var l,q,k=Ha(k);if(f){q=z("
"+Q(k)+"
").contents();l=q[0];if(q.length!=1||l.nodeType!==1)throw new u(g+k);k={$attr:{}};Fa(e,c,l);X(l,a,k);J(d,k)}else l=r,c.html(k);a.unshift(w);n=A(a,c,d,j);for(o=x(c.contents(),j);h.length;){var ca=h.pop(),k=h.pop();q=h.pop();var s=h.pop(),m=l;q!==r&&(m=db(l),Fa(k,z(q),m));n(function(){b(o,s,m,e,ca)},s,m,e,ca)}h=null}).error(function(a,b,c,d){throw u("Failed to load template: "+d.url);});return function(a, +c,d,e,f){h?(h.push(c),h.push(d),h.push(e),h.push(f)):n(function(){b(o,c,d,e,f)},c,d,e,f)}}function P(a,b){return b.priority-a.priority}function K(a,b,c,d){if(b)throw u("Multiple directives ["+b.name+", "+c.name+"] asking for "+a+" on: "+pa(d));}function G(a,b){var c=h(b,!0);c&&a.push({priority:0,compile:H(function(a,b){var d=b.parent(),e=d.data("$binding")||[];e.push(c);q(d.data("$binding",e),"ng-binding");a.$watch(c,function(a){b[0].nodeValue=a})})})}function V(a,b,c,d){var e=h(c,!0);e&&b.push({priority:100, +compile:H(function(a,b,c){b=c.$$observers||(c.$$observers={});d==="class"&&(e=h(c[d],!0));c[d]=p;(b[d]||(b[d]=[])).$$inter=!0;(c.$$observers&&c.$$observers[d].$$scope||a).$watch(e,function(a){c.$set(d,a)})})})}function Fa(a,b,c){var d=b[0],e=d.parentNode,f,g;if(a){f=0;for(g=a.length;f0){var e=K[0],f=e.text;if(f==a||f==b||f==c||f==d||!a&&!b&&!c&&!d)return e}return!1}function f(b,c, +d,f){return(b=i(b,c,d,f))?(a&&!b.json&&e("is not valid json",b),K.shift(),b):!1}function h(a){f(a)||e("is unexpected, expecting ["+a+"]",i())}function j(a,b){return function(c,d){return a(c,d,b)}}function k(a,b,c){return function(d,e){return b(d,e,a,c)}}function l(){for(var a=[];;)if(K.length>0&&!i("}",")",";","]")&&a.push(v()),!f(";"))return a.length==1?a[0]:function(b,c){for(var d,e=0;e","<=",">="))a=k(a,b.fn,q());return a}function x(){for(var a=m(),b;b=f("*","/","%");)a=k(a, +b.fn,m());return a}function m(){var a;return f("+")?A():(a=f("-"))?k(ba,a.fn,m()):(a=f("!"))?j(a.fn,m()):A()}function A(){var a;if(f("("))a=v(),h(")");else if(f("["))a=s();else if(f("{"))a=J();else{var b=f();(a=b.fn)||e("not a primary expression",b)}for(var c;b=f("(","[",".");)b.text==="("?(a=z(a,c),c=null):b.text==="["?(c=a,a=ea(a)):b.text==="."?(c=a,a=t(a)):e("IMPOSSIBLE");return a}function s(){var a=[];if(g().text!="]"){do a.push(G());while(f(","))}h("]");return function(b,c){for(var d=[],e=0;e< +a.length;e++)d.push(a[e](b,c));return d}}function J(){var a=[];if(g().text!="}"){do{var b=f(),b=b.string||b.text;h(":");var c=G();a.push({key:b,value:c})}while(f(","))}h("}");return function(b,c){for(var d={},e=0;e1;d++){var e=a.shift(),g=b[e];g||(g={},b[e]=g);b=g}return b[a.shift()]=c}function gb(b,a,c){if(!a)return b;for(var a=a.split("."),d,e=b,g=a.length,i=0;i7),hasEvent:function(c){if(c=="input"&&aa==9)return!1;if(t(a[c])){var e=b.document.createElement("div");a[c]="on"+c in e}return a[c]},csp:!1}}]}function Tc(){this.$get=H(T)}function Nb(b){var a={},c,d,e;if(!b)return a;m(b.split("\n"),function(b){e=b.indexOf(":");c=D(Q(b.substr(0,e)));d=Q(b.substr(e+1));c&&(a[c]?a[c]+=", "+d:a[c]=d)});return a}function Ob(b){var a=M(b)?b:p;return function(c){a||(a=Nb(b));return c? +a[D(c)]||null:a}}function Pb(b,a,c){if(L(c))return c(b,a);m(c,function(c){b=c(b,a)});return b}function Uc(){var b=/^\s*(\[|\{[^\{])/,a=/[\}\]]\s*$/,c=/^\)\]\}',?\n/,d=this.defaults={transformResponse:[function(d){E(d)&&(d=d.replace(c,""),b.test(d)&&a.test(d)&&(d=ob(d,!0)));return d}],transformRequest:[function(a){return M(a)&&Sa.apply(a)!=="[object File]"?da(a):a}],headers:{common:{Accept:"application/json, text/plain, */*","X-Requested-With":"XMLHttpRequest"},post:{"Content-Type":"application/json;charset=utf-8"}, +put:{"Content-Type":"application/json;charset=utf-8"}}},e=this.responseInterceptors=[];this.$get=["$httpBackend","$browser","$cacheFactory","$rootScope","$q","$injector",function(a,b,c,h,j,k){function l(a){function c(a){var b=y({},a,{data:Pb(a.data,a.headers,f)});return 200<=a.status&&a.status<300?b:j.reject(b)}a.method=la(a.method);var e=a.transformRequest||d.transformRequest,f=a.transformResponse||d.transformResponse,h=d.headers,h=y({"X-XSRF-TOKEN":b.cookies()["XSRF-TOKEN"]},h.common,h[D(a.method)], +a.headers),e=Pb(a.data,Ob(h),e),g;t(a.data)&&delete h["Content-Type"];g=o(a,e,h);g=g.then(c,c);m(w,function(a){g=a(g)});g.success=function(b){g.then(function(c){b(c.data,c.status,c.headers,a)});return g};g.error=function(b){g.then(null,function(c){b(c.data,c.status,c.headers,a)});return g};return g}function o(b,c,d){function e(a,b,c){m&&(200<=a&&a<300?m.put(w,[a,b,Nb(c)]):m.remove(w));f(b,a,c);h.$apply()}function f(a,c,d){c=Math.max(c,0);(200<=c&&c<300?k.resolve:k.reject)({data:a,status:c,headers:Ob(d), +config:b})}function i(){var a=ya(l.pendingRequests,b);a!==-1&&l.pendingRequests.splice(a,1)}var k=j.defer(),o=k.promise,m,p,w=r(b.url,b.params);l.pendingRequests.push(b);o.then(i,i);b.cache&&b.method=="GET"&&(m=M(b.cache)?b.cache:n);if(m)if(p=m.get(w))if(p.then)return p.then(i,i),p;else I(p)?f(p[1],p[0],U(p[2])):f(p,200,{});else m.put(w,o);p||a(b.method,w,c,e,d,b.timeout,b.withCredentials);return o}function r(a,b){if(!b)return a;var c=[];fc(b,function(a,b){a==null||a==p||(M(a)&&(a=da(a)),c.push(encodeURIComponent(b)+ +"="+encodeURIComponent(a)))});return a+(a.indexOf("?")==-1?"?":"&")+c.join("&")}var n=c("$http"),w=[];m(e,function(a){w.push(E(a)?k.get(a):k.invoke(a))});l.pendingRequests=[];(function(a){m(arguments,function(a){l[a]=function(b,c){return l(y(c||{},{method:a,url:b}))}})})("get","delete","head","jsonp");(function(a){m(arguments,function(a){l[a]=function(b,c,d){return l(y(d||{},{method:a,url:b,data:c}))}})})("post","put");l.defaults=d;return l}]}function Vc(){this.$get=["$browser","$window","$document", +function(b,a,c){return Wc(b,Xc,b.defer,a.angular.callbacks,c[0],a.location.protocol.replace(":",""))}]}function Wc(b,a,c,d,e,g){function i(a,b){var c=e.createElement("script"),d=function(){e.body.removeChild(c);b&&b()};c.type="text/javascript";c.src=a;aa?c.onreadystatechange=function(){/loaded|complete/.test(c.readyState)&&d()}:c.onload=c.onerror=d;e.body.appendChild(c)}return function(e,h,j,k,l,o,r){function n(a,c,d,e){c=(h.match(Gb)||["",g])[1]=="file"?d?200:404:c;a(c==1223?204:c,d,e);b.$$completeOutstandingRequest(C)} +b.$$incOutstandingRequestCount();h=h||b.url();if(D(e)=="jsonp"){var p="_"+(d.counter++).toString(36);d[p]=function(a){d[p].data=a};i(h.replace("JSON_CALLBACK","angular.callbacks."+p),function(){d[p].data?n(k,200,d[p].data):n(k,-2);delete d[p]})}else{var q=new a;q.open(e,h,!0);m(l,function(a,b){a&&q.setRequestHeader(b,a)});var x;q.onreadystatechange=function(){q.readyState==4&&n(k,x||q.status,q.responseText,q.getAllResponseHeaders())};if(r)q.withCredentials=!0;q.send(j||"");o>0&&c(function(){x=-1; +q.abort()},o)}}}function Yc(){this.$get=function(){return{id:"en-us",NUMBER_FORMATS:{DECIMAL_SEP:".",GROUP_SEP:",",PATTERNS:[{minInt:1,minFrac:0,maxFrac:3,posPre:"",posSuf:"",negPre:"-",negSuf:"",gSize:3,lgSize:3},{minInt:1,minFrac:2,maxFrac:2,posPre:"\u00a4",posSuf:"",negPre:"(\u00a4",negSuf:")",gSize:3,lgSize:3}],CURRENCY_SYM:"$"},DATETIME_FORMATS:{MONTH:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),SHORTMONTH:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","), +DAY:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),SHORTDAY:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(","),AMPMS:["AM","PM"],medium:"MMM d, y h:mm:ss a","short":"M/d/yy h:mm a",fullDate:"EEEE, MMMM d, y",longDate:"MMMM d, y",mediumDate:"MMM d, y",shortDate:"M/d/yy",mediumTime:"h:mm:ss a",shortTime:"h:mm a"},pluralCat:function(b){return b===1?"one":"other"}}}}function Zc(){this.$get=["$rootScope","$browser","$q","$exceptionHandler",function(b,a,c,d){function e(e,f,h){var j=c.defer(), +k=j.promise,l=v(h)&&!h,f=a.defer(function(){try{j.resolve(e())}catch(a){j.reject(a),d(a)}l||b.$apply()},f),h=function(){delete g[k.$$timeoutId]};k.$$timeoutId=f;g[f]=j;k.then(h,h);return k}var g={};e.cancel=function(b){return b&&b.$$timeoutId in g?(g[b.$$timeoutId].reject("canceled"),a.defer.cancel(b.$$timeoutId)):!1};return e}]}function Qb(b){function a(a,e){return b.factory(a+c,e)}var c="Filter";this.register=a;this.$get=["$injector",function(a){return function(b){return a.get(b+c)}}];a("currency", +Rb);a("date",Sb);a("filter",$c);a("json",ad);a("limitTo",bd);a("lowercase",cd);a("number",Tb);a("orderBy",Ub);a("uppercase",dd)}function $c(){return function(b,a){if(!(b instanceof Array))return b;var c=[];c.check=function(a){for(var b=0;b-1;case "object":for(var c in a)if(c.charAt(0)!=="$"&& +d(a[c],b))return!0;return!1;case "array":for(c=0;ce+1?i="0":(f=i,j=!0)}if(!j){i= +(i.split(Wb)[1]||"").length;t(e)&&(e=Math.min(Math.max(a.minFrac,i),a.maxFrac));var i=Math.pow(10,e),b=Math.round(b*i)/i,b=(""+b).split(Wb),i=b[0],b=b[1]||"",j=0,k=a.lgSize,l=a.gSize;if(i.length>=k+l)for(var j=i.length-k,o=0;o0||e>-c)e+=c;e===0&&c==-12&&(e=12);return jb(e,a,d)}}function La(b,a){return function(c,d){var e=c["get"+b](),g=la(a?"SHORT"+b:b);return d[g][e]}}function Sb(b){function a(a){var b;if(b=a.match(c)){var a=new Date(0),g=0,i=0;b[9]&&(g=F(b[9]+b[10]),i=F(b[9]+b[11]));a.setUTCFullYear(F(b[1]),F(b[2])-1,F(b[3]));a.setUTCHours(F(b[4]||0)-g,F(b[5]||0)-i,F(b[6]|| +0),F(b[7]||0))}return a}var c=/^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;return function(c,e){var g="",i=[],f,h,e=e||"mediumDate",e=b.DATETIME_FORMATS[e]||e;E(c)&&(c=ed.test(c)?F(c):a(c));va(c)&&(c=new Date(c));if(!na(c))return c;for(;e;)(h=fd.exec(e))?(i=i.concat(ia.call(h,1)),e=i.pop()):(i.push(e),e=null);m(i,function(a){f=gd[a];g+=f?f(c,b.DATETIME_FORMATS):a.replace(/(^'|'$)/g,"").replace(/''/g,"'")});return g}}function ad(){return function(b){return da(b, +!0)}}function bd(){return function(b,a){if(!(b instanceof Array))return b;var a=F(a),c=[],d,e;if(!b||!(b instanceof Array))return c;a>b.length?a=b.length:a<-b.length&&(a=-b.length);a>0?(d=0,e=a):(d=b.length+a,e=b.length);for(;dl?(d.$setValidity("maxlength",!1),p):(d.$setValidity("maxlength",!0),a)};d.$parsers.push(c);d.$formatters.push(c)}}function kb(b,a){b="ngClass"+b;return R(function(c,d,e){function g(b, +d){if(a===!0||c.$index%2===a)d&&b!==d&&i(d),f(b)}function i(a){M(a)&&!I(a)&&(a=Ta(a,function(a,b){if(a)return b}));d.removeClass(I(a)?a.join(" "):a)}function f(a){M(a)&&!I(a)&&(a=Ta(a,function(a,b){if(a)return b}));a&&d.addClass(I(a)?a.join(" "):a)}c.$watch(e[b],g,!0);e.$observe("class",function(){var a=c.$eval(e[b]);g(a,a)});b!=="ngClass"&&c.$watch("$index",function(d,g){var k=d%2;k!==g%2&&(k==a?f(c.$eval(e[b])):i(c.$eval(e[b])))})})}var D=function(b){return E(b)?b.toLowerCase():b},la=function(b){return E(b)? +b.toUpperCase():b},u=T.Error,aa=F((/msie (\d+)/.exec(D(navigator.userAgent))||[])[1]),z,ja,ia=[].slice,Ra=[].push,Sa=Object.prototype.toString,Zb=T.angular||(T.angular={}),sa,Db,Z=["0","0","0"];C.$inject=[];ma.$inject=[];Db=aa<9?function(b){b=b.nodeName?b:b[0];return b.scopeName&&b.scopeName!="HTML"?la(b.scopeName+":"+b.nodeName):b.nodeName}:function(b){return b.nodeName?b.nodeName:b[0].nodeName};var kc=/[A-Z]/g,hd={full:"1.0.4",major:1,minor:0,dot:4,codeName:"bewildering-hair"},Aa=O.cache={},za= +O.expando="ng-"+(new Date).getTime(),oc=1,$b=T.document.addEventListener?function(b,a,c){b.addEventListener(a,c,!1)}:function(b,a,c){b.attachEvent("on"+a,c)},eb=T.document.removeEventListener?function(b,a,c){b.removeEventListener(a,c,!1)}:function(b,a,c){b.detachEvent("on"+a,c)},mc=/([\:\-\_]+(.))/g,nc=/^moz([A-Z])/,ta=O.prototype={ready:function(b){function a(){c||(c=!0,b())}var c=!1;this.bind("DOMContentLoaded",a);O(T).bind("load",a)},toString:function(){var b=[];m(this,function(a){b.push(""+a)}); +return"["+b.join(", ")+"]"},eq:function(b){return b>=0?z(this[b]):z(this[this.length+b])},length:0,push:Ra,sort:[].sort,splice:[].splice},Da={};m("multiple,selected,checked,disabled,readOnly,required".split(","),function(b){Da[D(b)]=b});var Ab={};m("input,select,option,textarea,button,form".split(","),function(b){Ab[la(b)]=!0});m({data:vb,inheritedData:Ca,scope:function(b){return Ca(b,"$scope")},controller:yb,injector:function(b){return Ca(b,"$injector")},removeAttr:function(b,a){b.removeAttribute(a)}, +hasClass:Ba,css:function(b,a,c){a=sb(a);if(v(c))b.style[a]=c;else{var d;aa<=8&&(d=b.currentStyle&&b.currentStyle[a],d===""&&(d="auto"));d=d||b.style[a];aa<=8&&(d=d===""?p:d);return d}},attr:function(b,a,c){var d=D(a);if(Da[d])if(v(c))c?(b[a]=!0,b.setAttribute(a,d)):(b[a]=!1,b.removeAttribute(d));else return b[a]||(b.attributes.getNamedItem(a)||C).specified?d:p;else if(v(c))b.setAttribute(a,c);else if(b.getAttribute)return b=b.getAttribute(a,2),b===null?p:b},prop:function(b,a,c){if(v(c))b[a]=c;else return b[a]}, +text:y(aa<9?function(b,a){if(b.nodeType==1){if(t(a))return b.innerText;b.innerText=a}else{if(t(a))return b.nodeValue;b.nodeValue=a}}:function(b,a){if(t(a))return b.textContent;b.textContent=a},{$dv:""}),val:function(b,a){if(t(a))return b.value;b.value=a},html:function(b,a){if(t(a))return b.innerHTML;for(var c=0,d=b.childNodes;c":function(a,c,d,e){return d(a,c)>e(a,c)},"<=":function(a,c,d,e){return d(a,c)<=e(a,c)},">=":function(a,c,d,e){return d(a,c)>=e(a,c)},"&&":function(a,c,d,e){return d(a,c)&&e(a,c)},"||":function(a,c,d,e){return d(a,c)||e(a,c)}, +"&":function(a,c,d,e){return d(a,c)&e(a,c)},"|":function(a,c,d,e){return e(a,c)(a,c,d(a,c))},"!":function(a,c,d){return!d(a,c)}},Kc={n:"\n",f:"\u000c",r:"\r",t:"\t",v:"\u000b","'":"'",'"':'"'},ib={},Xc=T.XMLHttpRequest||function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(c){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(d){}throw new u("This browser does not support XMLHttpRequest.");};Qb.$inject=["$provide"];Rb.$inject= +["$locale"];Tb.$inject=["$locale"];var Wb=".",gd={yyyy:N("FullYear",4),yy:N("FullYear",2,0,!0),y:N("FullYear",1),MMMM:La("Month"),MMM:La("Month",!0),MM:N("Month",2,1),M:N("Month",1,1),dd:N("Date",2),d:N("Date",1),HH:N("Hours",2),H:N("Hours",1),hh:N("Hours",2,-12),h:N("Hours",1,-12),mm:N("Minutes",2),m:N("Minutes",1),ss:N("Seconds",2),s:N("Seconds",1),EEEE:La("Day"),EEE:La("Day",!0),a:function(a,c){return a.getHours()<12?c.AMPMS[0]:c.AMPMS[1]},Z:function(a){a=a.getTimezoneOffset();return jb(a/60,2)+ +jb(Math.abs(a%60),2)}},fd=/((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,ed=/^\d+$/;Sb.$inject=["$locale"];var cd=H(D),dd=H(la);Ub.$inject=["$parse"];var id=H({restrict:"E",compile:function(a,c){c.href||c.$set("href","");return function(a,c){c.bind("click",function(a){c.attr("href")||a.preventDefault()})}}}),lb={};m(Da,function(a,c){var d=fa("ng-"+c);lb[d]=function(){return{priority:100,compile:function(){return function(a,g,i){a.$watch(i[d],function(a){i.$set(c,!!a)})}}}}}); +m(["src","href"],function(a){var c=fa("ng-"+a);lb[c]=function(){return{priority:99,link:function(d,e,g){g.$observe(c,function(c){c&&(g.$set(a,c),aa&&e.prop(a,c))})}}}});var Oa={$addControl:C,$removeControl:C,$setValidity:C,$setDirty:C};Xb.$inject=["$element","$attrs","$scope"];var Ra=function(a){return["$timeout",function(c){var d={name:"form",restrict:"E",controller:Xb,compile:function(){return{pre:function(a,d,i,f){if(!i.action){var h=function(a){a.preventDefault?a.preventDefault():a.returnValue= +!1};$b(d[0],"submit",h);d.bind("$destroy",function(){c(function(){eb(d[0],"submit",h)},0,!1)})}var j=d.parent().controller("form"),k=i.name||i.ngForm;k&&(a[k]=f);j&&d.bind("$destroy",function(){j.$removeControl(f);k&&(a[k]=p);y(f,Oa)})}}}};return a?y(U(d),{restrict:"EAC"}):d}]},jd=Ra(),kd=Ra(!0),ld=/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/,md=/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/,nd=/^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/,bc={text:Qa,number:function(a, +c,d,e,g,i){Qa(a,c,d,e,g,i);e.$parsers.push(function(a){var c=S(a);return c||nd.test(a)?(e.$setValidity("number",!0),a===""?null:c?a:parseFloat(a)):(e.$setValidity("number",!1),p)});e.$formatters.push(function(a){return S(a)?"":""+a});if(d.min){var f=parseFloat(d.min),a=function(a){return!S(a)&&ah?(e.$setValidity("max",!1),p):(e.$setValidity("max", +!0),a)};e.$parsers.push(d);e.$formatters.push(d)}e.$formatters.push(function(a){return S(a)||va(a)?(e.$setValidity("number",!0),a):(e.$setValidity("number",!1),p)})},url:function(a,c,d,e,g,i){Qa(a,c,d,e,g,i);a=function(a){return S(a)||ld.test(a)?(e.$setValidity("url",!0),a):(e.$setValidity("url",!1),p)};e.$formatters.push(a);e.$parsers.push(a)},email:function(a,c,d,e,g,i){Qa(a,c,d,e,g,i);a=function(a){return S(a)||md.test(a)?(e.$setValidity("email",!0),a):(e.$setValidity("email",!1),p)};e.$formatters.push(a); +e.$parsers.push(a)},radio:function(a,c,d,e){t(d.name)&&c.attr("name",wa());c.bind("click",function(){c[0].checked&&a.$apply(function(){e.$setViewValue(d.value)})});e.$render=function(){c[0].checked=d.value==e.$viewValue};d.$observe("value",e.$render)},checkbox:function(a,c,d,e){var g=d.ngTrueValue,i=d.ngFalseValue;E(g)||(g=!0);E(i)||(i=!1);c.bind("click",function(){a.$apply(function(){e.$setViewValue(c[0].checked)})});e.$render=function(){c[0].checked=e.$viewValue};e.$formatters.push(function(a){return a=== +g});e.$parsers.push(function(a){return a?g:i})},hidden:C,button:C,submit:C,reset:C},cc=["$browser","$sniffer",function(a,c){return{restrict:"E",require:"?ngModel",link:function(d,e,g,i){i&&(bc[D(g.type)]||bc.text)(d,e,g,i,c,a)}}}],Na="ng-valid",Ma="ng-invalid",Pa="ng-pristine",Yb="ng-dirty",od=["$scope","$exceptionHandler","$attrs","$element","$parse",function(a,c,d,e,g){function i(a,c){c=c?"-"+$a(c,"-"):"";e.removeClass((a?Ma:Na)+c).addClass((a?Na:Ma)+c)}this.$modelValue=this.$viewValue=Number.NaN; +this.$parsers=[];this.$formatters=[];this.$viewChangeListeners=[];this.$pristine=!0;this.$dirty=!1;this.$valid=!0;this.$invalid=!1;this.$name=d.name;var f=g(d.ngModel),h=f.assign;if(!h)throw u(Eb+d.ngModel+" ("+pa(e)+")");this.$render=C;var j=e.inheritedData("$formController")||Oa,k=0,l=this.$error={};e.addClass(Pa);i(!0);this.$setValidity=function(a,c){if(l[a]!==!c){if(c){if(l[a]&&k--,!k)i(!0),this.$valid=!0,this.$invalid=!1}else i(!1),this.$invalid=!0,this.$valid=!1,k++;l[a]=!c;i(c,a);j.$setValidity(a, +c,this)}};this.$setViewValue=function(d){this.$viewValue=d;if(this.$pristine)this.$dirty=!0,this.$pristine=!1,e.removeClass(Pa).addClass(Yb),j.$setDirty();m(this.$parsers,function(a){d=a(d)});if(this.$modelValue!==d)this.$modelValue=d,h(a,d),m(this.$viewChangeListeners,function(a){try{a()}catch(d){c(d)}})};var o=this;a.$watch(function(){var c=f(a);if(o.$modelValue!==c){var d=o.$formatters,e=d.length;for(o.$modelValue=c;e--;)c=d[e](c);if(o.$viewValue!==c)o.$viewValue=c,o.$render()}})}],pd=function(){return{require:["ngModel", +"^?form"],controller:od,link:function(a,c,d,e){var g=e[0],i=e[1]||Oa;i.$addControl(g);c.bind("$destroy",function(){i.$removeControl(g)})}}},qd=H({require:"ngModel",link:function(a,c,d,e){e.$viewChangeListeners.push(function(){a.$eval(d.ngChange)})}}),dc=function(){return{require:"?ngModel",link:function(a,c,d,e){if(e){d.required=!0;var g=function(a){if(d.required&&(S(a)||a===!1))e.$setValidity("required",!1);else return e.$setValidity("required",!0),a};e.$formatters.push(g);e.$parsers.unshift(g); +d.$observe("required",function(){g(e.$viewValue)})}}}},rd=function(){return{require:"ngModel",link:function(a,c,d,e){var g=(a=/\/(.*)\//.exec(d.ngList))&&RegExp(a[1])||d.ngList||",";e.$parsers.push(function(a){var c=[];a&&m(a.split(g),function(a){a&&c.push(Q(a))});return c});e.$formatters.push(function(a){return I(a)?a.join(", "):p})}}},sd=/^(true|false|\d+)$/,td=function(){return{priority:100,compile:function(a,c){return sd.test(c.ngValue)?function(a,c,g){g.$set("value",a.$eval(g.ngValue))}:function(a, +c,g){a.$watch(g.ngValue,function(a){g.$set("value",a,!1)})}}}},ud=R(function(a,c,d){c.addClass("ng-binding").data("$binding",d.ngBind);a.$watch(d.ngBind,function(a){c.text(a==p?"":a)})}),vd=["$interpolate",function(a){return function(c,d,e){c=a(d.attr(e.$attr.ngBindTemplate));d.addClass("ng-binding").data("$binding",c);e.$observe("ngBindTemplate",function(a){d.text(a)})}}],wd=[function(){return function(a,c,d){c.addClass("ng-binding").data("$binding",d.ngBindHtmlUnsafe);a.$watch(d.ngBindHtmlUnsafe, +function(a){c.html(a||"")})}}],xd=kb("",!0),yd=kb("Odd",0),zd=kb("Even",1),Ad=R({compile:function(a,c){c.$set("ngCloak",p);a.removeClass("ng-cloak")}}),Bd=[function(){return{scope:!0,controller:"@"}}],Cd=["$sniffer",function(a){return{priority:1E3,compile:function(){a.csp=!0}}}],ec={};m("click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave".split(" "),function(a){var c=fa("ng-"+a);ec[c]=["$parse",function(d){return function(e,g,i){var f=d(i[c]);g.bind(D(a),function(a){e.$apply(function(){f(e, +{$event:a})})})}}]});var Dd=R(function(a,c,d){c.bind("submit",function(){a.$apply(d.ngSubmit)})}),Ed=["$http","$templateCache","$anchorScroll","$compile",function(a,c,d,e){return{restrict:"ECA",terminal:!0,compile:function(g,i){var f=i.ngInclude||i.src,h=i.onload||"",j=i.autoscroll;return function(g,i){var o=0,m,n=function(){m&&(m.$destroy(),m=null);i.html("")};g.$watch(f,function(f){var q=++o;f?a.get(f,{cache:c}).success(function(a){q===o&&(m&&m.$destroy(),m=g.$new(),i.html(a),e(i.contents())(m), +v(j)&&(!j||g.$eval(j))&&d(),m.$emit("$includeContentLoaded"),g.$eval(h))}).error(function(){q===o&&n()}):n()})}}}}],Fd=R({compile:function(){return{pre:function(a,c,d){a.$eval(d.ngInit)}}}}),Gd=R({terminal:!0,priority:1E3}),Hd=["$locale","$interpolate",function(a,c){var d=/{}/g;return{restrict:"EA",link:function(e,g,i){var f=i.count,h=g.attr(i.$attr.when),j=i.offset||0,k=e.$eval(h),l={},o=c.startSymbol(),r=c.endSymbol();m(k,function(a,e){l[e]=c(a.replace(d,o+f+"-"+j+r))});e.$watch(function(){var c= +parseFloat(e.$eval(f));return isNaN(c)?"":(k[c]||(c=a.pluralCat(c-j)),l[c](e,g,!0))},function(a){g.text(a)})}}}],Id=R({transclude:"element",priority:1E3,terminal:!0,compile:function(a,c,d){return function(a,c,i){var f=i.ngRepeat,i=f.match(/^\s*(.+)\s+in\s+(.*)\s*$/),h,j,k;if(!i)throw u("Expected ngRepeat in form of '_item_ in _collection_' but got '"+f+"'.");f=i[1];h=i[2];i=f.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/);if(!i)throw u("'item' in 'item in collection' should be identifier or (key, value) but got '"+ +f+"'.");j=i[3]||i[1];k=i[2];var l=new fb;a.$watch(function(a){var e,f,i=a.$eval(h),m=c,p=new fb,z,A,s,v,t,u;if(I(i))t=i||[];else{t=[];for(s in i)i.hasOwnProperty(s)&&s.charAt(0)!="$"&&t.push(s);t.sort()}z=t.length;e=0;for(f=t.length;ey;)v.pop().element.remove()}for(;s.length>w;)s.pop()[0].element.remove()}var i;if(!(i=w.match(d)))throw u("Expected ngOptions in form of '_select_ (as _label_)? for (_key_,)?_value_ in _collection_' but got '"+w+"'."); +var j=c(i[2]||i[1]),k=i[4]||i[6],l=i[5],m=c(i[3]||""),o=c(i[2]?i[1]:k),r=c(i[7]),s=[[{element:f,label:""}]];q&&(a(q)(e),q.removeClass("ng-scope"),q.remove());f.html("");f.bind("change",function(){e.$apply(function(){var a,c=r(e)||[],d={},h,i,j,m,q,t;if(n){i=[];m=0;for(t=s.length;m@charset "UTF-8";[ng\\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak{display:none;}ng\\:form{display:block;}'); diff --git a/js/localstorage.js b/js/localstorage.js new file mode 100644 index 0000000..a77db29 --- /dev/null +++ b/js/localstorage.js @@ -0,0 +1,113 @@ + +var ls = angular.module('localStorage',[]); + +ls.factory("$store",function($parse){ + /** + * Global Vars + */ + var storage = (typeof window.localStorage === 'undefined') ? undefined : window.localStorage, + supported = !(typeof storage == 'undefined' || typeof window.JSON == 'undefined'); + + var privateMethods = { + /** + * Pass any type of a string from the localStorage to be parsed so it returns a usable version (like an Object) + * @param res - a string that will be parsed for type + * @returns {*} - whatever the real type of stored value was + */ + parseValue: function(res) { + var val; + try { + val = JSON.parse(res); + if (typeof val == 'undefined'){ + val = res; + } + if (val == 'true'){ + val = true; + } + if (val == 'false'){ + val = false; + } + if (parseFloat(val) == val && !angular.isObject(val) ){ + val = parseFloat(val); + } + } catch(e){ + val = res; + } + return val; + } + }; + var publicMethods = { + /** + * Set - let's you set a new localStorage key pair set + * @param key - a string that will be used as the accessor for the pair + * @param value - the value of the localStorage item + * @returns {*} - will return whatever it is you've stored in the local storage + */ + set: function(key,value){ + if (!supported){ + try { + $.cookie(key, value); + return value; + } catch(e){ + console.log('Local Storage not supported, make sure you have the $.cookie supported.'); + } + } + var saver = JSON.stringify(value); + storage.setItem(key, saver); + return privateMethods.parseValue(saver); + }, + /** + * Get - let's you get the value of any pair you've stored + * @param key - the string that you set as accessor for the pair + * @returns {*} - Object,String,Float,Boolean depending on what you stored + */ + get: function(key){ + if (!supported){ + try { + return privateMethods.parseValue($.cookie(key)); + } catch(e){ + return null; + } + } + var item = storage.getItem(key); + return privateMethods.parseValue(item); + }, + /** + * Remove - let's you nuke a value from localStorage + * @param key - the accessor value + * @returns {boolean} - if everything went as planned + */ + remove: function(key) { + if (!supported){ + try { + $.cookie(key, null); + return true; + } catch(e){ + return false; + } + } + storage.removeItem(key); + return true; + }, + /** + * Bind - let's you directly bind a localStorage value to a $scope variable + * @param $scope - the current scope you want the variable available in + * @param key - the name of the variable you are binding + * @param def - the default value (OPTIONAL) + * @returns {*} - returns whatever the stored value is + */ + bind: function ($scope, key, def) { + def = def || ''; + if (!publicMethods.get(key)) { + publicMethods.set(key, def); + } + $parse(key).assign($scope, publicMethods.get(key)); + $scope.$watch(key, function (val) { + publicMethods.set(key, val); + }, true); + return publicMethods.get(key); + } + }; + return publicMethods; +}); + diff --git a/js/protocol.js b/js/protocol.js new file mode 100644 index 0000000..ea6dda8 --- /dev/null +++ b/js/protocol.js @@ -0,0 +1,180 @@ +var Protocol = function() { + var self = this; + + var getInfo = function() { + var info = {}; + info.key = getString(); + info.value = getString(); + return info; + }; + + var getHdata = function() { + var paths; + var count; + var objs = []; + var hpath = getString(); + + + + keys = getString().split(','); + paths = hpath.split('/'); + count = getInt(); + + keys = keys.map(function(key) { + return key.split(':'); + }); + var i; + for (i = 0; i < count; i++) { + var tmp = {}; + + tmp.pointers = paths.map(function(path) { + return getPointer(); + }); + + keys.forEach(function(key) { + tmp[key[0]] = runType(key[1]); + }); + objs.push(tmp); + }; + return objs; + }; + + function getPointer() { + var l = getChar(); + + var pointer = getSlice(l) + var parsed_data = new Uint8Array(pointer); + return _uiatos(parsed_data); + + }; + + var _uiatos =function(uia) { + var _str = []; + for (var c = 0; c < uia.length; c++) { + _str[c] = String.fromCharCode(uia[c]); + } + return decodeURIComponent(escape(_str.join(""))); + }; + + var getInt = function() { + var parsed_data = new Uint8Array(getSlice(4)); + var i = ((parsed_data[0] & 0xff) << 24) | ((parsed_data[1] & 0xff) << 16) | ((parsed_data[2] & 0xff) << 8) | (parsed_data[3] & 0xff); + return i; + + }; + + var getChar = function() { + var parsed_data = new Uint8Array(getSlice(1)); + return parsed_data[0]; + }; + + var getString = function() { + var l = getInt(); + if (l > 0) { + var s = getSlice(l); + var parsed_data = new Uint8Array(s); + return _uiatos(parsed_data); + } + return ""; + }; + + var getSlice = function(length) { + var slice = self.data.slice(0,length); + self.data = self.data.slice(length); + return slice; + }; + + var getType = function() { + var t = getSlice(3); + return _uiatos(new Uint8Array(t)); + }; + + var runType = function(type) { + if (type in types) { + return types[type](); + } + 0; + }; + + var getHeader = function() { + return { + length: getInt(), + compression: getChar(), + } + }; + + var getId = function() { + return getString(); + } + + var getObject = function() { + var type = getType(); + if (type) { + return object = { + type: type, + content: runType(type), + } + } + } + + self.parse = function(data) { + self.setData(data); + var header = getHeader(); + var id = getId(); + var objects = []; + var object = getObject(); + while(object) { + objects.push(object); + object = getObject(); + } + return { + header: header, + id: id, + objects: objects, + } + } + + self.setData = function (data) { + self.data = data; + }; + + function array() { + var type; + var count; + var values; + + type = getType(); + count = getInt(); + values = []; + var i; + for (i = 0; i < count; i++) { + values.push(runType(type)); + }; + return values; + } + + var types = { + chr: getChar, + "int": getInt, + str: getString, + inf: getInfo, + hda: getHdata, + ptr: getPointer, + lon: getPointer, + tim: getPointer, + buf: getString, + arr: array + }; +//TODO: IMPLEMENT THIS STUFF +// chr: this.getChar, +// 'int': getInt, + // hacks + + // hacks +// htb: getHashtable, +// inf: Protocol.getInfo, +// inl: getInfolist, + +// }, + +} diff --git a/js/underscore.js b/js/underscore.js new file mode 100644 index 0000000..7d4ee27 --- /dev/null +++ b/js/underscore.js @@ -0,0 +1,1246 @@ +// Underscore.js 1.5.1 +// http://underscorejs.org +// (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +// Underscore may be freely distributed under the MIT license. + +(function() { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `global` on the server. + var root = this; + + // Save the previous value of the `_` variable. + var previousUnderscore = root._; + + // Establish the object that gets returned to break out of a loop iteration. + var breaker = {}; + + // Save bytes in the minified (but not gzipped) version: + var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; + + // Create quick reference variables for speed access to core prototypes. + var + push = ArrayProto.push, + slice = ArrayProto.slice, + concat = ArrayProto.concat, + toString = ObjProto.toString, + hasOwnProperty = ObjProto.hasOwnProperty; + + // All **ECMAScript 5** native function implementations that we hope to use + // are declared here. + var + nativeForEach = ArrayProto.forEach, + nativeMap = ArrayProto.map, + nativeReduce = ArrayProto.reduce, + nativeReduceRight = ArrayProto.reduceRight, + nativeFilter = ArrayProto.filter, + nativeEvery = ArrayProto.every, + nativeSome = ArrayProto.some, + nativeIndexOf = ArrayProto.indexOf, + nativeLastIndexOf = ArrayProto.lastIndexOf, + nativeIsArray = Array.isArray, + nativeKeys = Object.keys, + nativeBind = FuncProto.bind; + + // Create a safe reference to the Underscore object for use below. + var _ = function(obj) { + if (obj instanceof _) return obj; + if (!(this instanceof _)) return new _(obj); + this._wrapped = obj; + }; + + // Export the Underscore object for **Node.js**, with + // backwards-compatibility for the old `require()` API. If we're in + // the browser, add `_` as a global object via a string identifier, + // for Closure Compiler "advanced" mode. + if (typeof exports !== 'undefined') { + if (typeof module !== 'undefined' && module.exports) { + exports = module.exports = _; + } + exports._ = _; + } else { + root._ = _; + } + + // Current version. + _.VERSION = '1.5.1'; + + // Collection Functions + // -------------------- + + // The cornerstone, an `each` implementation, aka `forEach`. + // Handles objects with the built-in `forEach`, arrays, and raw objects. + // Delegates to **ECMAScript 5**'s native `forEach` if available. + var each = _.each = _.forEach = function(obj, iterator, context) { + if (obj == null) return; + if (nativeForEach && obj.forEach === nativeForEach) { + obj.forEach(iterator, context); + } else if (obj.length === +obj.length) { + for (var i = 0, l = obj.length; i < l; i++) { + if (iterator.call(context, obj[i], i, obj) === breaker) return; + } + } else { + for (var key in obj) { + if (_.has(obj, key)) { + if (iterator.call(context, obj[key], key, obj) === breaker) return; + } + } + } + }; + + // Return the results of applying the iterator to each element. + // Delegates to **ECMAScript 5**'s native `map` if available. + _.map = _.collect = function(obj, iterator, context) { + var results = []; + if (obj == null) return results; + if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); + each(obj, function(value, index, list) { + results.push(iterator.call(context, value, index, list)); + }); + return results; + }; + + var reduceError = 'Reduce of empty array with no initial value'; + + // **Reduce** builds up a single result from a list of values, aka `inject`, + // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. + _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { + var initial = arguments.length > 2; + if (obj == null) obj = []; + if (nativeReduce && obj.reduce === nativeReduce) { + if (context) iterator = _.bind(iterator, context); + return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); + } + each(obj, function(value, index, list) { + if (!initial) { + memo = value; + initial = true; + } else { + memo = iterator.call(context, memo, value, index, list); + } + }); + if (!initial) throw new TypeError(reduceError); + return memo; + }; + + // The right-associative version of reduce, also known as `foldr`. + // Delegates to **ECMAScript 5**'s native `reduceRight` if available. + _.reduceRight = _.foldr = function(obj, iterator, memo, context) { + var initial = arguments.length > 2; + if (obj == null) obj = []; + if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { + if (context) iterator = _.bind(iterator, context); + return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); + } + var length = obj.length; + if (length !== +length) { + var keys = _.keys(obj); + length = keys.length; + } + each(obj, function(value, index, list) { + index = keys ? keys[--length] : --length; + if (!initial) { + memo = obj[index]; + initial = true; + } else { + memo = iterator.call(context, memo, obj[index], index, list); + } + }); + if (!initial) throw new TypeError(reduceError); + return memo; + }; + + // Return the first value which passes a truth test. Aliased as `detect`. + _.find = _.detect = function(obj, iterator, context) { + var result; + any(obj, function(value, index, list) { + if (iterator.call(context, value, index, list)) { + result = value; + return true; + } + }); + return result; + }; + + // Return all the elements that pass a truth test. + // Delegates to **ECMAScript 5**'s native `filter` if available. + // Aliased as `select`. + _.filter = _.select = function(obj, iterator, context) { + var results = []; + if (obj == null) return results; + if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context); + each(obj, function(value, index, list) { + if (iterator.call(context, value, index, list)) results.push(value); + }); + return results; + }; + + // Return all the elements for which a truth test fails. + _.reject = function(obj, iterator, context) { + return _.filter(obj, function(value, index, list) { + return !iterator.call(context, value, index, list); + }, context); + }; + + // Determine whether all of the elements match a truth test. + // Delegates to **ECMAScript 5**'s native `every` if available. + // Aliased as `all`. + _.every = _.all = function(obj, iterator, context) { + iterator || (iterator = _.identity); + var result = true; + if (obj == null) return result; + if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context); + each(obj, function(value, index, list) { + if (!(result = result && iterator.call(context, value, index, list))) return breaker; + }); + return !!result; + }; + + // Determine if at least one element in the object matches a truth test. + // Delegates to **ECMAScript 5**'s native `some` if available. + // Aliased as `any`. + var any = _.some = _.any = function(obj, iterator, context) { + iterator || (iterator = _.identity); + var result = false; + if (obj == null) return result; + if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context); + each(obj, function(value, index, list) { + if (result || (result = iterator.call(context, value, index, list))) return breaker; + }); + return !!result; + }; + + // Determine if the array or object contains a given value (using `===`). + // Aliased as `include`. + _.contains = _.include = function(obj, target) { + if (obj == null) return false; + if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; + return any(obj, function(value) { + return value === target; + }); + }; + + // Invoke a method (with arguments) on every item in a collection. + _.invoke = function(obj, method) { + var args = slice.call(arguments, 2); + var isFunc = _.isFunction(method); + return _.map(obj, function(value) { + return (isFunc ? method : value[method]).apply(value, args); + }); + }; + + // Convenience version of a common use case of `map`: fetching a property. + _.pluck = function(obj, key) { + return _.map(obj, function(value){ return value[key]; }); + }; + + // Convenience version of a common use case of `filter`: selecting only objects + // containing specific `key:value` pairs. + _.where = function(obj, attrs, first) { + if (_.isEmpty(attrs)) return first ? void 0 : []; + return _[first ? 'find' : 'filter'](obj, function(value) { + for (var key in attrs) { + if (attrs[key] !== value[key]) return false; + } + return true; + }); + }; + + // Convenience version of a common use case of `find`: getting the first object + // containing specific `key:value` pairs. + _.findWhere = function(obj, attrs) { + return _.where(obj, attrs, true); + }; + + // Return the maximum element or (element-based computation). + // Can't optimize arrays of integers longer than 65,535 elements. + // See [WebKit Bug 80797](https://bugs.webkit.org/show_bug.cgi?id=80797) + _.max = function(obj, iterator, context) { + if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { + return Math.max.apply(Math, obj); + } + if (!iterator && _.isEmpty(obj)) return -Infinity; + var result = {computed : -Infinity, value: -Infinity}; + each(obj, function(value, index, list) { + var computed = iterator ? iterator.call(context, value, index, list) : value; + computed > result.computed && (result = {value : value, computed : computed}); + }); + return result.value; + }; + + // Return the minimum element (or element-based computation). + _.min = function(obj, iterator, context) { + if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { + return Math.min.apply(Math, obj); + } + if (!iterator && _.isEmpty(obj)) return Infinity; + var result = {computed : Infinity, value: Infinity}; + each(obj, function(value, index, list) { + var computed = iterator ? iterator.call(context, value, index, list) : value; + computed < result.computed && (result = {value : value, computed : computed}); + }); + return result.value; + }; + + // Shuffle an array. + _.shuffle = function(obj) { + var rand; + var index = 0; + var shuffled = []; + each(obj, function(value) { + rand = _.random(index++); + shuffled[index - 1] = shuffled[rand]; + shuffled[rand] = value; + }); + return shuffled; + }; + + // An internal function to generate lookup iterators. + var lookupIterator = function(value) { + return _.isFunction(value) ? value : function(obj){ return obj[value]; }; + }; + + // Sort the object's values by a criterion produced by an iterator. + _.sortBy = function(obj, value, context) { + var iterator = lookupIterator(value); + return _.pluck(_.map(obj, function(value, index, list) { + return { + value : value, + index : index, + criteria : iterator.call(context, value, index, list) + }; + }).sort(function(left, right) { + var a = left.criteria; + var b = right.criteria; + if (a !== b) { + if (a > b || a === void 0) return 1; + if (a < b || b === void 0) return -1; + } + return left.index < right.index ? -1 : 1; + }), 'value'); + }; + + // An internal function used for aggregate "group by" operations. + var group = function(obj, value, context, behavior) { + var result = {}; + var iterator = lookupIterator(value == null ? _.identity : value); + each(obj, function(value, index) { + var key = iterator.call(context, value, index, obj); + behavior(result, key, value); + }); + return result; + }; + + // Groups the object's values by a criterion. Pass either a string attribute + // to group by, or a function that returns the criterion. + _.groupBy = function(obj, value, context) { + return group(obj, value, context, function(result, key, value) { + (_.has(result, key) ? result[key] : (result[key] = [])).push(value); + }); + }; + + // Counts instances of an object that group by a certain criterion. Pass + // either a string attribute to count by, or a function that returns the + // criterion. + _.countBy = function(obj, value, context) { + return group(obj, value, context, function(result, key) { + if (!_.has(result, key)) result[key] = 0; + result[key]++; + }); + }; + + // Use a comparator function to figure out the smallest index at which + // an object should be inserted so as to maintain order. Uses binary search. + _.sortedIndex = function(array, obj, iterator, context) { + iterator = iterator == null ? _.identity : lookupIterator(iterator); + var value = iterator.call(context, obj); + var low = 0, high = array.length; + while (low < high) { + var mid = (low + high) >>> 1; + iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; + } + return low; + }; + + // Safely create a real, live array from anything iterable. + _.toArray = function(obj) { + if (!obj) return []; + if (_.isArray(obj)) return slice.call(obj); + if (obj.length === +obj.length) return _.map(obj, _.identity); + return _.values(obj); + }; + + // Return the number of elements in an object. + _.size = function(obj) { + if (obj == null) return 0; + return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; + }; + + // Array Functions + // --------------- + + // Get the first element of an array. Passing **n** will return the first N + // values in the array. Aliased as `head` and `take`. The **guard** check + // allows it to work with `_.map`. + _.first = _.head = _.take = function(array, n, guard) { + if (array == null) return void 0; + return (n != null) && !guard ? slice.call(array, 0, n) : array[0]; + }; + + // Returns everything but the last entry of the array. Especially useful on + // the arguments object. Passing **n** will return all the values in + // the array, excluding the last N. The **guard** check allows it to work with + // `_.map`. + _.initial = function(array, n, guard) { + return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); + }; + + // Get the last element of an array. Passing **n** will return the last N + // values in the array. The **guard** check allows it to work with `_.map`. + _.last = function(array, n, guard) { + if (array == null) return void 0; + if ((n != null) && !guard) { + return slice.call(array, Math.max(array.length - n, 0)); + } else { + return array[array.length - 1]; + } + }; + + // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. + // Especially useful on the arguments object. Passing an **n** will return + // the rest N values in the array. The **guard** + // check allows it to work with `_.map`. + _.rest = _.tail = _.drop = function(array, n, guard) { + return slice.call(array, (n == null) || guard ? 1 : n); + }; + + // Trim out all falsy values from an array. + _.compact = function(array) { + return _.filter(array, _.identity); + }; + + // Internal implementation of a recursive `flatten` function. + var flatten = function(input, shallow, output) { + if (shallow && _.every(input, _.isArray)) { + return concat.apply(output, input); + } + each(input, function(value) { + if (_.isArray(value) || _.isArguments(value)) { + shallow ? push.apply(output, value) : flatten(value, shallow, output); + } else { + output.push(value); + } + }); + return output; + }; + + // Return a completely flattened version of an array. + _.flatten = function(array, shallow) { + return flatten(array, shallow, []); + }; + + // Return a version of the array that does not contain the specified value(s). + _.without = function(array) { + return _.difference(array, slice.call(arguments, 1)); + }; + + // Produce a duplicate-free version of the array. If the array has already + // been sorted, you have the option of using a faster algorithm. + // Aliased as `unique`. + _.uniq = _.unique = function(array, isSorted, iterator, context) { + if (_.isFunction(isSorted)) { + context = iterator; + iterator = isSorted; + isSorted = false; + } + var initial = iterator ? _.map(array, iterator, context) : array; + var results = []; + var seen = []; + each(initial, function(value, index) { + if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) { + seen.push(value); + results.push(array[index]); + } + }); + return results; + }; + + // Produce an array that contains the union: each distinct element from all of + // the passed-in arrays. + _.union = function() { + return _.uniq(_.flatten(arguments, true)); + }; + + // Produce an array that contains every item shared between all the + // passed-in arrays. + _.intersection = function(array) { + var rest = slice.call(arguments, 1); + return _.filter(_.uniq(array), function(item) { + return _.every(rest, function(other) { + return _.indexOf(other, item) >= 0; + }); + }); + }; + + // Take the difference between one array and a number of other arrays. + // Only the elements present in just the first array will remain. + _.difference = function(array) { + var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); + return _.filter(array, function(value){ return !_.contains(rest, value); }); + }; + + // Zip together multiple lists into a single array -- elements that share + // an index go together. + _.zip = function() { + var length = _.max(_.pluck(arguments, "length").concat(0)); + var results = new Array(length); + for (var i = 0; i < length; i++) { + results[i] = _.pluck(arguments, '' + i); + } + return results; + }; + + // Converts lists into objects. Pass either a single array of `[key, value]` + // pairs, or two parallel arrays of the same length -- one of keys, and one of + // the corresponding values. + _.object = function(list, values) { + if (list == null) return {}; + var result = {}; + for (var i = 0, l = list.length; i < l; i++) { + if (values) { + result[list[i]] = values[i]; + } else { + result[list[i][0]] = list[i][1]; + } + } + return result; + }; + + // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**), + // we need this function. Return the position of the first occurrence of an + // item in an array, or -1 if the item is not included in the array. + // Delegates to **ECMAScript 5**'s native `indexOf` if available. + // If the array is large and already in sort order, pass `true` + // for **isSorted** to use binary search. + _.indexOf = function(array, item, isSorted) { + if (array == null) return -1; + var i = 0, l = array.length; + if (isSorted) { + if (typeof isSorted == 'number') { + i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted); + } else { + i = _.sortedIndex(array, item); + return array[i] === item ? i : -1; + } + } + if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted); + for (; i < l; i++) if (array[i] === item) return i; + return -1; + }; + + // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available. + _.lastIndexOf = function(array, item, from) { + if (array == null) return -1; + var hasIndex = from != null; + if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { + return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); + } + var i = (hasIndex ? from : array.length); + while (i--) if (array[i] === item) return i; + return -1; + }; + + // Generate an integer Array containing an arithmetic progression. A port of + // the native Python `range()` function. See + // [the Python documentation](http://docs.python.org/library/functions.html#range). + _.range = function(start, stop, step) { + if (arguments.length <= 1) { + stop = start || 0; + start = 0; + } + step = arguments[2] || 1; + + var len = Math.max(Math.ceil((stop - start) / step), 0); + var idx = 0; + var range = new Array(len); + + while(idx < len) { + range[idx++] = start; + start += step; + } + + return range; + }; + + // Function (ahem) Functions + // ------------------ + + // Reusable constructor function for prototype setting. + var ctor = function(){}; + + // Create a function bound to a given object (assigning `this`, and arguments, + // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if + // available. + _.bind = function(func, context) { + var args, bound; + if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); + if (!_.isFunction(func)) throw new TypeError; + args = slice.call(arguments, 2); + return bound = function() { + if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); + ctor.prototype = func.prototype; + var self = new ctor; + ctor.prototype = null; + var result = func.apply(self, args.concat(slice.call(arguments))); + if (Object(result) === result) return result; + return self; + }; + }; + + // Partially apply a function by creating a version that has had some of its + // arguments pre-filled, without changing its dynamic `this` context. + _.partial = function(func) { + var args = slice.call(arguments, 1); + return function() { + return func.apply(this, args.concat(slice.call(arguments))); + }; + }; + + // Bind all of an object's methods to that object. Useful for ensuring that + // all callbacks defined on an object belong to it. + _.bindAll = function(obj) { + var funcs = slice.call(arguments, 1); + if (funcs.length === 0) throw new Error("bindAll must be passed function names"); + each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); + return obj; + }; + + // Memoize an expensive function by storing its results. + _.memoize = function(func, hasher) { + var memo = {}; + hasher || (hasher = _.identity); + return function() { + var key = hasher.apply(this, arguments); + return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); + }; + }; + + // Delays a function for the given number of milliseconds, and then calls + // it with the arguments supplied. + _.delay = function(func, wait) { + var args = slice.call(arguments, 2); + return setTimeout(function(){ return func.apply(null, args); }, wait); + }; + + // Defers a function, scheduling it to run after the current call stack has + // cleared. + _.defer = function(func) { + return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); + }; + + // Returns a function, that, when invoked, will only be triggered at most once + // during a given window of time. Normally, the throttled function will run + // as much as it can, without ever going more than once per `wait` duration; + // but if you'd like to disable the execution on the leading edge, pass + // `{leading: false}`. To disable execution on the trailing edge, ditto. + _.throttle = function(func, wait, options) { + var context, args, result; + var timeout = null; + var previous = 0; + options || (options = {}); + var later = function() { + previous = options.leading === false ? 0 : new Date; + timeout = null; + result = func.apply(context, args); + }; + return function() { + var now = new Date; + if (!previous && options.leading === false) previous = now; + var remaining = wait - (now - previous); + context = this; + args = arguments; + if (remaining <= 0) { + clearTimeout(timeout); + timeout = null; + previous = now; + result = func.apply(context, args); + } else if (!timeout && options.trailing !== false) { + timeout = setTimeout(later, remaining); + } + return result; + }; + }; + + // Returns a function, that, as long as it continues to be invoked, will not + // be triggered. The function will be called after it stops being called for + // N milliseconds. If `immediate` is passed, trigger the function on the + // leading edge, instead of the trailing. + _.debounce = function(func, wait, immediate) { + var result; + var timeout = null; + return function() { + var context = this, args = arguments; + var later = function() { + timeout = null; + if (!immediate) result = func.apply(context, args); + }; + var callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) result = func.apply(context, args); + return result; + }; + }; + + // Returns a function that will be executed at most one time, no matter how + // often you call it. Useful for lazy initialization. + _.once = function(func) { + var ran = false, memo; + return function() { + if (ran) return memo; + ran = true; + memo = func.apply(this, arguments); + func = null; + return memo; + }; + }; + + // Returns the first function passed as an argument to the second, + // allowing you to adjust arguments, run code before and after, and + // conditionally execute the original function. + _.wrap = function(func, wrapper) { + return function() { + var args = [func]; + push.apply(args, arguments); + return wrapper.apply(this, args); + }; + }; + + // Returns a function that is the composition of a list of functions, each + // consuming the return value of the function that follows. + _.compose = function() { + var funcs = arguments; + return function() { + var args = arguments; + for (var i = funcs.length - 1; i >= 0; i--) { + args = [funcs[i].apply(this, args)]; + } + return args[0]; + }; + }; + + // Returns a function that will only be executed after being called N times. + _.after = function(times, func) { + return function() { + if (--times < 1) { + return func.apply(this, arguments); + } + }; + }; + + // Object Functions + // ---------------- + + // Retrieve the names of an object's properties. + // Delegates to **ECMAScript 5**'s native `Object.keys` + _.keys = nativeKeys || function(obj) { + if (obj !== Object(obj)) throw new TypeError('Invalid object'); + var keys = []; + for (var key in obj) if (_.has(obj, key)) keys.push(key); + return keys; + }; + + // Retrieve the values of an object's properties. + _.values = function(obj) { + var values = []; + for (var key in obj) if (_.has(obj, key)) values.push(obj[key]); + return values; + }; + + // Convert an object into a list of `[key, value]` pairs. + _.pairs = function(obj) { + var pairs = []; + for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]); + return pairs; + }; + + // Invert the keys and values of an object. The values must be serializable. + _.invert = function(obj) { + var result = {}; + for (var key in obj) if (_.has(obj, key)) result[obj[key]] = key; + return result; + }; + + // Return a sorted list of the function names available on the object. + // Aliased as `methods` + _.functions = _.methods = function(obj) { + var names = []; + for (var key in obj) { + if (_.isFunction(obj[key])) names.push(key); + } + return names.sort(); + }; + + // Extend a given object with all the properties in passed-in object(s). + _.extend = function(obj) { + each(slice.call(arguments, 1), function(source) { + if (source) { + for (var prop in source) { + obj[prop] = source[prop]; + } + } + }); + return obj; + }; + + // Return a copy of the object only containing the whitelisted properties. + _.pick = function(obj) { + var copy = {}; + var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); + each(keys, function(key) { + if (key in obj) copy[key] = obj[key]; + }); + return copy; + }; + + // Return a copy of the object without the blacklisted properties. + _.omit = function(obj) { + var copy = {}; + var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); + for (var key in obj) { + if (!_.contains(keys, key)) copy[key] = obj[key]; + } + return copy; + }; + + // Fill in a given object with default properties. + _.defaults = function(obj) { + each(slice.call(arguments, 1), function(source) { + if (source) { + for (var prop in source) { + if (obj[prop] === void 0) obj[prop] = source[prop]; + } + } + }); + return obj; + }; + + // Create a (shallow-cloned) duplicate of an object. + _.clone = function(obj) { + if (!_.isObject(obj)) return obj; + return _.isArray(obj) ? obj.slice() : _.extend({}, obj); + }; + + // Invokes interceptor with the obj, and then returns obj. + // The primary purpose of this method is to "tap into" a method chain, in + // order to perform operations on intermediate results within the chain. + _.tap = function(obj, interceptor) { + interceptor(obj); + return obj; + }; + + // Internal recursive comparison function for `isEqual`. + var eq = function(a, b, aStack, bStack) { + // Identical objects are equal. `0 === -0`, but they aren't identical. + // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). + if (a === b) return a !== 0 || 1 / a == 1 / b; + // A strict comparison is necessary because `null == undefined`. + if (a == null || b == null) return a === b; + // Unwrap any wrapped objects. + if (a instanceof _) a = a._wrapped; + if (b instanceof _) b = b._wrapped; + // Compare `[[Class]]` names. + var className = toString.call(a); + if (className != toString.call(b)) return false; + switch (className) { + // Strings, numbers, dates, and booleans are compared by value. + case '[object String]': + // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is + // equivalent to `new String("5")`. + return a == String(b); + case '[object Number]': + // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for + // other numeric values. + return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); + case '[object Date]': + case '[object Boolean]': + // Coerce dates and booleans to numeric primitive values. Dates are compared by their + // millisecond representations. Note that invalid dates with millisecond representations + // of `NaN` are not equivalent. + return +a == +b; + // RegExps are compared by their source patterns and flags. + case '[object RegExp]': + return a.source == b.source && + a.global == b.global && + a.multiline == b.multiline && + a.ignoreCase == b.ignoreCase; + } + if (typeof a != 'object' || typeof b != 'object') return false; + // Assume equality for cyclic structures. The algorithm for detecting cyclic + // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. + var length = aStack.length; + while (length--) { + // Linear search. Performance is inversely proportional to the number of + // unique nested structures. + if (aStack[length] == a) return bStack[length] == b; + } + // Objects with different constructors are not equivalent, but `Object`s + // from different frames are. + var aCtor = a.constructor, bCtor = b.constructor; + if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) && + _.isFunction(bCtor) && (bCtor instanceof bCtor))) { + return false; + } + // Add the first object to the stack of traversed objects. + aStack.push(a); + bStack.push(b); + var size = 0, result = true; + // Recursively compare objects and arrays. + if (className == '[object Array]') { + // Compare array lengths to determine if a deep comparison is necessary. + size = a.length; + result = size == b.length; + if (result) { + // Deep compare the contents, ignoring non-numeric properties. + while (size--) { + if (!(result = eq(a[size], b[size], aStack, bStack))) break; + } + } + } else { + // Deep compare objects. + for (var key in a) { + if (_.has(a, key)) { + // Count the expected number of properties. + size++; + // Deep compare each member. + if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; + } + } + // Ensure that both objects contain the same number of properties. + if (result) { + for (key in b) { + if (_.has(b, key) && !(size--)) break; + } + result = !size; + } + } + // Remove the first object from the stack of traversed objects. + aStack.pop(); + bStack.pop(); + return result; + }; + + // Perform a deep comparison to check if two objects are equal. + _.isEqual = function(a, b) { + return eq(a, b, [], []); + }; + + // Is a given array, string, or object empty? + // An "empty" object has no enumerable own-properties. + _.isEmpty = function(obj) { + if (obj == null) return true; + if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; + for (var key in obj) if (_.has(obj, key)) return false; + return true; + }; + + // Is a given value a DOM element? + _.isElement = function(obj) { + return !!(obj && obj.nodeType === 1); + }; + + // Is a given value an array? + // Delegates to ECMA5's native Array.isArray + _.isArray = nativeIsArray || function(obj) { + return toString.call(obj) == '[object Array]'; + }; + + // Is a given variable an object? + _.isObject = function(obj) { + return obj === Object(obj); + }; + + // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp. + each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { + _['is' + name] = function(obj) { + return toString.call(obj) == '[object ' + name + ']'; + }; + }); + + // Define a fallback version of the method in browsers (ahem, IE), where + // there isn't any inspectable "Arguments" type. + if (!_.isArguments(arguments)) { + _.isArguments = function(obj) { + return !!(obj && _.has(obj, 'callee')); + }; + } + + // Optimize `isFunction` if appropriate. + if (typeof (/./) !== 'function') { + _.isFunction = function(obj) { + return typeof obj === 'function'; + }; + } + + // Is a given object a finite number? + _.isFinite = function(obj) { + return isFinite(obj) && !isNaN(parseFloat(obj)); + }; + + // Is the given value `NaN`? (NaN is the only number which does not equal itself). + _.isNaN = function(obj) { + return _.isNumber(obj) && obj != +obj; + }; + + // Is a given value a boolean? + _.isBoolean = function(obj) { + return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; + }; + + // Is a given value equal to null? + _.isNull = function(obj) { + return obj === null; + }; + + // Is a given variable undefined? + _.isUndefined = function(obj) { + return obj === void 0; + }; + + // Shortcut function for checking if an object has a given property directly + // on itself (in other words, not on a prototype). + _.has = function(obj, key) { + return hasOwnProperty.call(obj, key); + }; + + // Utility Functions + // ----------------- + + // Run Underscore.js in *noConflict* mode, returning the `_` variable to its + // previous owner. Returns a reference to the Underscore object. + _.noConflict = function() { + root._ = previousUnderscore; + return this; + }; + + // Keep the identity function around for default iterators. + _.identity = function(value) { + return value; + }; + + // Run a function **n** times. + _.times = function(n, iterator, context) { + var accum = Array(Math.max(0, n)); + for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i); + return accum; + }; + + // Return a random integer between min and max (inclusive). + _.random = function(min, max) { + if (max == null) { + max = min; + min = 0; + } + return min + Math.floor(Math.random() * (max - min + 1)); + }; + + // List of HTML entities for escaping. + var entityMap = { + escape: { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '/': '/' + } + }; + entityMap.unescape = _.invert(entityMap.escape); + + // Regexes containing the keys and values listed immediately above. + var entityRegexes = { + escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), + unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') + }; + + // Functions for escaping and unescaping strings to/from HTML interpolation. + _.each(['escape', 'unescape'], function(method) { + _[method] = function(string) { + if (string == null) return ''; + return ('' + string).replace(entityRegexes[method], function(match) { + return entityMap[method][match]; + }); + }; + }); + + // If the value of the named `property` is a function then invoke it with the + // `object` as context; otherwise, return it. + _.result = function(object, property) { + if (object == null) return void 0; + var value = object[property]; + return _.isFunction(value) ? value.call(object) : value; + }; + + // Add your own custom functions to the Underscore object. + _.mixin = function(obj) { + each(_.functions(obj), function(name){ + var func = _[name] = obj[name]; + _.prototype[name] = function() { + var args = [this._wrapped]; + push.apply(args, arguments); + return result.call(this, func.apply(_, args)); + }; + }); + }; + + // Generate a unique integer id (unique within the entire client session). + // Useful for temporary DOM ids. + var idCounter = 0; + _.uniqueId = function(prefix) { + var id = ++idCounter + ''; + return prefix ? prefix + id : id; + }; + + // By default, Underscore uses ERB-style template delimiters, change the + // following template settings to use alternative delimiters. + _.templateSettings = { + evaluate : /<%([\s\S]+?)%>/g, + interpolate : /<%=([\s\S]+?)%>/g, + escape : /<%-([\s\S]+?)%>/g + }; + + // When customizing `templateSettings`, if you don't want to define an + // interpolation, evaluation or escaping regex, we need one that is + // guaranteed not to match. + var noMatch = /(.)^/; + + // Certain characters need to be escaped so that they can be put into a + // string literal. + var escapes = { + "'": "'", + '\\': '\\', + '\r': 'r', + '\n': 'n', + '\t': 't', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; + + var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; + + // JavaScript micro-templating, similar to John Resig's implementation. + // Underscore templating handles arbitrary delimiters, preserves whitespace, + // and correctly escapes quotes within interpolated code. + _.template = function(text, data, settings) { + var render; + settings = _.defaults({}, settings, _.templateSettings); + + // Combine delimiters into one regular expression via alternation. + var matcher = new RegExp([ + (settings.escape || noMatch).source, + (settings.interpolate || noMatch).source, + (settings.evaluate || noMatch).source + ].join('|') + '|$', 'g'); + + // Compile the template source, escaping string literals appropriately. + var index = 0; + var source = "__p+='"; + text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { + source += text.slice(index, offset) + .replace(escaper, function(match) { return '\\' + escapes[match]; }); + + if (escape) { + source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; + } + if (interpolate) { + source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; + } + if (evaluate) { + source += "';\n" + evaluate + "\n__p+='"; + } + index = offset + match.length; + return match; + }); + source += "';\n"; + + // If a variable is not specified, place data values in local scope. + if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; + + source = "var __t,__p='',__j=Array.prototype.join," + + "print=function(){__p+=__j.call(arguments,'');};\n" + + source + "return __p;\n"; + + try { + render = new Function(settings.variable || 'obj', '_', source); + } catch (e) { + e.source = source; + throw e; + } + + if (data) return render(data, _); + var template = function(data) { + return render.call(this, data, _); + }; + + // Provide the compiled function source as a convenience for precompilation. + template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; + + return template; + }; + + // Add a "chain" function, which will delegate to the wrapper. + _.chain = function(obj) { + return _(obj).chain(); + }; + + // OOP + // --------------- + // If Underscore is called as a function, it returns a wrapped object that + // can be used OO-style. This wrapper holds altered versions of all the + // underscore functions. Wrapped objects may be chained. + + // Helper function to continue chaining intermediate results. + var result = function(obj) { + return this._chain ? _(obj).chain() : obj; + }; + + // Add all of the Underscore functions to the wrapper object. + _.mixin(_); + + // Add all mutator Array functions to the wrapper. + each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + var obj = this._wrapped; + method.apply(obj, arguments); + if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0]; + return result.call(this, obj); + }; + }); + + // Add all accessor Array functions to the wrapper. + each(['concat', 'join', 'slice'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + return result.call(this, method.apply(this._wrapped, arguments)); + }; + }); + + _.extend(_.prototype, { + + // Start chaining a wrapped Underscore object. + chain: function() { + this._chain = true; + return this; + }, + + // Extracts the result from a wrapped and chained object. + value: function() { + return this._wrapped; + } + + }); + +}).call(this); diff --git a/js/websockets.js b/js/websockets.js new file mode 100644 index 0000000..592abdb --- /dev/null +++ b/js/websockets.js @@ -0,0 +1,599 @@ +var weechat = angular.module('weechat', ['localStorage']); +weechat.filter('toArray', function () { + 'use strict'; + + return function (obj) { + if (!(obj instanceof Object)) { + return obj; + } + + return Object.keys(obj).map(function (key) { + return Object.defineProperty(obj[key], '$key', {__proto__: null, value: key}); + }); + } +}); + +weechat.factory('colors', [function($scope) { + + // http://weechat.org/files/doc/devel/weechat_dev.en.html#color_codes_in_strings + var part, fg, bg, attrs, colors = ['', 'black', 'dark gray', 'dark red', 'light red', 'dark green', 'light green', 'brown', 'yellow', 'dark blue', 'light blue', 'dark magenta', 'light magenta', 'dark cyan', 'light cyan', 'gray', 'white']; + // XTerm 8-bit pallete + var colors = [ + '#000000', '#AA0000', '#00AA00', '#AA5500', '#0000AA', + '#AA00AA', '#00AAAA', '#AAAAAA', '#555555', '#FF5555', + '#55FF55', '#FFFF55', '#5555FF', '#FF55FF', '#55FFFF', + '#FFFFFF', '#000000', '#00005F', '#000087', '#0000AF', + '#0000D7', '#0000FF', '#005F00', '#005F5F', '#005F87', + '#005FAF', '#005FD7', '#005FFF', '#008700', '#00875F', + '#008787', '#0087AF', '#0087D7', '#00AF00', '#00AF5F', + '#00AF87', '#00AFAF', '#00AFD7', '#00AFFF', '#00D700', + '#00D75F', '#00D787', '#00D7AF', '#00D7D7', '#00D7FF', + '#00FF00', '#00FF5F', '#00FF87', '#00FFAF', '#00FFD7', + '#00FFFF', '#5F0000', '#5F005F', '#5F0087', '#5F00AF', + '#5F00D7', '#5F00FF', '#5F5F00', '#5F5F5F', '#5F5F87', + '#5F5FAF', '#5F5FD7', '#5F5FFF', '#5F8700', '#5F875F', + '#5F8787', '#5F87AF', '#5F87D7', '#5F87FF', '#5FAF00', + '#5FAF5F', '#5FAF87', '#5FAFAF', '#5FAFD7', '#5FAFFF', + '#5FD700', '#5FD75F', '#5FD787', '#5FD7AF', '#5FD7D7', + '#5FD7FF', '#5FFF00', '#5FFF5F', '#5FFF87', '#5FFFAF', + '#5FFFD7', '#5FFFFF', '#870000', '#87005F', '#870087', + '#8700AF', '#8700D7', '#8700FF', '#875F00', '#875F5F', + '#875F87', '#875FAF', '#875FD7', '#875FFF', '#878700', + '#87875F', '#878787', '#8787AF', '#8787D7', '#8787FF', + '#87AF00', '#87AF5F', '#87AF87', '#87AFAF', '#87AFD7', + '#87AFFF', '#87D700', '#87D75F', '#87D787', '#87D7AF', + '#87D7D7', '#87D7FF', '#87FF00', '#87FF5F', '#87FF87', + '#87FFAF', '#87FFD7', '#87FFFF', '#AF0000', '#AF005F', + '#AF0087', '#AF00AF', '#AF00D7', '#AF00FF', '#AF5F00', + '#AF5F5F', '#AF5F87', '#AF5FAF', '#AF5FD7', '#AF5FFF', + '#AF8700', '#AF875F', '#AF8787', '#AF87AF', '#AF87D7', + '#AF87FF', '#AFAF00', '#AFAF5F', '#AFAF87', '#AFAFAF', + '#AFAFD7', '#AFAFFF', '#AFD700', '#AFD75F', '#AFD787', + '#AFD7AF', '#AFD7D7', '#AFD7FF', '#AFFF00', '#AFFF5F', + '#AFFF87', '#AFFFAF', '#AFFFD7', '#AFFFFF', '#D70000', + '#D7005F', '#D70087', '#D700AF', '#D700D7', '#D700FF', + '#D75F00', '#D75F5F', '#D75F87', '#D75FAF', '#D75FD7', + '#D75FFF', '#D78700', '#D7875F', '#D78787', '#D787AF', + '#D787D7', '#D787FF', '#D7AF00', '#D7AF5F', '#D7AF87', + '#D7AFAF', '#D7AFD7', '#D7AFFF', '#D7D700', '#D7D75F', + '#D7D787', '#D7D7AF', '#D7D7D7', '#D7D7FF', '#D7FF00', + '#D7FF5F', '#D7FF87', '#D7FFAF', '#D7FFD7', '#D7FFFF', + '#FF0000', '#FF005F', '#FF0087', '#FF00AF', '#FF00D7', + '#FF00FF', '#FF5F00', '#FF5F5F', '#FF5F87', '#FF5FAF', + '#FF5FD7', '#FF5FFF', '#FF8700', '#FF875F', '#FF8787', + '#FF87AF', '#FF87D7', '#FF87FF', '#FFAF00', '#FFAF5F', + '#FFAF87', '#FFAFAF', '#FFAFD7', '#FFAFFF', '#FFD700', + '#FFD75F', '#FFD787', '#FFD7AF', '#FFD7D7', '#FFD7FF', + '#FFFF00', '#FFFF5F', '#FFFF87', '#FFFFAF', '#FFFFD7', + '#FFFFFF', '#080808', '#121212', '#1C1C1C', '#262626', + '#303030', '#3A3A3A', '#444444', '#4E4E4E', '#585858', + '#626262', '#6C6C6C', '#767676', '#808080', '#8A8A8A', + '#949494', '#9E9E9E', '#A8A8A8', '#B2B2B2', '#BCBCBC', + '#C6C6C6', '#D0D0D0', '#DADADA', '#E4E4E4', '#EEEEEE' + ] + + + function setAttrs() { + while (part.match(/^[\*\/\_\|]/)) { + attrs.push(part.charAt(0)); + part = part.slice(1); + } + } + + function getColor() { + var c; + if (part.match(/^@/)) { + c = part.slice(1, 6); + part = part.slice(6); + } else { + c = part.slice(0, 2); + part = part.slice(2); + } + return c; + } + + function prepareCss(color) { + /* + * Translates a weechat color to CSS + */ + return 'color: ' + color; + } + + var prefixes = { + '\x19': function() { + if (part.match(/^F/)) { + part = part.slice(1); + setAttrs(); + fg = getColor(); + } else if (part.match(/^B/)) { + part = part.slice(1); + setAttrs(); + bg = getColor(); + } else { + setAttrs(); + fg = getColor(); + if (part.match(/^,/)) { + part = part.slice(1); + bg = getColor(); + } + } + }, + '\x1A': function() { + // Don't know what to do + }, + '\x1B': function() { + attrs = []; + }, + '\x1C': function() { + fg = ''; + bg = ''; + } + }; + + function parse(text) { + if (!text) { + return text; + } + var f, parts = text.split(/(\x19|\x1A|\x1B|\x1C)/); + if (parts.length === 1) return [{ + text: parts[0] + }]; + attrs = []; + + return parts.map(function(p) { + var res, tmp = prefixes[p.charAt(0)]; + if (f) { + part = p; + f(); + res = { + text: part, + fg: colors[parseInt(fg, 10)], + bg: colors[parseInt(bg, 10)], + attrs: attrs + }; + if (!res.fg) res.fg = fg; + if (!res.bg) res.bg = bg; + } + f = tmp; + return res; + }).filter(function(p) { + return p; + }); + }; + + + + + + + return { + + setAttrs: setAttrs, + getColor: getColor, + prepareCss: prepareCss, + parse: parse, + parts: ['', 'black', 'dark gray', 'dark red', 'light red', 'dark green', 'light green', 'brown', 'yellow', 'dark blue', 'light blue', 'dark magenta', 'light magenta', 'dark cyan', 'light cyan', 'gray', 'white'] + } + +}]); + +weechat.factory('pluginManager', ['youtubePlugin', 'urlPlugin', 'imagePlugin', function(youtubePlugin, urlPlugin, imagePlugin) { + + var plugins = [youtubePlugin, urlPlugin, imagePlugin] + + var hookPlugin = function(plugin) { + plugins.push(plugin); + } + + var contentForMessage = function(message) { + + console.log('Message: ', message); + var content = []; + for (var i = 0; i < plugins.length; i++) { + var pluginContent = plugins[i].contentForMessage(message); + if (pluginContent) { + var pluginContent = {'visible': false, 'content': pluginContent } + content.push(pluginContent); + + if (plugins[i].exclusive) { + break; + } + } + } + + console.log('Content: ', content); + return content; + } + + return { + hookPlugin: hookPlugin, + contentForMessage: contentForMessage + } + +}]); + +weechat.factory('youtubePlugin', [function() { + + var contentForMessage = function(message) { + if (message.indexOf('youtube.com') != -1) { + var index = message.indexOf("?v="); + var token = message.substr(index+3); + return '' + } + return null; + } + + return { + contentForMessage: contentForMessage, + exclusive: true + } + +}]); + +weechat.factory('urlPlugin', [function() { + var contentForMessage = function(message) { + var urlPattern = /(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/; + var url = message.match(urlPattern); + if (url) { + return '' + message + ''; + } + return null; + } + + return { + contentForMessage: contentForMessage, + exclusive: false + } +}]); + +weechat.factory('imagePlugin', [function() { + var contentForMessage = function(message) { + var urls = message.match(/https?:\/\/[^\s]*\.(jpg|png|gif)\b/) + if (urls != null) { + var url = urls[0]; /* Actually parse one url per message */ + return ''; + } + return null; + } + + return { + contentForMessage: contentForMessage + } +}]); + +weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($rootScope, colors, pluginManager) { + + var handleBufferClosing = function(message) { + var buffer_pointer = message['objects'][0]['content'][0]['pointers'][0]; + $rootScope.closeBuffer(buffer_pointer); + } + + var handleLine = function(line, initial) { + var buffer_line = {} + var date = line['date']; + var prefix = colors.parse(line['prefix']); + var text = colors.parse(line['message']); + var buffer = line['buffer']; + var tags_array = line['tags_array']; + var displayed = line['displayed']; + var highlight = line['highlight']; + var message = _.union(prefix, text); + message =_.map(message, function(message) { + if (message != "" && 'fg' in message) { + message['fg'] = colors.prepareCss(message['fg']); + } + return message; + }); + // Only react to line if its displayed + if (displayed) { + buffer_line['message'] = message; + + + if (!_isActiveBuffer(buffer) && !initial && !_.contains(tags_array, 'notify_none')) { + + if ($rootScope.buffers[buffer]['unread'] == '') { + $rootScope.buffers[buffer]['unread'] = 1; + }else { + $rootScope.buffers[buffer]['unread'] = parseInt($rootScope.buffers[buffer]['unread']) + 1; + } + } + + if (text[0] != undefined) { + var additionalContent = pluginManager.contentForMessage(text[0]['text']); + + if (additionalContent) { + buffer_line['metadata'] = additionalContent; + } + } + + $rootScope.buffers[buffer]['lines'].push(buffer_line); + + buffer_line['date'] = date; + + if(!initial && (highlight || _.contains(tags_array, 'notify_private')) ) { + $rootScope.createHighlight(prefix, text, message, buffer, additionalContent); + $rootScope.buffers[buffer]['highlight'] = true; + } + } + } + + var handleBufferLineAdded = function(message) { + message['objects'][0]['content'].forEach(function(l) { + handleLine(l, false); + }); + } + + /* + * Returns whether or not this buffer is the active buffer + */ + var _isActiveBuffer = function(buffer) { + if ($rootScope.activeBuffer['id'] == buffer) { + return true; + } else { + return false; + } + } + + var handleBufferOpened = function(message) { + var obj = message['objects'][0]['content'][0]; + var fullName = obj['full_name']; + var buffer = obj['pointers'][0]; + var short_name = obj['short_name']; + var title = obj['title']; + + $rootScope.buffers[buffer] = { 'id': buffer, 'lines':[], 'full_name':fullName, 'short_name':short_name, 'title':title, 'unread':'' } + + } + + var handleBufferTitleChanged = function(message) { + var obj = message['objects'][0]['content'][0]; + var buffer = obj['pointers'][0]; + var old = $rootScope.buffers[buffer]; + old['full_name'] = obj['full_name']; + old['title'] = obj['title']; + } + var handleBufferRenamed = function(message) { + var obj = message['objects'][0]['content'][0]; + var buffer = obj['pointers'][0]; + var old = $rootScope.buffers[buffer]; + old['full_name'] = obj['full_name']; + old['short_name'] = obj['short_name']; + } + + + /* + * Handle answers to (bufinfo) messages + * + * (bufinfo) messages are specified by this client. It is the first + * message that is sent to the relay after connection. + */ + var handleBufferInfo = function(message) { + // buffer info from message + var bufferInfos = message['objects'][0]['content']; + // buffers objects + var buffers = {}; + for (var i = 0; i < bufferInfos.length ; i++) { + var bufferInfo = bufferInfos[i]; + var pointer = bufferInfo['pointers'][0]; + bufferInfo['id'] = pointer; + bufferInfo['lines'] = []; + bufferInfo['unread'] = ''; + buffers[pointer] = bufferInfo + if (i == 0) { + // first buffer is active buffer by default + $rootScope.activeBuffer = buffers[pointer]; + $rootScope.activeBuffer['active'] = true; + } + } + $rootScope.buffers = buffers; + + // Request latest buffer lines for each buffer + $rootScope.getLines(); + } + + + /* + * Handle answers to (lineinfo) messages + * + * (lineinfo) messages are specified by this client. It is request after bufinfo completes + */ + var handleLineInfo = function(message) { + var lines = message['objects'][0]['content'].reverse(); + lines.forEach(function(l) { + handleLine(l, true); + }); + } + + var handleEvent = function(event) { + if (_.has(eventHandlers, event['id'])) { + eventHandlers[event['id']](event); + } + + } + + var findMetaData = function(message) { + if (message.indexOf('youtube.com') != -1) { + var index = message.indexOf("?v="); + var token = message.substr(index+3); + return '' + } + return null; + } + + var eventHandlers = { + bufinfo: handleBufferInfo, + lineinfo: handleLineInfo, + _buffer_closing: handleBufferClosing, + _buffer_line_added: handleBufferLineAdded, + _buffer_opened: handleBufferOpened, + _buffer_title_changed: handleBufferTitleChanged, + _buffer_renamed: handleBufferRenamed + } + + return { + handleEvent: handleEvent + + } + +}]); + +weechat.factory('connection', ['$rootScope', '$log', 'handlers', 'colors', function($rootScope, $log, handlers, colors) { + protocol = new Protocol(); + var websocket = null; + + + // Sanitizes messages to be sent to the weechat relay + var doSend = function(message) { + msgs = message.replace(/[\r\n]+$/g, "").split("\n"); + for (var i = 0; i < msgs.length; i++) { + $log.log('=' + msgs[i] + '='); + $rootScope.commands.push("SENT: " + msgs[i]); + } + websocket.send(message); + } + + // Takes care of the connection and websocket hooks + var connect = function (hostport, proto, password) { + websocket = new WebSocket("ws://" + hostport + "/weechat"); + websocket.binaryType = "arraybuffer" + + websocket.onopen = function (evt) { + var send = ""; + // FIXME: does password need to be sent only if protocol is not weechat? + if (proto == "weechat") { + if (password) { + send += "init compression=off,password=" + password + "\n"; + } + + send += "(bufinfo) hdata buffer:gui_buffers(*) number,full_name,short_name,title\n"; + send += "sync\n"; + } else { + + } + $log.info("Connected to relay"); + doSend(send); + $rootScope.connected = true; + $rootScope.$apply(); + } + + websocket.onclose = function (evt) { + $log.info("Disconnected from relay"); + $rootScope.connected = false; + $rootScope.$apply(); + } + + websocket.onmessage = function (evt) { + message = protocol.parse(evt.data) + handlers.handleEvent(message); + $rootScope.commands.push("RECV: " + evt.data + " TYPE:" + evt.type) ; + $rootScope.$apply(); + } + + websocket.onerror = function (evt) { + if (evt.type == "error" && websocket.readyState == 0) { + $rootScope.errorMessage = true; + } + $log.error("Relay error " + evt.data); + } + + this.websocket = websocket; + } + + var sendMessage = function(message) { + message = "input " + $rootScope.activeBuffer['full_name'] + " " + message + "\n" + doSend(message); + } + + var getLines = function(count) { + var message = "(lineinfo) hdata buffer:gui_buffers(*)/own_lines/last_line(-"+count+")/data\n"; + doSend(message) + } + + return { + send: doSend, + getLines: getLines, + connect: connect, + sendMessage: sendMessage + } +}]); + +weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', 'connection', function ($rootScope, $scope, $store, connection) { + + // Request notification permission + Notification.requestPermission(function (status) { + console.log('Notification permission status:',status); + if (Notification.permission !== status) { + Notification.permission = status; + } + }); + if(window.webkitNotifications != undefined) { + if (window.webkitNotifications.checkPermission() == 0) { // 0 is PERMISSION_ALLOWED + console.log('Notification permission status:', window.webkitNotifications.checkPermission() == 0); + window.webkitNotifications.requestPermission(); + } + } + + $rootScope.commands = [] + + $rootScope.buffer = [] + $rootScope.buffers = {} + $rootScope.activeBuffer = null; + $store.bind($scope, "hostport", "localhost:9001"); + $store.bind($scope, "proto", "weechat"); + $store.bind($scope, "password", ""); + // TODO checkbox for saving password or not? + // $scope.password = ""; + + $rootScope.closeBuffer = function(buffer_pointer) { + delete($rootScope.buffers[buffer_pointer]); + var first_buffer = _.keys($rootScope.buffers)[0]; + $scope.setActiveBuffer(first_buffer); + } + + $scope.setActiveBuffer = function(key) { + $rootScope.activeBuffer['active'] = false; + $rootScope.buffers[key]['active'] = true; + $rootScope.buffers[key]['highlight'] = false; + $rootScope.buffers[key]['unread'] = ''; + $rootScope.activeBuffer = $rootScope.buffers[key]; + $rootScope.pageTitle = $rootScope.activeBuffer['short_name'] + ' | ' + $rootScope.activeBuffer['title']; + }; + + $scope.sendMessage = function() { + connection.sendMessage($scope.command); + $scope.command = ""; + }; + + $scope.connect = function() { + connection.connect($scope.hostport, $scope.proto, $scope.password); + } + $rootScope.getLines = function() { + var count = 20; + connection.getLines(20); + } + + /* Function gets called from bufferLineAdded code if user should be notified */ + $rootScope.createHighlight = function(prefix, text, message, buffer, additionalContent) { + var prefixs = ""; + prefixs += prefix[0].text; + if(prefix[1] != undefined) { + prefixs += prefix[1].text; + } + var messages = ""; + messages += text[0].text; + + var buffers = $rootScope.buffers[buffer]; + + var title = buffers.full_name; + var content = "<"+prefixs+">"+messages; + + var timeout = 15*1000; + console.log('Displaying notification:',title,',with timeout:',timeout); + var notification = new Notification(title, {body:content, icon:'img/favicon.png'}); + // Cancel notification automatically + notification.onshow = function() { + setTimeout(function() { notification.close() }, timeout); + } + }; +}] + ); From 001b05beeb21a9edaa19b6014f8091b770104a18 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Mon, 7 Oct 2013 14:26:05 +0200 Subject: [PATCH 19/26] Use protocol agnostic links to CDN resources --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index a445ae2..180f0a4 100644 --- a/index.html +++ b/index.html @@ -6,9 +6,9 @@ - + - + From 628961026b7bedf06d3995bf3287c86342cdbc9e Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Mon, 7 Oct 2013 15:38:47 +0200 Subject: [PATCH 20/26] Add support for encryption --- index.html | 22 +++++++++++++++++----- js/websockets.js | 24 ++++++++++-------------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/index.html b/index.html index 180f0a4..051a724 100644 --- a/index.html +++ b/index.html @@ -7,8 +7,6 @@ - - @@ -16,6 +14,8 @@ + +
@@ -33,6 +33,18 @@ /relay add weechat 9001 Note: The communication goes directly between your browser and your weechat in clear text. Connection settings are saved between sessions, including password, in your own browser. +

Encryption

+ If you want to use encrypted session you first have to set up the relay using SSL +
+$ mkdir -p ~/.weechat/ssl
+$ cd ~/.weechat/ssl
+$ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out relay.pem
+
+ If WeeChat is already running, you can reload the certificate and private key with command: +
+/relay sslcertkey
+/relay add ssl.weechat 8000
+

Connection settings

@@ -50,9 +62,9 @@

Password will be stored in your browser session

- - -

Default is fine.

+ + +

Check the box if you want to encrypt communication between browser and WeeChat. Note: Due to a bug encryption will not work in Firefox. You must also first visit the URL https://weechathost:relayport/ to accept the certificate

diff --git a/js/websockets.js b/js/websockets.js index 592abdb..9b5d36f 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -453,23 +453,19 @@ weechat.factory('connection', ['$rootScope', '$log', 'handlers', 'colors', funct } // Takes care of the connection and websocket hooks - var connect = function (hostport, proto, password) { - websocket = new WebSocket("ws://" + hostport + "/weechat"); + var connect = function (hostport, password, ssl) { + var proto = ssl ? 'wss':'ws'; + websocket = new WebSocket(proto+"://" + hostport + "/weechat"); websocket.binaryType = "arraybuffer" websocket.onopen = function (evt) { var send = ""; - // FIXME: does password need to be sent only if protocol is not weechat? - if (proto == "weechat") { - if (password) { - send += "init compression=off,password=" + password + "\n"; - } - - send += "(bufinfo) hdata buffer:gui_buffers(*) number,full_name,short_name,title\n"; - send += "sync\n"; - } else { - + if (password) { + send += "init compression=off,password=" + password + "\n"; } + + send += "(bufinfo) hdata buffer:gui_buffers(*) number,full_name,short_name,title\n"; + send += "sync\n"; $log.info("Connected to relay"); doSend(send); $rootScope.connected = true; @@ -490,7 +486,7 @@ weechat.factory('connection', ['$rootScope', '$log', 'handlers', 'colors', funct } websocket.onerror = function (evt) { - if (evt.type == "error" && websocket.readyState == 0) { + if (evt.type == "error" && websocket.readyState != 1) { $rootScope.errorMessage = true; } $log.error("Relay error " + evt.data); @@ -565,7 +561,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', 'connection }; $scope.connect = function() { - connection.connect($scope.hostport, $scope.proto, $scope.password); + connection.connect($scope.hostport, $scope.password, $scope.ssl); } $rootScope.getLines = function() { var count = 20; From 5032af8ab3cf05f66cb6391fcaff7d9925ea4e92 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Mon, 7 Oct 2013 16:58:41 +0200 Subject: [PATCH 21/26] fix automatic scrolling --- css/glowingbear.css | 10 ++++++++-- index.html | 2 +- js/websockets.js | 29 +++++++++++++++++++++++++---- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index d013eee..1902717 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -1,3 +1,5 @@ +html { +} body { color: white; background-color: #222; @@ -6,10 +8,14 @@ body { padding-bottom:70px; padding-top: 70px; } +.content { + height: 100%; + min-height: 100%; + display: block; +} .bufferlines { font-family: monospace; - overflow: scroll-y; - height: 100%; + overflow-y: auto; } .navbar-fixed-bottom { diff --git a/index.html b/index.html index 051a724..a750669 100644 --- a/index.html +++ b/index.html @@ -69,7 +69,7 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
-
+
+
+

+ + glowing bear + + WeeChat web frontend + +

+
To start using, please enable relay in your WeeChat client: +
 /set relay.network.password yourpassword
 /relay add weechat 9001
- Note: The communication goes directly between your browser and your weechat in clear text. - Connection settings are saved between sessions, including password, in your own browser. -

Encryption

- If you want to use encrypted session you first have to set up the relay using SSL -
+      Note: The communication goes directly between your browser and your weechat in clear text.
+      Connection settings are saved between sessions, including password, in your own browser.
+      

Encryption

+ If you want to use encrypted session you first have to set up the relay using SSL +
 $ mkdir -p ~/.weechat/ssl
 $ cd ~/.weechat/ssl
 $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out relay.pem
 
- If WeeChat is already running, you can reload the certificate and private key with command: -
+      If WeeChat is already running, you can reload the certificate and private key with command:
+      
 /relay sslcertkey
 /relay add ssl.weechat 8000
 
-
-

Connection settings

-
-
- Oh no! We cannot connect! -
-
- - -

Enter the hostname and the port to the WeeChat relay, separated by a :

-
-
- - -

Password will be stored in your browser session

-
-
- - -

Check the box if you want to encrypt communication between browser and WeeChat. Note: Due to a bug encryption will not work in Firefox. You must also first visit the URL https://weechathost:relayport/ to accept the certificate

-
- -
-
- -
-
- - {{ bufferline.date | date:'HH:mm' }} - +

Connection settings

+
+
+ Oh no! We cannot connect! +
+
+ + +

Enter the hostname and the port to the WeeChat relay, separated by a :

+
+
+ + +

Password will be stored in your browser session

+
+
+ + +

Check the box if you want to encrypt communication between browser and WeeChat. Note: Due to a bug encryption will not work in Firefox. You must also first visit the URL https://weechathost:relayport/ to accept the certificate

+
+ +
+
+
+
+
+ + {{ bufferline.date | date:'HH:mm' }} + - - {{ part.text }} - + + {{ part.text }} + - - - +
+
+ diff --git a/js/models.js b/js/models.js new file mode 100644 index 0000000..8dc36d5 --- /dev/null +++ b/js/models.js @@ -0,0 +1,183 @@ +/* + * This file contains the weechat models and various + * helper methods to work with them. + */ +var models = angular.module('weechatModels', []); + +models.service('models', ['colors', function(colors) { + /* + * Buffer class + */ + this.Buffer = function(message) { + // weechat properties + var fullName = message['full_name'] + var shortName = message['short_name'] + var title = message['title'] + var number = message['number'] + var pointer = message['pointers'][0] + var lines = [] + var active = false; + var notification = false; + var unread = ''; + + /* + * Adds a line to this buffer + * + * @param line the BufferLine object + * @return undefined + */ + var addLine = function(line) { + lines.push(line); + } + + return { + id: pointer, + fullName: fullName, + shortName: shortName, + number: number, + title: title, + lines: lines, + addLine: addLine + } + + } + + /* + * BufferLine class + */ + this.BufferLine = function(message) { + + /* + * Parse the text elements from the buffer line added + * + * @param message weechat message + */ + function parseLineAddedTextElements(message) { + var prefix = colors.parse(message['prefix']); + + var buffer = message['buffer']; + text_elements = _.union(prefix, text); + text_elements =_.map(text_elements, function(text_element) { + if (text_element && ('fg' in text_element)) { + text_element['fg'] = colors.prepareCss(text_element['fg']); + } + // TODO: parse background as well + + return text_element; + }); + return text_elements; + } + + + var buffer = message['buffer']; + var date = message['date']; + var text = colors.parse(message['message']); + var tags_array = message['tags_array']; + var displayed = message['displayed']; + var highlight = message['highlight']; + var content = parseLineAddedTextElements(message); + var text = ""; + if(text[0] != undefined) { + text = text[0]['text']; + } + + return { + content: content, + date: date, + buffer: buffer, + tags: tags_array, + highlight: highlight, + displayed: displayed, + text: text, + } + + } + + + var BufferList = [] + activeBuffer = null; + + this.model = { 'buffers': {} } + + /* + * Adds a buffer to the list + * + * @param buffer buffer object + * @return undefined + */ + this.addBuffer = function(buffer) { + BufferList[buffer.id] = buffer; + if (BufferList.length == 1) { + activeBuffer = buffer.id; + } + this.model.buffers[buffer.id] = buffer; + } + + /* + * Returns the current active buffer + * + * @return active buffer object + */ + this.getActiveBuffer = function() { + return activeBuffer; + } + + /* + * Sets the buffer specifiee by bufferId as active. + * Deactivates the previous current buffer. + * + * @param bufferId id of the new active buffer + * @return undefined + */ + this.setActiveBuffer = function(bufferId) { + + if (this.getActiveBuffer()) { + this.getActiveBuffer().active = false; + } + + activeBuffer = _.find(this.model['buffers'], function(buffer) { + if (buffer['id'] == bufferId) { + return buffer; + } + }); + activeBuffer.notification = false; + activeBuffer.active = true; + activeBuffer.unread = ''; + + } + + /* + * Returns the buffer list + */ + this.getBuffers = function() { + return BufferList; + } + + /* + * Returns a specific buffer object + * + * @param bufferId id of the buffer + * @return the buffer object + */ + this.getBuffer = function(bufferId) { + return _.find(this.model['buffers'], function(buffer) { + if (buffer['id'] == bufferId) { + return buffer; + } + }); + } + + /* + * Closes a weechat buffer. Sets the first buffer + * as active. + * + * @param bufferId id of the buffer to close + * @return undefined + */ + this.closeBuffer = function(bufferId) { + + delete(this.model['buffers'][bufferId.id]); + var firstBuffer = _.keys(this.model['buffers'])[0]; + this.setActiveBuffer(firstBuffer); + } +}]); diff --git a/js/plugins.js b/js/plugins.js new file mode 100644 index 0000000..64ad843 --- /dev/null +++ b/js/plugins.js @@ -0,0 +1,132 @@ +/* + * This file contains the plugin definitions + */ + +plugins = angular.module('plugins', []); + +/* + * Definition of a user provided plugin with sensible default values + * + * User plugins are created by providing a contentForMessage function + * that parses a string and return any additional content. + */ +var Plugin = function(contentForMessage) { + + return { + contentForMessage: contentForMessage, + exclusive: false, + } +} + +/* + * This service provides access to the plugin manager + * + * The plugin manager is where the various user provided plugins + * are registered. It is responsible for finding additional content + * to display when messages are received. + * + */ +plugins.service('plugins', ['userPlugins', function(userPlugins) { + + /* + * Defines the plugin manager object + */ + var PluginManagerObject = function() { + + var plugins = []; + + /* + * Register the user provides plugins + * + * @param userPlugins user provided plugins + */ + var registerPlugins = function(userPlugins) { + for (var i = 0; i < userPlugins.length; i++) { + plugins.push(userPlugins[i]); + }; + } + + /* + * Iterates through all the registered plugins + * and run their contentForMessage function. + */ + var contentForMessage = function(message) { + + var content = []; + for (var i = 0; i < plugins.length; i++) { + var pluginContent = plugins[i].contentForMessage(message); + if (pluginContent) { + var pluginContent = {'visible': false, + 'content': pluginContent } + content.push(pluginContent); + + if (plugins[i].exclusive) { + break; + } + } + } + return content; + } + + return { + registerPlugins: registerPlugins, + contentForMessage: contentForMessage + } + } + + // Instanciates and registers the plugin manager. + this.PluginManager = new PluginManagerObject(); + this.PluginManager.registerPlugins(userPlugins.plugins); + +}]); + +/* + * This factory exposes the collection of user provided plugins. + * + * To create your own plugin, you need to: + * + * 1. Define it's contentForMessage function. The contentForMessage + * function takes a string as a parameter and returns a HTML string. + * + * 2. Instanciate a Plugin object with contentForMessage function as it's + * argument. + * + * 3. Add it to the plugins array. + * + */ +plugins.factory('userPlugins', function() { + + var youtubePlugin = new Plugin(function(message) { + + if (message.indexOf('youtube.com') != -1) { + var index = message.indexOf("?v="); + var token = message.substr(index+3); + return '' + } + + return null; + }); + + var urlPlugin = new Plugin(function(message) { + var urlPattern = /(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/; + var url = message.match(urlPattern); + if (url) { + return '' + message + ''; + } + return null; + + }); + + var imagePlugin = new Plugin(function(message) { + var urls = message.match(/https?:\/\/[^\s]*\.(jpg|png|gif)\b/) + if (urls != null) { + var url = urls[0]; /* Actually parse one url per message */ + return ''; + } + return null; + }); + + return { + plugins: [youtubePlugin, urlPlugin, imagePlugin] + } +}); diff --git a/js/protocol.js b/js/protocol.js deleted file mode 100644 index ea6dda8..0000000 --- a/js/protocol.js +++ /dev/null @@ -1,180 +0,0 @@ -var Protocol = function() { - var self = this; - - var getInfo = function() { - var info = {}; - info.key = getString(); - info.value = getString(); - return info; - }; - - var getHdata = function() { - var paths; - var count; - var objs = []; - var hpath = getString(); - - - - keys = getString().split(','); - paths = hpath.split('/'); - count = getInt(); - - keys = keys.map(function(key) { - return key.split(':'); - }); - var i; - for (i = 0; i < count; i++) { - var tmp = {}; - - tmp.pointers = paths.map(function(path) { - return getPointer(); - }); - - keys.forEach(function(key) { - tmp[key[0]] = runType(key[1]); - }); - objs.push(tmp); - }; - return objs; - }; - - function getPointer() { - var l = getChar(); - - var pointer = getSlice(l) - var parsed_data = new Uint8Array(pointer); - return _uiatos(parsed_data); - - }; - - var _uiatos =function(uia) { - var _str = []; - for (var c = 0; c < uia.length; c++) { - _str[c] = String.fromCharCode(uia[c]); - } - return decodeURIComponent(escape(_str.join(""))); - }; - - var getInt = function() { - var parsed_data = new Uint8Array(getSlice(4)); - var i = ((parsed_data[0] & 0xff) << 24) | ((parsed_data[1] & 0xff) << 16) | ((parsed_data[2] & 0xff) << 8) | (parsed_data[3] & 0xff); - return i; - - }; - - var getChar = function() { - var parsed_data = new Uint8Array(getSlice(1)); - return parsed_data[0]; - }; - - var getString = function() { - var l = getInt(); - if (l > 0) { - var s = getSlice(l); - var parsed_data = new Uint8Array(s); - return _uiatos(parsed_data); - } - return ""; - }; - - var getSlice = function(length) { - var slice = self.data.slice(0,length); - self.data = self.data.slice(length); - return slice; - }; - - var getType = function() { - var t = getSlice(3); - return _uiatos(new Uint8Array(t)); - }; - - var runType = function(type) { - if (type in types) { - return types[type](); - } - 0; - }; - - var getHeader = function() { - return { - length: getInt(), - compression: getChar(), - } - }; - - var getId = function() { - return getString(); - } - - var getObject = function() { - var type = getType(); - if (type) { - return object = { - type: type, - content: runType(type), - } - } - } - - self.parse = function(data) { - self.setData(data); - var header = getHeader(); - var id = getId(); - var objects = []; - var object = getObject(); - while(object) { - objects.push(object); - object = getObject(); - } - return { - header: header, - id: id, - objects: objects, - } - } - - self.setData = function (data) { - self.data = data; - }; - - function array() { - var type; - var count; - var values; - - type = getType(); - count = getInt(); - values = []; - var i; - for (i = 0; i < count; i++) { - values.push(runType(type)); - }; - return values; - } - - var types = { - chr: getChar, - "int": getInt, - str: getString, - inf: getInfo, - hda: getHdata, - ptr: getPointer, - lon: getPointer, - tim: getPointer, - buf: getString, - arr: array - }; -//TODO: IMPLEMENT THIS STUFF -// chr: this.getChar, -// 'int': getInt, - // hacks - - // hacks -// htb: getHashtable, -// inf: Protocol.getInfo, -// inl: getInfolist, - -// }, - -} diff --git a/js/websockets.js b/js/websockets.js index b10cde9..4d473c4 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -1,4 +1,5 @@ -var weechat = angular.module('weechat', ['localStorage']); +var weechat = angular.module('weechat', ['localStorage', 'weechatModels', 'plugins']); + weechat.filter('toArray', function () { 'use strict'; @@ -167,7 +168,7 @@ weechat.factory('colors', [function($scope) { return { - + setAttrs: setAttrs, getColor: getColor, prepareCss: prepareCss, @@ -177,142 +178,39 @@ weechat.factory('colors', [function($scope) { }]); -weechat.factory('pluginManager', ['youtubePlugin', 'urlPlugin', 'imagePlugin', function(youtubePlugin, urlPlugin, imagePlugin) { - - var plugins = [youtubePlugin, urlPlugin, imagePlugin] - - var hookPlugin = function(plugin) { - plugins.push(plugin); - } - - var contentForMessage = function(message) { - - console.log('Message: ', message); - var content = []; - for (var i = 0; i < plugins.length; i++) { - var pluginContent = plugins[i].contentForMessage(message); - if (pluginContent) { - var pluginContent = {'visible': false, 'content': pluginContent } - content.push(pluginContent); - - if (plugins[i].exclusive) { - break; - } - } - } - - console.log('Content: ', content); - return content; - } - - return { - hookPlugin: hookPlugin, - contentForMessage: contentForMessage - } - -}]); - -weechat.factory('youtubePlugin', [function() { - - var contentForMessage = function(message) { - if (message.indexOf('youtube.com') != -1) { - var index = message.indexOf("?v="); - var token = message.substr(index+3); - return '' - } - return null; - } - - return { - contentForMessage: contentForMessage, - exclusive: true - } - -}]); - -weechat.factory('urlPlugin', [function() { - var contentForMessage = function(message) { - var urlPattern = /(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/; - var url = message.match(urlPattern); - if (url) { - return '' + message + ''; - } - return null; - } - - return { - contentForMessage: contentForMessage, - exclusive: false - } -}]); - -weechat.factory('imagePlugin', [function() { - var contentForMessage = function(message) { - var urls = message.match(/https?:\/\/[^\s]*\.(jpg|png|gif)\b/) - if (urls != null) { - var url = urls[0]; /* Actually parse one url per message */ - return ''; - } - return null; - } - - return { - contentForMessage: contentForMessage - } -}]); - -weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($rootScope, colors, pluginManager) { +weechat.factory('handlers', ['$rootScope', 'colors', 'models', 'plugins', function($rootScope, colors, models, plugins) { var handleBufferClosing = function(message) { - var buffer_pointer = message['objects'][0]['content'][0]['pointers'][0]; - $rootScope.closeBuffer(buffer_pointer); + var bufferMessage = message['objects'][0]['content'][0]; + var buffer = new models.Buffer(bufferMessage); + models.closeBuffer(buffer); } var handleLine = function(line, initial) { - var buffer_line = {} - var date = line['date']*1000; - var prefix = colors.parse(line['prefix']); - var text = colors.parse(line['message']); - var buffer = line['buffer']; - var tags_array = line['tags_array']; - var displayed = line['displayed']; - var highlight = line['highlight']; - var message = _.union(prefix, text); - message =_.map(message, function(message) { - if (message != "" && 'fg' in message) { - message['fg'] = colors.prepareCss(message['fg']); - } - return message; - }); + var message = new models.BufferLine(line); // Only react to line if its displayed - if (displayed) { - buffer_line['message'] = message; + if(message.displayed) { + var buffer = models.getBuffer(message.buffer); + message.metadata = plugins.PluginManager.contentForMessage(message.text); + buffer.addLine(message); + if (buffer.active) { + $rootScope.scrollToBottom(); + } - if (!_isActiveBuffer(buffer) && !initial && !_.contains(tags_array, 'notify_none')) { - - if ($rootScope.buffers[buffer]['unread'] == '') { - $rootScope.buffers[buffer]['unread'] = 1; - }else { - $rootScope.buffers[buffer]['unread'] = parseInt($rootScope.buffers[buffer]['unread']) + 1; + if (!initial) { + if (!buffer.active && _.contains(message.tags, 'notify_message') && !_.contains(message.tags, 'notify_none')) { + if (buffer.unread == '' || buffer.unread == undefined) { + buffer.unread = 1; + }else { + buffer.unread++; + } } - } - if (text[0] != undefined) { - var additionalContent = pluginManager.contentForMessage(text[0]['text']); - - if (additionalContent) { - buffer_line['metadata'] = additionalContent; - } - } - - $rootScope.addLine(buffer, buffer_line); - - buffer_line['date'] = date; - - if(!initial && (highlight || _.contains(tags_array, 'notify_private')) ) { - $rootScope.createHighlight(prefix, text, message, buffer, additionalContent); - $rootScope.buffers[buffer]['highlight'] = true; + if(message.highlight || _.contains(message.tags, 'notify_private') ) { + $rootScope.createHighlight(buffer, message); + buffer.notification = true; + } } } } @@ -323,26 +221,10 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ }); } - /* - * Returns whether or not this buffer is the active buffer - */ - var _isActiveBuffer = function(buffer) { - if ($rootScope.activeBuffer['id'] == buffer) { - return true; - } else { - return false; - } - } - var handleBufferOpened = function(message) { - var obj = message['objects'][0]['content'][0]; - var fullName = obj['full_name']; - var buffer = obj['pointers'][0]; - var short_name = obj['short_name']; - var title = obj['title']; - - $rootScope.buffers[buffer] = { 'id': buffer, 'lines':[], 'full_name':fullName, 'short_name':short_name, 'title':title, 'unread':'' } - + var bufferMessage = message['objects'][0]['content'][0]; + var buffer = new models.Buffer(bufferMessage); + models.addBuffer(buffer); } var handleBufferTitleChanged = function(message) { @@ -371,21 +253,10 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ // buffer info from message var bufferInfos = message['objects'][0]['content']; // buffers objects - var buffers = {}; for (var i = 0; i < bufferInfos.length ; i++) { - var bufferInfo = bufferInfos[i]; - var pointer = bufferInfo['pointers'][0]; - bufferInfo['id'] = pointer; - bufferInfo['lines'] = []; - bufferInfo['unread'] = ''; - buffers[pointer] = bufferInfo - if (i == 0) { - // first buffer is active buffer by default - $rootScope.activeBuffer = buffers[pointer]; - $rootScope.activeBuffer['active'] = true; - } + var buffer = new models.Buffer(bufferInfos[i]); + models.addBuffer(buffer); } - $rootScope.buffers = buffers; // Request latest buffer lines for each buffer $rootScope.getLines(); @@ -403,7 +274,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ handleLine(l, true); }); } - + var handleEvent = function(event) { if (_.has(eventHandlers, event['id'])) { eventHandlers[event['id']](event); @@ -411,15 +282,6 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ } - var findMetaData = function(message) { - if (message.indexOf('youtube.com') != -1) { - var index = message.indexOf("?v="); - var token = message.substr(index+3); - return '' - } - return null; - } - var eventHandlers = { bufinfo: handleBufferInfo, lineinfo: handleLineInfo, @@ -437,12 +299,12 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ }]); -weechat.factory('connection', ['$rootScope', '$log', 'handlers', 'colors', function($rootScope, $log, handlers, colors) { - protocol = new Protocol(); +weechat.factory('connection', ['$rootScope', '$log', 'handlers', 'colors', 'models', function($rootScope, $log, handlers, colors, models) { + protocol = new WeeChatProtocol(); var websocket = null; - // Sanitizes messages to be sent to the weechat relay + // Sanitizes messages to be sent to the weechat relay var doSend = function(message) { msgs = message.replace(/[\r\n]+$/g, "").split("\n"); for (var i = 0; i < msgs.length; i++) { @@ -451,23 +313,26 @@ weechat.factory('connection', ['$rootScope', '$log', 'handlers', 'colors', funct } websocket.send(message); } - + // Takes care of the connection and websocket hooks - var connect = function (hostport, password, ssl) { + var connect = function (hostport, passwd, ssl) { var proto = ssl ? 'wss':'ws'; websocket = new WebSocket(proto+"://" + hostport + "/weechat"); websocket.binaryType = "arraybuffer" websocket.onopen = function (evt) { - var send = ""; - if (password) { - send += "init compression=off,password=" + password + "\n"; - } + doSend(WeeChatProtocol.formatInit({ + password: passwd, + compression: 'off' + })); + doSend(WeeChatProtocol.formatHdata({ + id: 'bufinfo', + path: 'buffer:gui_buffers(*)', + keys: ['number,full_name,short_name,title'] + })); + doSend(WeeChatProtocol.formatSync({})); - send += "(bufinfo) hdata buffer:gui_buffers(*) number,full_name,short_name,title\n"; - send += "sync\n"; $log.info("Connected to relay"); - doSend(send); $rootScope.connected = true; $rootScope.$apply(); } @@ -496,13 +361,18 @@ weechat.factory('connection', ['$rootScope', '$log', 'handlers', 'colors', funct } var sendMessage = function(message) { - message = "input " + $rootScope.activeBuffer['full_name'] + " " + message + "\n" - doSend(message); + doSend(WeeChatProtocol.formatInput({ + buffer: models.getActiveBuffer()['fullName'], + data: message + })); } var getLines = function(count) { - var message = "(lineinfo) hdata buffer:gui_buffers(*)/own_lines/last_line(-"+count+")/data\n"; - doSend(message) + doSend(WeeChatProtocol.formatHdata({ + id: 'lineinfo', + path: "buffer:gui_buffers(*)/own_lines/last_line(-"+count+")/data", + keys: [] + })); } return { @@ -513,8 +383,8 @@ weechat.factory('connection', ['$rootScope', '$log', 'handlers', 'colors', funct } }]); -weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', 'connection', function ($rootScope, $scope, $store, connection) { - +weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', 'models', 'connection', function ($rootScope, $scope, $store, models, connection, testService) { + // Request notification permission Notification.requestPermission(function (status) { console.log('Notification permission status:',status); @@ -529,30 +399,38 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', 'connection } } + + $scope.buffers = models.model.buffers; + $scope.activeBuffer = models.getActiveBuffer + + $scope.incrementAge = function () { + models.model.age++; + models.model.cats.push('nouveau chat'); + } + + + $scope.clickS = function () { + $scope.countS = testService.incrementCount(); + }; + $rootScope.commands = [] + + $rootScope.models = models; $rootScope.buffer = [] - $rootScope.buffers = {} - $rootScope.activeBuffer = null; + $store.bind($scope, "hostport", "localhost:9001"); $store.bind($scope, "proto", "weechat"); $store.bind($scope, "password", ""); + $store.bind($scope, "ssl", false); // TODO checkbox for saving password or not? // $scope.password = ""; - $rootScope.closeBuffer = function(buffer_pointer) { - delete($rootScope.buffers[buffer_pointer]); - var first_buffer = _.keys($rootScope.buffers)[0]; - $scope.setActiveBuffer(first_buffer); - } $scope.setActiveBuffer = function(key) { - $rootScope.activeBuffer['active'] = false; - $rootScope.buffers[key]['active'] = true; - $rootScope.buffers[key]['highlight'] = false; - $rootScope.buffers[key]['unread'] = ''; - $rootScope.activeBuffer = $rootScope.buffers[key]; - $rootScope.pageTitle = $rootScope.activeBuffer['short_name'] + ' | ' + $rootScope.activeBuffer['title']; + models.setActiveBuffer(key); + var ab = models.getActiveBuffer(); + $rootScope.pageTitle = ab.shortName + ' | ' + ab.title; $rootScope.scrollToBottom(); }; @@ -562,14 +440,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', 'connection } }); - $rootScope.addLine = function(buffer, line) { - $rootScope.buffers[buffer]['lines'].push(line); - // Scroll if needed - if ($rootScope.activeBuffer['id'] == buffer) { - $rootScope.scrollToBottom(); - } - } - $rootScope.scrollToBottom = function() { setTimeout(function() { window.scrollTo(0, window.scrollMaxY); @@ -590,22 +460,18 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', 'connection } /* Function gets called from bufferLineAdded code if user should be notified */ - $rootScope.createHighlight = function(prefix, text, message, buffer, additionalContent) { - var prefixs = ""; - prefixs += prefix[0].text; - if(prefix[1] != undefined) { - prefixs += prefix[1].text; - } + $rootScope.createHighlight = function(buffer, message) { var messages = ""; - messages += text[0].text; + message.content.forEach(function(part) { + if (part.text != undefined) + messages += part.text + " "; + }); - var buffers = $rootScope.buffers[buffer]; - - var title = buffers.full_name; - var content = "<"+prefixs+">"+messages; + var title = buffer.fullName; + var content = messages; var timeout = 15*1000; - console.log('Displaying notification:',title,',with timeout:',timeout); + console.log('Displaying notification:buffer:',buffer,',message:',message,',with timeout:',timeout); var notification = new Notification(title, {body:content, icon:'img/favicon.png'}); // Cancel notification automatically notification.onshow = function() { diff --git a/js/weechat-protocol.js b/js/weechat-protocol.js new file mode 100644 index 0000000..05b3096 --- /dev/null +++ b/js/weechat-protocol.js @@ -0,0 +1,655 @@ +/** + * WeeChat protocol handling. + * + * This object parses messages and formats commands for the WeeChat + * protocol. It's independent from the communication layer and thus + * may be used with any network mechanism. + */ +var WeeChatProtocol = function() { + // specific parsing for each message type + this._types = { + 'chr': this._getChar, + 'int': this._getInt, + 'str': this._getString, + 'inf': this._getInfo, + 'hda': this._getHdata, + 'ptr': this._getPointer, + 'lon': this._getStrNumber, + 'tim': this._getTime, + 'buf': this._getString, + 'arr': this._getArray, + 'htb': this._getHashTable, + 'inl': function() { + this._warnUnimplemented('infolist'); + } + }; + + // string value for some message types + this._typesStr = { + 'chr': this._strDirect, + 'str': this._strDirect, + 'int': this._strToString, + 'tim': this._strToString, + 'ptr': this._strDirect + }; +}; + +/** + * Unsigned integer array to string. + * + * @param uia Unsigned integer array + * @return Decoded string + */ +WeeChatProtocol._uia2s = function(uia) { + var str = []; + + for (var c = 0; c < uia.length; c++) { + str.push(String.fromCharCode(uia[c])); + } + + return decodeURIComponent(escape(str.join(''))); +}; + +/** + * Merges default parameters with overriding parameters. + * + * @param defaults Default parameters + * @param override Overriding parameters + * @return Merged parameters + */ +WeeChatProtocol._mergeParams = function(defaults, override) { + for (var v in override) { + defaults[v] = override[v]; + } + + return defaults; +} + +/** + * Formats a command. + * + * @param id Command ID (null for no ID) + * @param name Command name + * @param parts Command parts + * @return Formatted command string + */ +WeeChatProtocol._formatCmd = function(id, name, parts) { + var cmdIdName; + var cmd; + + cmdIdName = (id !== null) ? '(' + id + ') ' : ''; + cmdIdName += name; + parts.unshift(cmdIdName); + cmd = parts.join(' '); + cmd += '\n'; + + return cmd; +}; + +/** + * Formats an init command. + * + * @param params Parameters: + * password: password (optional) + * compression: compression ('off' or 'zlib') (optional) + * @return Formatted init command string + */ +WeeChatProtocol.formatInit = function(params) { + var defaultParams = { + password: null, + compression: 'off' + }; + var keys = []; + var parts = []; + + params = WeeChatProtocol._mergeParams(defaultParams, params); + keys.push('compression=' + params.compression); + if (params.password !== null) { + keys.push('password=' + params.password); + } + parts.push(keys.join(',')); + + return WeeChatProtocol._formatCmd(null, 'init', parts); +}; + +/** + * Formats an hdata command. + * + * @param params Parameters: + * id: command ID (optional) + * path: hdata path (mandatory) + * keys: array of keys (optional) + * @return Formatted hdata command string + */ +WeeChatProtocol.formatHdata = function(params) { + var defaultParams = { + id: null, + keys: null + }; + var parts = []; + + params = WeeChatProtocol._mergeParams(defaultParams, params); + parts.push(params.path); + if (params.keys !== null) { + parts.push(params.keys.join(',')); + } + + return WeeChatProtocol._formatCmd(params.id, 'hdata', parts); +}; + +/** + * Formats an info command. + * + * @param params Parameters: + * id: command ID (optional) + * name: info name (mandatory) + * @return Formatted info command string + */ +WeeChatProtocol.formatInfo = function(params) { + var defaultParams = { + id: null + }; + var parts = []; + + params = WeeChatProtocol._mergeParams(defaultParams, params); + parts.push(params.name); + + return WeeChatProtocol._formatCmd(params.id, 'info', parts); +}; + +/** + * Formats a nicklist command. + * + * @param params Parameters: + * id: command ID (optional) + * buffer: buffer name (optional) + * @return Formatted nicklist command string + */ +WeeChatProtocol.formatNicklist = function(params) { + var defaultParams = { + id: null, + buffer: null + }; + var parts = []; + + params = WeeChatProtocol._mergeParams(defaultParams, params); + if (params.buffer !== null) { + parts.push(params.buffer); + } + + return WeeChatProtocol._formatCmd(params.id, 'nicklist', parts); +}; + +/** + * Formats an input command. + * + * @param params Parameters: + * id: command ID (optional) + * buffer: target buffer (mandatory) + * data: input data (mandatory) + * @return Formatted input command string + */ +WeeChatProtocol.formatInput = function(params) { + var defaultParams = { + id: null + }; + var parts = []; + + params = WeeChatProtocol._mergeParams(defaultParams, params); + parts.push(params.buffer); + parts.push(params.data); + + return WeeChatProtocol._formatCmd(params.id, 'input', parts); +}; + +/** + * Formats a sync or a desync command. + * + * @param params Parameters (see _formatSync and _formatDesync) + * @return Formatted sync/desync command string + */ +WeeChatProtocol._formatSyncDesync = function(cmdName, params) { + var defaultParams = { + id: null, + buffers: null, + options: null + }; + var parts = []; + + params = WeeChatProtocol._mergeParams(defaultParams, params); + if (params.buffers !== null) { + parts.push(params.buffers.join(',')); + if (params.options !== null) { + parts.push(params.options.join(',')); + } + } + + return WeeChatProtocol._formatCmd(params.id, cmdName, parts); +} + +/** + * Formats a sync command. + * + * @param params Parameters: + * id: command ID (optional) + * buffers: array of buffers to sync (optional) + * options: array of options (optional) + * @return Formatted sync command string + */ +WeeChatProtocol.formatSync = function(params) { + return WeeChatProtocol._formatSyncDesync('sync', params); +}; + +/** + * Formats a desync command. + * + * @param params Parameters: + * id: command ID (optional) + * buffers: array of buffers to desync (optional) + * options: array of options (optional) + * @return Formatted desync command string + */ +WeeChatProtocol.formatDesync = function(params) { + return WeeChatProtocol._formatSyncDesync('desync', params); +}; + +/** + * Formats a test command. + * + * @param params Parameters: + * id: command ID (optional) + * @return Formatted test command string + */ +WeeChatProtocol.formatTest = function(params) { + var defaultParams = { + id: null + }; + var parts = []; + + params = WeeChatProtocol._mergeParams(defaultParams, params); + + return WeeChatProtocol._formatCmd(params.id, 'test', parts); +}; + +/** + * Formats a quit command. + * + * @return Formatted quit command string + */ +WeeChatProtocol.formatQuit = function() { + return WeeChatProtocol._formatCmd(null, 'quit', []); +}; + +/** + * Formats a ping command. + * + * @param params Parameters: + * id: command ID (optional) + * args: array of custom arguments (optional) + * @return Formatted ping command string + */ +WeeChatProtocol.formatPing = function(params) { + var defaultParams = { + id: null, + args: null + }; + var parts = []; + + params = WeeChatProtocol._mergeParams(defaultParams, params); + if (params.args !== null) { + parts.push(params.args.join(' ')); + } + + return WeeChatProtocol._formatCmd(params.id, 'ping', parts); +}; + +WeeChatProtocol.prototype = { + /** + * Warns that message parsing is not implemented for a + * specific type. + * + * @param type Message type to display + */ + _warnUnimplemented: function(type) { + console.log('Warning: ' + type + ' message parsing is not implemented'); + }, + + /** + * Reads a 3-character message type token value from current + * set data. + * + * @return Type + */ + _getType: function() { + var t = this._getSlice(3); + + if (!t) { + return null; + } + + return WeeChatProtocol._uia2s(new Uint8Array(t)); + }, + + /** + * Runs the appropriate read routine for the specified message type. + * + * @param type Message type + * @return Data value + */ + _runType: function(type) { + var cb = this._types[type]; + var boundCb = cb.bind(this); + + return boundCb(); + }, + + /** + * Reads a "number as a string" token value from current set data. + * + * @return Number as a string + */ + _getStrNumber: function() { + var len = this._getByte(); + var str = this._getSlice(len); + + return WeeChatProtocol._uia2s(new Uint8Array(str)); + }, + + /** + * Returns the passed object. + * + * @param obj Object + * @return Passed object + */ + _strDirect: function(obj) { + return obj; + }, + + /** + * Calls toString() on the passed object and returns the value. + * + * @param obj Object to call toString() on + * @return String value of object + */ + _strToString: function(obj) { + return obj.toString(); + }, + + /** + * Gets the string value of an object representing the message + * value for a specified type. + * + * @param obj Object for which to get the string value + * @param type Message type + * @return String value of object + */ + _objToString: function(obj, type) { + var cb = this._typesStr[type]; + var boundCb = cb.bind(this); + + return boundCb(obj); + }, + + /** + * Reads an info token value from current set data. + * + * @return Info object + */ + _getInfo: function() { + var info = {}; + info.key = this._getString(); + info.value = this._getString(); + + return info; + }, + + /** + * Reads an hdata token value from current set data. + * + * @return Hdata object + */ + _getHdata: function() { + var self = this; + var paths; + var count; + var objs = []; + var hpath = this._getString(); + + keys = this._getString().split(','); + paths = hpath.split('/'); + count = this._getInt(); + + keys = keys.map(function(key) { + return key.split(':'); + }); + + for (var i = 0; i < count; i++) { + var tmp = {}; + + tmp.pointers = paths.map(function(path) { + return self._getPointer(); + }); + keys.forEach(function(key) { + tmp[key[0]] = self._runType(key[1]); + }); + objs.push(tmp); + }; + + return objs; + }, + + /** + * Reads a pointer token value from current set data. + * + * @return Pointer value + */ + _getPointer: function() { + return this._getStrNumber(); + }, + + /** + * Reads a time token value from current set data. + * + * @return Time value (Date) + */ + _getTime: function() { + var str = this._getStrNumber(); + + return new Date(parseInt(str) * 1000); + }, + + /** + * Reads an integer token value from current set data. + * + * @return Integer value + */ + _getInt: function() { + var parsedData = new Uint8Array(this._getSlice(4)); + + return ((parsedData[0] & 0xff) << 24) | + ((parsedData[1] & 0xff) << 16) | + ((parsedData[2] & 0xff) << 8) | + (parsedData[3] & 0xff); + }, + + /** + * Reads a byte from current set data. + * + * @return Byte value (integer) + */ + _getByte: function() { + var parsedData = new Uint8Array(this._getSlice(1)); + + return parsedData[0]; + }, + + /** + * Reads a character token value from current set data. + * + * @return Character (string) + */ + _getChar: function() { + return this._getByte(); + }, + + /** + * Reads a string token value from current set data. + * + * @return String value + */ + _getString: function() { + var l = this._getInt(); + + if (l > 0) { + var s = this._getSlice(l); + var parsedData = new Uint8Array(s); + + return WeeChatProtocol._uia2s(parsedData); + } + + return ""; + }, + + /** + * Reads a message header from current set data. + * + * @return Header object + */ + _getHeader: function() { + var len = this._getInt(); + var comp = this._getByte(); + + return { + length: len, + compression: comp, + }; + }, + + /** + * Reads a message header ID from current set data. + * + * @return Message ID (string) + */ + _getId: function() { + return this._getString(); + }, + + /** + * Reads an arbitrary object token from current set data. + * + * @return Object value + */ + _getObject: function() { + var self = this; + var type = this._getType(); + + if (type) { + return { + type: type, + content: self._runType(type), + }; + } + }, + + /** + * Reads an hash table token from current set data. + * + * @return Hash table + */ + _getHashTable: function() { + var self = this; + var typeKeys, typeValues, count; + var dict = {}; + + typeKeys = this._getType(); + typeValues = this._getType(); + count = this._getInt(); + + for (var i = 0; i < count; ++i) { + var key = self._runType(typeKeys); + var keyStr = self._objToString(key, typeKeys); + var value = self._runType(typeValues); + dict[keyStr] = value; + } + + return dict; + }, + + /** + * Reads an array token from current set data. + * + * @return Array + */ + _getArray: function() { + var self = this; + var type; + var count; + var values; + + type = this._getType(); + count = this._getInt(); + values = []; + + for (var i = 0; i < count; i++) { + values.push(self._runType(type)); + }; + + return values; + }, + + /** + * Reads a specified number of bytes from current set data. + * + * @param length Number of bytes to read + * @return Sliced array + */ + _getSlice: function(length) { + if (this.dataAt + length > this._data.byteLength) { + return null; + } + + var slice = this._data.slice(this._dataAt, this._dataAt + length); + + this._dataAt += length; + + return slice; + }, + + /** + * Sets the current data. + * + * @param data Current data + */ + _setData: function (data) { + this._data = data; + }, + + /** + * Parses a WeeChat message. + * + * @param data Message data (ArrayBuffer) + * @return Message value + */ + parse: function(data) { + var self = this; + + this._setData(data); + this._dataAt = 0; + + var header = this._getHeader(); + var id = this._getId(); + var objects = []; + var object = this._getObject(); + + while (object) { + objects.push(object); + object = self._getObject(); + } + + return { + header: header, + id: id, + objects: objects, + }; + } +}; From 5ae3ca27ca9dfe3a6f2609b8b2b57e3ee02b8523 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Thu, 10 Oct 2013 12:24:11 +0200 Subject: [PATCH 24/26] Fix the metadata return value --- js/models.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/models.js b/js/models.js index 8dc36d5..4608f11 100644 --- a/js/models.js +++ b/js/models.js @@ -76,9 +76,9 @@ models.service('models', ['colors', function(colors) { var displayed = message['displayed']; var highlight = message['highlight']; var content = parseLineAddedTextElements(message); - var text = ""; + var rtext = ""; if(text[0] != undefined) { - text = text[0]['text']; + rtext = text[0]['text']; } return { @@ -88,7 +88,7 @@ models.service('models', ['colors', function(colors) { tags: tags_array, highlight: highlight, displayed: displayed, - text: text, + text: rtext, } } From 21d19b5aac10a93ba6e7a7e6adb4a5f44ca85e40 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Thu, 10 Oct 2013 12:37:25 +0200 Subject: [PATCH 25/26] Fix the title change and rename events to use the new model --- js/websockets.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/js/websockets.js b/js/websockets.js index 4d473c4..37d1b41 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -230,16 +230,17 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'models', 'plugins', functi var handleBufferTitleChanged = function(message) { var obj = message['objects'][0]['content'][0]; var buffer = obj['pointers'][0]; - var old = $rootScope.buffers[buffer]; - old['full_name'] = obj['full_name']; - old['title'] = obj['title']; + var old = models.getBuffer(buffer); + old.fullName = obj['full_name']; + old.title = obj['title']; + old.number = obj['number']; } var handleBufferRenamed = function(message) { var obj = message['objects'][0]['content'][0]; var buffer = obj['pointers'][0]; - var old = $rootScope.buffers[buffer]; - old['full_name'] = obj['full_name']; - old['short_name'] = obj['short_name']; + var old = models.getBuffer(buffer); + old.fullName = obj['full_name']; + old.shortName = obj['short_name']; } From 340915576b883cc693797e6abf4f66f1546bef6a Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Thu, 10 Oct 2013 12:49:04 +0200 Subject: [PATCH 26/26] Display full name when shortName is missing --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 3eb0594..5e7f7cc 100644 --- a/index.html +++ b/index.html @@ -31,7 +31,7 @@