- new feature: aliases v0.9-rc1
authorfoldericon <foldericon@gmail.com>
Fri, 9 Nov 2012 18:42:42 +0000 (19:42 +0100)
committerfoldericon <foldericon@gmail.com>
Fri, 9 Nov 2012 18:42:42 +0000 (19:42 +0100)
- new feature: perform
- improved settings dialog
- many many bug fixes

.version [new file with mode: 0644]
JIRC.js
README
README.txt
lib/IRC.js
public/classes.js
public/index.html
public/main.css
public/main.js
scripts/.dontremove [deleted file]

diff --git a/.version b/.version
new file mode 100644 (file)
index 0000000..660ad2a
--- /dev/null
+++ b/.version
@@ -0,0 +1 @@
+v0.9-rc1
diff --git a/JIRC.js b/JIRC.js
index 09541dee2c0cbe1025aae296d05068f47b4e7b25..512b7d19cf91f33329f366be1b41f9dea85c76fa 100644 (file)
--- a/JIRC.js
+++ b/JIRC.js
@@ -36,11 +36,19 @@ var http = require('http'),
     url = require('url'),
     fs = require('fs'),        
     static = require('node-static'),
+    getyt = require('request'),
     file = new(static.Server)('./public', { cache: 7200, headers: {'X-Hello':'World!'} }),
     httpServer = http.createServer(function(request, response) {
             var queryData = "";        
         request.on('data', function(data) {
             var path = url.parse(request.url).pathname; 
+            if(path=="/youtube"){
+                queryData += data;
+                if(queryData.length > 1e6) {
+                    response.writeHead(413, {'Content-Type': 'text/plain'});                
+                    request.connection.destroy();                
+                }            
+            }
             if(path=="/resume"){        
                 queryData += data;
                 if(queryData.length > 1e6) {
@@ -58,8 +66,8 @@ var http = require('http'),
             }
         });
         
-        request.addListener('end', function () {    
-            var path = url.parse(request.url).pathname;
+        request.addListener('end', function () {            
+            var path = url.parse(request.url).pathname;            
             if(path=="/emoticons"){
                 var emoticons = fs.readFileSync(
                     __dirname + '/public/images/emoticons/Emoticons.plist', 'utf8'
@@ -76,6 +84,7 @@ var http = require('http'),
                 response.writeHead(200, {"Content-Type": "application/json"});               
                 response.end(JSON.stringify(global.settings));
                 if(queryData) {
+                       console.log(queryData);
                     global.settings=JSON.parse(queryData);
                 }
             } else{
diff --git a/README b/README
index b29838f505ccc76fb0f30c71286c442ab0579ac9..f7da8a5ba27614b75590133df94151c5eac6a40f 100644 (file)
--- a/README
+++ b/README
@@ -15,6 +15,13 @@ but please send me your improvements.
 Changelog
 ---------
 
+v0.9-rc1
+- new feature: aliases
+- new feature: perform
+- improved settings dialog
+- many many bug fixes
+
+v0.9-beta2
 - Connection-Settings will be saved now using local storage
 - Colors (and color stripping) are now working correctly
   (0000002, 0000009)
@@ -32,7 +39,6 @@ Known Issues
 
 - No error-handling in the backend
 - No error-handling in UI-dialogs
-- Wrong size of user-list while changing size
 - Only one connection per time allowed
 - Not multi-user ready
 
@@ -43,14 +49,8 @@ Browser Support
 - Tested Browsers:
  Firefox 16
  Safari 6
- to be continued ...
-
-- Browsers that should work:
- Chrome 14+
- Firefox 7+
- Safari 5+
- Opera ? 
- Internet Explorer 9+
+ Opera 12.02
+ Chrome 22
 
 
 Installation
index 5513e40415816ee5a1d45cbfbaccf782c8ab5aae..f10b5860dc199cac5087c5f226df72e5ec400454 100644 (file)
@@ -15,6 +15,13 @@ but please send me your improvements.
 Changelog\r
 ---------\r
 \r
+v0.9-rc1\r
+- new feature: aliases\r
+- new feature: perform\r
+- improved settings dialog\r
+- many many bug fixes\r
+\r
+v0.9-beta2\r
 - Connection-Settings will be saved now using local storage\r
 - Colors (and color stripping) are now working correctly\r
   (0000002, 0000009)\r
@@ -33,7 +40,6 @@ Known Issues
 - No error-handling in the backend\r
 - No error-handling in UI-dialogs\r
 - no saving of connection-settings\r
-- Wrong size of user-list while changing size\r
 - Only one connection per time allowed\r
 - Not multi-user ready\r
 \r
@@ -41,17 +47,11 @@ Known Issues
 Browser Support\r
 ----------------\r
 \r
-Tested Browsers: \r
-\r
-Firefox 16\r
-Safari 6 to be continued ...\r
-\r
-- Browsers that should work:\r
- Chrome 14+\r
- Firefox 7+\r
- Safari 5+\r
- Opera ? \r
- Internet Explorer 9+\r
+- Tested Browsers:\r
+ Firefox 16\r
+ Safari 6\r
+ Opera 12.02\r
+ Chrome 22\r
 \r
 \r
 Installation\r
@@ -60,4 +60,4 @@ Installation
 1. Download and install NodeJS from http://nodejs.org\r
 2. open a terminal and cd into the JIRC-directory\r
 3. type in "node JIRC.js"\r
-4. that's it
\ No newline at end of file
+4. that's it\r
index d14a5da7bf8e16c8aaa6f7dcc61b37de35521e04..76a1ca3b391965fc4e4bdfb9951036effc489a9b 100644 (file)
@@ -99,7 +99,8 @@ var util = require('util'),
     _ = require('underscore'),
     growl = require('growl'),
     request = require('request');
- //   var buffer, ignoredb, listeners, socket;
+//    irc = require('irc');
+//    var buffer, ignoredb, listeners, socket;
        var buffer, listener, socket;
     socket = new net.Socket();
     socket.setNoDelay(true);
@@ -129,6 +130,7 @@ var util = require('util'),
 
     socket.on('data', function (data) {
         var newlineIdx;
+//        console.log(data.rawCommand+' ' +data.args.join());
         data = data.replace('\r', '');
         while ((newlineIdx = data.indexOf('\n')) > -1) {   
             if (buffer.size > 0) {
@@ -282,6 +284,28 @@ var util = require('util'),
         port = port || 6667;
         pass = pass || '';
         global.nickname = nickname;
+        /*
+        socket = new irc.Client(host, nickname, { 
+                                    autoConnect: false, 
+                                    userName: sanitize(username),
+                                    realName: sanitize(nickname),
+                                    port: port,
+                                    debug: false,
+                                    showErrors: false,
+                                    autoRejoin: true,
+                                    autoConnect: true,
+                                    channels: [],
+                                    secure: false,
+                                    selfSigned: false,
+                                    certExpired: false,
+                                    floodProtection: false,
+                                    floodProtectionDelay: 1000,
+                                    stripColors: false,
+                                    channelPrefixes: "&#",
+                                    messageSplit: 512
+        });
+        socket.connect();
+        */
         socket.connect(port, host, function () {
             if(i==0){
             if(pass) send('PASS ' + sanitize(pass));
@@ -289,12 +313,13 @@ var util = require('util'),
             send('USER ' + sanitize(username) + ' localhost * ' + sanitize(realname));
             i=1;
             }
-        });
+        });                
+
     }
 
         this.loadScripts = function () {
             var i, k, script, scripts;
-            socket.pause();
+            if(socket) socket.pause();
             listeners = [];
             scripts = fs.readdirSync('scripts');
             if (scripts) {
index 7396fa749e2bc7a20408c7833ac69aae28979eb8..2840d578485b887789819df989e56592d3147075 100644 (file)
@@ -73,10 +73,9 @@ var Query = {
         }
     },
        createWindow : function(){
-        var dock_icon, win, content, panel;
+        var win, content, panel;
         panel = $$('.con_panel')[0];
-        dock_icon = document.createElement("span");
-        this.dock_icon = dock_icon;
+        this.dock_icon = document.createElement("span");
 //        dock_icon.className = "icon_active";
         this.dock_icon.className = "icon_waiting";
         panel.appendChild(dock_icon); 
@@ -98,9 +97,11 @@ var Query = {
         });
         this.dock_icon.win = win;
 //        $('cons').appendChild(panel);
-        content = $$('.querytemplate').first().cloneNode(true);    
-        content.style.display = 'block';        
+        content = $$('.querytemplate').first().cloneNode(true);  
         win.getContent().appendChild(content);         
+        $$('#'+win.getContent().id+' .content').first().update();
+        $$('#'+win.getContent().id+' .textbox').first().value="";
+        content.style.display = 'block';                
 //        win.show();      
         $(dock_icon).update(win.getTitle().split(' ')[0]);
         Event.observe(this.dock_icon, "mouseup", Windows.restore);
@@ -129,11 +130,15 @@ var Channel = {
           return this;
        },
        setTopic : function(topic) {
+          this.topic = topic;
           if(topic){
           this.topic=topic;
-             this.win.setTitle(this.name + " - Topic: " + topic);
+             this.win.setTitle('<div class="topic" style="width:'+(parseInt(this.win.getSize()['width'])-22)+'px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>' + this.name + '</b> - Topic: ' + topic + '</div>');
           }
        },
+       getTopic : function() {        
+        return this.topic;
+       },      
     setWaiting : function(mode) {
         if(mode == 0) {
             if(this.dock_icon.className == "dock_icon")
@@ -433,7 +438,27 @@ var Utf8 = {
         connection.send(data);
     }
     IRCConnection.getSettings = function() {
-        settings='';
+
+        var obj, aliases = [], performs = [], strAliases = $$('.aliases tbody').first().innerHTML, strPerform = $$('.perform tbody').first().innerHTML;
+        settings = {};
+        if(strAliases.match(/<tr>.+<\/tr>/)){
+            for (var x=0; x<strAliases.match(/<tr>.*?<\/tr>/g).length; x++){
+                if(strAliases.match(/<tr>.*?<\/tr>/g)[x].match(/<td>(.*?)<\/td><td>(.*?)<\/td>/)){
+                    obj = {};
+                    obj.key = strAliases.match(/<tr>.*?<\/tr>/g)[x].match(/<td>(.*?)<\/td><td>(.*?)<\/td>/)[1];
+                    obj.value = strAliases.match(/<tr>.*?<\/tr>/g)[x].match(/<td>(.*?)<\/td><td>(.*?)<\/td>/)[2];
+                }
+                aliases.push(obj);                            
+            }
+        }
+        settings.aliases=aliases;
+        if(strPerform.match(/<tr>.+<\/tr>/)){
+            for (var x=0; x<strPerform.match(/<tr>.*?<\/tr>/g).length; x++){
+                performs.push(strPerform.match(/<tr>.*?<\/tr>/g)[x].match(/<td>(.*?)<\/td>/)[1]);
+            }            
+        }        
+        settings.perform=performs;
+
         new Ajax.Request('/settings', {
             method:'post',
             contentType:'application/json',
@@ -459,26 +484,85 @@ var Utf8 = {
                     if(data.nma == "on") $('config')['nma'].checked = true;
                     if(data.nmakey != "") $('config')['nmakey'].value = data.nmakey;
                     if(data.nmapriority != "") $('config')['nmapriority'].value = data.nmapriority;
-                    settings = data;
+                    data.aliases = JSON.parse(data.aliases); 
+                    data.perform = JSON.parse(data.perform);   
+                    settings = data;                                    
+                } else { 
+                    settings = JSON.parse(localStorage.getItem('settings'));
+                    settings.aliases = JSON.parse(settings.aliases);
+                    settings.perform = JSON.parse(settings.perform);                    
+                }      
+                if(settings.aliases){
+                    var elmAliases = $$('.aliases tbody').first();
+                    if(elmAliases){
+                        $$('.aliases tbody').each(function(elm){
+                            elm.update();                            
+                            for(var x=0; x<settings.aliases.length; x++){                                             
+                                elm.update(elm.innerHTML + '<tr><td>' +  settings.aliases[x].key + '</td><td>' + settings.aliases[x].value+ '</td></tr>\n');
+                            }
+                        });                            
+                        $$('.aliases tbody tr').each(function(elm){
+                            Event.observe(elm, "mousedown", function(event) {
+                                $$('.aliases tbody tr').each(function(tr){tr.removeClassName('selected')});                            
+                                var td = Event.element(event); debug(td.parentNode); 
+                                td.parentNode.addClassName('selected')
+                            });
+                        });                
+                    }
                 }
+                if(settings.perform){           
+                    var elmPerform = $$('.perform tbody').first();
+                    if(elmPerform){
+                        $$('.perform tbody').each(function(elm){                            
+                            elm.update();                            
+                            for(var x=0; x<settings.perform.length; x++){                     
+                                elm.update(elm.innerHTML + '<tr><td>' +  settings.perform[x] + '</td></tr>\n');
+                            }
+                        });
+                        $$('.perform tbody tr').each(function(elm){
+                            Event.observe(elm, "mousedown", function(event) {
+                                $$('.perform tbody tr').each(function(tr){tr.removeClassName('selected')});                            
+                                var td = Event.element(event); debug(td.parentNode); 
+                                td.parentNode.addClassName('selected')
+                            });
+                        });                            
+                    }                        
+                }                
             }
-        });
-    
+        });        
     }
     IRCConnection.saveSettings = function(data) {
+        var obj, aliases = [], performs = [], strAliases = $$('.aliases tbody').first().innerHTML, strPerform = $$('.perform tbody').first().innerHTML;
+        settings = {};
+        settings=data;
+        if(strAliases.match(/<tr.*>.+<\/tr>/g)){
+            for (var x=0; x<strAliases.match(/<tr.*>.+<\/tr>/gi).length; x++){
+                obj = {};
+                obj.key = strAliases.match(/<tr.*>.*?<\/tr>/g)[x].match(/<td.*>(.+)<\/td><td>(.+)<\/td>/)[1];
+                obj.value = strAliases.match(/<tr.*>.*?<\/tr>/g)[x].match(/<td.*>(.+)<\/td><td>(.+)<\/td>/)[2];
+                aliases.push(obj);
+            }
+        }
+        settings.aliases=aliases;
+        if(strPerform.match(/<tr.*>.+<\/tr>/)){
+            for (var x=0; x<strPerform.match(/<tr.*>.*?<\/tr>/g).length; x++){
+                performs.push(strPerform.match(/<tr.*>.*?<\/tr>/g)[x].match(/<td>(.*?)<\/td>/)[1]);
+            }            
+        }        
+        settings.perform=performs;
         new Ajax.Request('/settings', {
           method:'post',
           contentType:'application/json',
-          postBody:JSON.stringify(data),
+          postBody:JSON.stringify(settings),
           asynchronous:true,
           onSuccess: function (req) {
-    //        sendInfoResponse(req.responseText);
               IRCConnection.getSettings();     
           }
-        });    
+        }); 
+        localStorage.setItem('settings', JSON.stringify(settings));
     }
     
-    IRCConnection.showSettings = function() {
+    IRCConnection.showSettings = function() {    
         IRCConnection.getSettings();
         Dialog.confirm($('settings').innerHTML, {
                             className:"alphacube", 
@@ -492,6 +576,149 @@ var Utf8 = {
                             showEffect:Element.show, 
                             hideEffect:Element.hide
         });    
+        
+        $$('.aliases tbody tr').each(function(elm){
+            Event.observe(elm, "mousedown", function(event) {
+                $$('.aliases tbody tr').each(function(tr){tr.removeClassName('selected')});                            
+                var td = Event.element(event);
+                td.parentNode.addClassName('selected')
+            });
+        
+        });
+
+        $$('.perform tbody tr').each(function(elm){
+            Event.observe(elm, "mousedown", function(event) {
+                $$('.perform tbody tr').each(function(tr){tr.removeClassName('selected')});                            
+                var td = Event.element(event);
+                td.parentNode.addClassName('selected')
+            });
+        
+        });
+                                    
+        $$('.set1 .alias_edit input').each(function(elm){   
+            Event.observe(elm, "mouseup", function(event) {
+                var edit = Event.element(event);
+                if(edit.value=="add"){
+                    Dialog.confirm($('dialog_alias').innerHTML, {
+                        className:"alphacube", 
+                        width:250, 
+                        okLabel: "save", 
+                        cancelLabel: "cancel",
+                        ok:function() {
+                            $$('.aliases tbody').first().update($$('.aliases tbody').first().innerHTML + "<tr><td>" + $F('input_alias') + "</td><td>" + $F('input_cmd') +" </td></tr>\n");
+                            $$('.aliases tbody tr').each(function(elm){
+                                Event.observe(elm, "mousedown", function(event) {
+                                    $$('.aliases tbody tr').each(function(tr){tr.removeClassName('selected')});                            
+                                    var td = Event.element(event);
+                                    td.parentNode.addClassName('selected')
+                                });
+                            
+                            });                            
+                            return true;
+                        }, 
+                        showEffect:Element.show, 
+                        hideEffect:Element.hide
+                    });    
+                } else if(edit.value=="del"){
+                    var x=0, a;
+                    $$('.aliases tbody tr').each(function(tr){
+                        if(tr.className == "selected"){
+                            a=x;
+                            tr.remove();
+                        }
+                        x++;
+                    });
+                    $$('.aliases tbody tr')[a].addClassName('selected');                    
+                } else if(edit.value=="edit"){            
+                    Dialog.confirm($('dialog_alias').innerHTML, {
+                        className:"alphacube", 
+                        width:250, 
+                        okLabel: "save", 
+                        cancelLabel: "cancel",
+                        ok:function() {
+                           $$('.aliases tbody tr').each(function(tr){
+                                if(tr.className=="selected") {
+                                    tr.update('<td>' + $$('.form_alias input')[0].value + '</td><td>' + $$('.form_alias input')[1].value + '</td>');                            
+                                    tr.removeClassName('selected');
+                                }
+                            });
+                            return true;
+                        }, 
+                        showEffect:Element.show, 
+                        hideEffect:Element.hide
+                    });    
+                   $$('.aliases tbody tr').each(function(tr){
+                        if(tr.className=="selected") {
+                            $$('.form_alias input')[0].value=tr.innerHTML.match(/<td>(.*?)<\/td><td>(.*?)<\/td>/)[1];
+                            $$('.form_alias input')[1].value=tr.innerHTML.match(/<td>(.*?)<\/td><td>(.*?)<\/td>/)[2];                            
+                        }
+                    });                        
+                }
+            });
+        });
+        
+        $$('.set1 .perform_edit input').each(function(elm){   
+            Event.observe(elm, "mouseup", function(event) {
+                var edit = Event.element(event);
+                if(edit.value=="add"){
+                    Dialog.confirm($('dialog_perform').innerHTML, {
+                        className:"alphacube", 
+                        width:250, 
+                        okLabel: "save", 
+                        cancelLabel: "cancel",
+                        ok:function() {
+                            $$('.perform tbody').first().update($$('.perform tbody').first().innerHTML + "<tr><td>" + $F('input_perform') + "</td></tr>\n");
+                            $$('.perform tbody tr').each(function(elm){
+                                Event.observe(elm, "mousedown", function(event) {
+                                    $$('.perform tbody tr').each(function(tr){tr.removeClassName('selected')});                            
+                                    var td = Event.element(event);
+                                    td.parentNode.addClassName('selected')
+                                });
+                            
+                            });                            
+                            return true;
+                        }, 
+                        showEffect:Element.show, 
+                        hideEffect:Element.hide
+                    });    
+                } else if(edit.value=="del"){
+                    var x=0, a;
+                    $$('.perform tbody tr').each(function(tr){
+                        if(tr.className == "selected"){
+                            tr.remove();
+                            a=x;
+                        }
+                        x++;
+                    });
+                    $$('.perform tbody tr')[a].addClassName('selected');
+                } else if(edit.value=="edit"){            
+                    Dialog.confirm($('dialog_perform').innerHTML, {
+                        className:"alphacube", 
+                        width:250, 
+                        okLabel: "save", 
+                        cancelLabel: "cancel",
+                        ok:function() {
+                           $$('.perform tbody tr').each(function(tr){
+                                if(tr.className=="selected") {
+                                    tr.update('<td>' + $$('.form_perform input')[0].value + '</td>');                            
+                                    tr.removeClassName('selected');
+                                }
+                            });
+                            return true;
+                        }, 
+                        showEffect:Element.show, 
+                        hideEffect:Element.hide
+                    });    
+                   $$('.perform tbody tr').each(function(tr){
+                        if(tr.className=="selected") {
+                            $$('.form_perform input')[0].value=tr.innerHTML.match(/<td>(.*?)<\/td>/)[1];
+                        }
+                    });                        
+                }
+            });
+        });
+
+            
     }
     IRCConnection.create = function() {  
         Dialog.confirm($('login').innerHTML, {
@@ -523,7 +750,10 @@ var Utf8 = {
     }
     
     IRCConnection.handleInput = function(title, data) {
-        title = title.split(' ')[0];
+//        title = title.split(' ')[0];
+//        debug('TITLE ' + title);
+        if(getActiveChan()) title = getActiveChan().name;
+        else title = "status";
         if (data.substring(0,1) == "/") {
             var cmd = data.substring(1);
             cmd = cmd.replace(cmd.split(' ')[0], cmd.split(' ')[0].toUpperCase());
@@ -550,6 +780,9 @@ var Utf8 = {
                     case "PART":
                         if(title != 'status')                
                             cmd = 'PART ' + title + ' :' + cmd.substring(5);
+                        else
+                            if(title.substring(0,1) == "#") cmd = 'PART ' + cmd.split(' ')[1] + ' :' + cmd.split(' ')[2];
+                            else cmd = "";
                         break;
                     case "QUIT":
                             IRCConnection.quit();
@@ -560,12 +793,46 @@ var Utf8 = {
                         objQuery.win.show();
                         channels.push(objQuery);                    
                         return;
+                    default:
+                        var cmds;
+                        if(settings.aliases){
+                            debug('jo aliases');
+                            for (var x=0; x<settings.aliases.length;x++){
+                                if(cmd.match(/^\w{0,8}/)[0] == settings.aliases[x].key.substring(1).match(/^\w{0,8}/)[0].toUpperCase()){
+                                    cmds = settings.aliases[x].value.split(';');
+                                    var string, args;
+                                    for (var y=0; y<cmds.length; y++){
+                                        args1 = cmd.replace(/^\w{0,8} /,'').replace(/\s$/, '').split(' ');
+                                        args2 = cmds[y].substring(1).replace(/^\w{0,8} /,'').replace(/\s$/, '').split(' ');                                        
+                                        string = cmds[y].substring(1).match(/^\w{0,8}/)[0].toUpperCase();
+                                        for (var z=0; z<args2.length; z++){
+                                            string = string + " " + args2[z];                                        
+                                        }
+                                        if(args1){
+                                            if(string.match(/\$1/)) string = string.replace(/\$1/, args1[0]) || '';
+                                            if(string.match(/\$2/)) string = string.replace(/\$2/, args1[1]) || '';                                            
+                                            if(string.match(/\$3/)) string = string.replace(/\$3/, args1[2]) || '';
+                                            if(string.match(/\$selectedchan/)) string = string.replace(/\$selectedchan/, getActiveChan().name) || '';
+                                            if(string.match(/\$nick/)) string = string.replace(/\$nick/, nickname) || '';                                                                                                                                                                         
+                                        }
+                                        cmd = "";
+                                        IRCConnection.handleInput(title, '/'+string);
+//                                        connection.send(string);
+                                    }
+                                }
+                            }
+                        }
+                        break;                        
                 }
             }
-            connection.send(cmd);
+            if(cmd) connection.send(cmd);
         } else if(title != "status" && data.replace(/\s/g ,'') != "") connection.send('PRIVMSG ' + title + ' :' + data);
     }
     
+    IRCConnection.getChannels = function() {
+            return channels;
+    }
+        
     IRCConnection.handleRaw = function(data) {
         var raw = data.substring(3);
         var reg1 = /^:([^!]+)!.*PRIVMSG ([^ ]+) :/i;
@@ -597,10 +864,10 @@ var Utf8 = {
                     var objChan = getChannelByName(replyTo);
                     var objUser = objChan.getUserByNick(nick);
                     msg = stripCodes(raw.replace(/^:([^!]+)!.*PRIVMSG\ \#[\w\_\-\^]+\ \:/, ''));
-                    if(objChan.name != getActiveChan.name)
+                    if(objChan.name != getActiveChan().name)
                         objChan.setWaiting(0);
                     if(msg.indexOf(nickname)>-1){
-                        if(objChan.name != getActiveChan.name)
+                        if(objChan.name != getActiveChan().name)
                             objChan.setWaiting(1);
                         context = 'hl';
                     }
@@ -617,7 +884,7 @@ var Utf8 = {
                     objChan.addMessage(msg);
                 } else{
                     var objQuery, objUser;
-                     msg = stripCodes(raw.replace(/.*PRIVMSG [\w\_\-\^]+ :/, ''));                    
+                     msg = stripCodes(raw.replace(/.*PRIVMSG [\w\@\.\_\-\^]+ :/, ''));                    
                     if(hasQueryWithName(replyTo)){
                         objQuery = getChannelByName(replyTo);
                         objUser = objQuery.user;
@@ -631,7 +898,7 @@ var Utf8 = {
                         }
                     }
                     if(msg.indexOf(nickname)>-1){
-                        if(objQuery.name != getActiveChan.name)
+                        if(objQuery.name != getActiveChan().name)
                             objQuery.setWaiting(1);
                         context = 'hl';
                     }               
@@ -650,16 +917,11 @@ var Utf8 = {
             }
 
         }
-
-        IRCConnection.getChannels = function() {
-            return channels;
-        }
-
+        
         if (raw.match(reg2)) {
             // JOIN
             var chan = raw.replace(reg2, '').replace(/^:/, '').replace(/\s$/, ''), host = raw.match(/^:([^!]+)!([^!]+)@([\w.\-_]+)/)[0].substring(1).split('!');
             var msg = '<span class="statusmessage"><time> <font color="#0f0">→</font> <b>' + host[0] + '</b> (' + host[1] + ') joined the channel.</span>';
-            debug('CHANNAME ' +chan);
             var objChannel;
             if(host[0] == nickname){            
                 objChannel = Object.create(Channel).init(chan);
@@ -759,10 +1021,11 @@ var Utf8 = {
         if (raw.match(/^:([^!]+)!.*TOPIC /)) {
             // CHANGE TOPIC
             var host = raw.match(/^:([^!]+)!([^!]+)@([\w.\-_]+)/)[0].substring(1).split('!');            
-            var arrD = raw.replace(/^:([^!]+)!.*TOPIC /, '').split(' ');
-            var objChannel = getChannelByName(arrD[0]);
-            var msg = '<span class="statusmessage"><time> <b>' + host[0] + '</b> changed the topic to <b>' + arrD[1].substring(1) + '</b></span>';                            
-            objChannel.setTopic(arrD[1].substring(1));
+            var arrM = raw.match(/^:([^!]+)!.*TOPIC (\#[\w\_\-\^]+) \:(.+)/);
+            debug(arrM[1] + " " + arrM[2] + " " + arrM[3]);
+            var objChannel = getChannelByName(arrM[2]);
+            var msg = '<span class="statusmessage"><time> <b>' + host[0] + '</b> changed the topic to <b>' + arrM[3] + '</b></span>';                            
+            objChannel.setTopic(arrM[3]);
             objChannel.addMessage(msg);
         }        
         if (raw.match(reg8) || raw.match(/^NOTICE /)) {
@@ -855,7 +1118,7 @@ var Utf8 = {
             // TOPIC
             debug('TOPIC');            
             var topic = raw.replace(/^\:.+\s332\ .+\ \#[\w\_\-\^]+\ \:/, '');
-            var objChan = getChannelByName(raw.replace(/^:.+ 332 /, '').replace(/ :.+/, '').split(' ')[1].replace(/\s$/, ''));
+            var objChan = getChannelByName(raw.match(/^\:.+\s332\ .+\ (\#[\w\_\-\^]+) \:/)[1]);
             objChan.setTopic(stripCodes(topic));
         }                
         if(raw.match(/\:.+\s352/)){
@@ -892,11 +1155,21 @@ var Utf8 = {
             msg = '<span class="logmessage"><time> Your message couldn\'t be sent to the channel';
             objChan.addMessage(msg);
         }        
-        if(raw.match(/\:[A-Za-z0-9.]+ 001 ([A-Za-z0-9_\-\[\]\\^{}|`]+)/)){
-            nickname = raw.match(/\:[A-Za-z0-9.]+ 001 ([A-Za-z0-9_\-\[\]\\^{}|`]+)/)[1];
+        if(raw.match(/^\:[a-zA-Z0-9.-]+ 001/)){
+            debug('jo 001');
+            nickname = raw.match(/\:[a-zA-Z0-9.-]+ 001 ([A-Za-z0-9_\-\[\]\\^{}|`]+)/)[1];
+            window.setTimeout(function(){
+                if(settings.perform){
+                    debug('jo perform1');
+                    for (var x=0; x<settings.perform.length; x++){
+                        debug('jo send');
+                        IRCConnection.handleInput('status', settings.perform[x].replace(/\$nick/, nickname));
+                    }
+                }             
+            }, 1500);
             debug('NICK ' +nickname);
         }
-        if(raw.match(/\:[A-Za-z0-9.]+ 3(1[1-9]|2[0-9]|30)/)){
+        if(raw.match(/\:[A-Za-z0-9.-]+ 3(1[1-9]|2[0-9]|30)/)){
             // WHOIS
             var objChan = getActiveChan();
             if(objChan){
@@ -953,7 +1226,6 @@ var Utf8 = {
             }
         }                
     }
-    
     IRCConnection.quit = function() {
         $$('.con_panel span').each(function(icon) {
                 icon.win.close();
@@ -962,6 +1234,7 @@ var Utf8 = {
         $$('.con_panel').each(function(panel) {
             panel.remove();
         });    
+        channels = [];
         connection.close();
     }
 
@@ -998,7 +1271,6 @@ var Utf8 = {
     }
     
     function getColor(i) {
-        debug('JAU I ' + i);
         var c = ["FFF","000","00007F","009000","FF0000","7F0000","9F009F","FF7F00","FFFF00","00F800","00908F","00FFFF","0000FF","FF00FF","7F7F7F","CFD0CF"];    
         return c[parseInt(i)];
     }
@@ -1044,10 +1316,13 @@ var Utf8 = {
     IRCConnection.getActiveChan = getActiveChan;
     
     function getActiveChan() {
+        var chan;
         for(var x=0; x<channels.length;x++)
-            if(channels[x].dock_icon.className == 'icon_active' && channels[x].win.getTitle().substring(0,1) == '#')
-                return channels[x];
-        return null;
+            if(channels[x].dock_icon.className == 'icon_active')
+                chan = channels[x];
+        if(!chan && channels && channels.length > 0)
+            chan = channels[0];
+        return chan;
     }
         
     function getChannelByName(name){
@@ -1063,7 +1338,8 @@ var Utf8 = {
         panel.addClassName('dont_select');
         panel.style.display = "none";
         childs = $('cons').childNodes.length;
-        panel.style.top = (childs-2) * 26 + "px";    
+        panel.style.top = (childs-2) * 26 + "px";
+//        panel.update('<span class="dock_icon">+</div>');    
         return panel;
     }
     
@@ -1115,7 +1391,7 @@ var Utf8 = {
 //          $('span').hide();
             return;
         } 
-        connection = new WebSocket(location.href.split('http://').join('ws://'));
+        connection = new WebSocket(location.href.split('http://').join('ws://').replace(/\/$/,'').replace(/\#/,''));
         connection.win = win;
         connection.onopen = function () {
             if(data[0] && data[1]) {
index e144e907af6dd513784e427bf2623a27d839751c..7eca33f9964f8e3f542cd68acb22ce332b7e7db2 100644 (file)
@@ -7,11 +7,11 @@
     <link href="windows_js_1.3/themes/lighting.css" rel="stylesheet" type="text/css" />
     <link href="windows_js_1.3/themes/mac_os_x.css" rel="stylesheet" type="text/css" />
     <link href="windows_js_1.3/themes/debug.css" rel="stylesheet" type="text/css" />
-    <link href="./main.css" rel="stylesheet" type="text/css" />
     <link href="windows_js_1.3/themes/spread.css" rel="stylesheet" type="text/css" />
     <link href="windows_js_1.3/themes/alert.css" rel="stylesheet" type="text/css" />
     <link href="windows_js_1.3/themes/alert_lite.css" rel="stylesheet" type="text/css" />
     <link href="windows_js_1.3/themes/alphacube.css" rel="stylesheet" type="text/css" />
+    <link href="main.css" rel="stylesheet" type="text/css" />    
     <script type="text/javascript" src="swfobject.js"></script>
     <script type="text/javascript" src="web_socket.js"></script>
     <script type="text/javascript" src="windows_js_1.3/javascripts/prototype.js"></script>
@@ -29,8 +29,8 @@
 <body onload="init();" onunload="backup();"> 
 <div id="cons">
 <div id="dock"> 
-<a href="JavaScript:IRCConnection.create();">new connection</a>
-<a href="JavaScript:IRCConnection.showSettings();" style="padding-left:10px;">settings</a>
+&nbsp;&nbsp;<a href="JavaScript:IRCConnection.create();">new connection</a>&nbsp;
+<a href="JavaScript:IRCConnection.showSettings();" style="padding-left:10px;">settings</a>&nbsp;&nbsp;
   <div id="theme">Theme
     <select>
       <option>Mac OS X</option>
     </div>
 </div>
 </div>
+
+<div id="dialog_alias" style="display:none;">
+    <form id="form_alias" class="form_alias">
+        <center>
+        <span class="login_input"><b>Alias</b><br /><input type="text" id="input_alias" name="input_alias" value="" /></span>
+        <span class="login_input"><b>Full Command</b><br /><input type="text" id="input_cmd" name="input_cmd" value="" /></span>
+        </center>
+    </form>
+</div>
+<div id="dialog_perform" style="display:none;">
+    <form id="form_perform" class="form_perform">
+        <table><tr><td>
+        <span class="login_input"><b>Command</b><br /><input type="text" id="input_perform" name="input_alias" value="" /></span>
+        </td></tr></table>
+    </form>
+</div>
 <div id="settings" style="display:none;">
+<article>
+<span><a href="JavaScript:showSettingsPane('link1');" class="link1 active">User Interface</a>
+<a href="JavaScript:showSettingsPane('link2');" class="link2">Notifications</a></span>
     <form id="config" action="#">
-  <p><span class="config_label"><b>User Interface</b></span><span class="config_input"></span></p>    
+<section class="set1">
+  <p><span class="config_label"><b>Behavior</b></span><span class="config_input"></span></p>    
   <div style="clear:both"></div>    
   <p><span class="config_label">on invite</span>
     <span class="config_input"><input type="radio" name="invite" id="ask" value="ask" checked="checked">ask<br /><input type="radio" name="invite" id="join" value="join">join automatically<br /><input type="radio" name="invite" id="ignore" value="ignore">do nothing</span></p>
   <p><span class="config_label" style="width:320px;"><input type="checkbox" id="codes" name="codes">show message colors and formating</span><span class="config_input"></span></p>
   <p><span class="config_label" style="width:220px;"><input type="checkbox" id="hold" name="hold">hold connection on close</span><span class="config_input"></span></p> 
-  <div style="clear:both"></div>    
+  <p><div style="clear:both"></div></p>
+  <p><span class="config_label"><b>Aliases</b></span><span class="config_input"></span></p>
+  <p><span class="config_label" style="width:320px;font-size:8pt;">Available variables are: $1, $2, $3, $selectedchan and $nick.<br />Use ; to seperate multiple commands within the same alias.</span></p>    
+  <p>
+    <span class="config_label">
+    <center>
+    <div style="margin:5px; border: 1px solid #64355A;width:380px;height:60px;overflow-x:hidden;overflow-y:auto;">
+    <table cellpadding="0" cellspacing="0" class="aliases">
+        <thead><tr><td style="width:100px;"><b>Alias</b></td><td><b>Full Command</b></td></thead>
+        <tbody>
+            <tr><td>/j</td><td>/join $1</td></tr>
+            <tr><td>/q</td><td>/quit</td></tr>                        
+        </tbody>
+    </table>
+    </div>
+    </center>
+    <table>
+            <tr><td>
+                <span class="alias_edit"><input type="button" value="add"><input type="button" value="del"><input type="button" value="edit"></span>
+            </td></tr>
+    </table>
+    </span></p>
+  <p><div style="clear:both"></div></p>
+  <p><span class="config_label"><b>Perform</b></span><span class="config_input"></span></p>    
+  <p>
+    <span class="config_label">
+    <center>
+    <div style="margin:5px; border: 1px solid #64355A;width:380px;height:55px;overflow-x:hidden;overflow-y:auto;">
+    <table cellpadding="0" cellspacing="0" class="perform">
+        <tbody> 
+            <tr><td>/mode $nick +x</td></tr>                 
+        </tbody>
+    </table>
+    </div>
+    </center>
+    <table>
+            <tr><td>
+                <span class="perform_edit"><input type="button" value="add"><input type="button" value="del"><input type="button" value="edit"></span>
+            </td></tr>
+    </table>
+    </span></p>  
+  <p><div style="clear:both"></div></p>
+</section>
+<section class="set2">
   <p><span class="config_label"><b>Notifications</b></span><span class="config_input"></span></p>
     <div style="clear:both"></div>
   <p><span class="config_label" style="width:220px;"><input type="checkbox" id="ooh" name="ooh">only on hold</span></p>   
   <p><span class="config_label"><input type="checkbox" id="growl" name="growl">Growl</span><span class="config_input">Growl IP:Port<br /><input type="text" id="growlip" name="growlip"><br />Growl Password<br /><input type="text" id="growlpw" name="growlpw"></span></p>      
   <p><span class="config_label"><input type="checkbox" id="prowl" name="prowl">Prowl</span><span class="config_input">Prowl API key<br /><input type="text" id="prowlkey" name="prowlkey"><br />Prowl Priority<br /><input type="text" id="prowlpriority" name="prowlpriority"></span></p>
   <p><span class="config_label"><input type="checkbox" id="nma" name="nma">Notify My Android</span><span class="config_input">NMA key<br /><input type="text" id="nmakey" name="nmakey"><br />NMA Priority<br /><input type="text" id="nmapriority" name="nmapriority"></span></p>  
-  <div style="clear:both"></div>  
+  <div style="clear:both"></div>
+</section>
     </form>
+</article>
 </div>
 <div id="login" style="display:none;">
     <form class="conconfig" action="#">
   <p style="display:none;"><span class="login_label">Nick-PW</span> <span class="login_input"><input type="password" id="nickpw" /></span></p>
   </form>
 </div>
-<span id="tabindex">0</span>
+<span id="tabindex" style="display:none;">0</span>
 <div class="querytemplate">
     <table style="width:100%;height:90%;border-collapse:collapse;background-color:#fff;table-layout:fixed;overflow:hidden;">
         <tr>
         </tr>
     </table>    
 </div>
-
 <div class="channeltemplate">
     <table style="width:100%;height:90%;border-collapse:collapse;background-color:#fff;table-layout:fixed;overflow:hidden;">
         <tr>
index 148e19ab2ad690342f4a5d9d4fe44ab077336e1e..013d48917877c36fb252f8ff7b8637c76cbf3e73 100644 (file)
     src: url('fonts/Menlo.ttc');
 }
 
+article a, article a:Active, article a:Visited {
+    position:relative;
+    top:1px;
+    text-decoration:none;
+    color:#000;
+    width:60px;
+    font-size:18px;
+    color:#64355A;
+    background-color:#fff;
+    margin-right:10px;
+    padding-left:5px;
+    padding-right:5px;
+    border-top: 1px solid black;
+    border-bottom: 1px solid black;
+    border-left: 1px solid black;
+    border-right: 1px solid black;    
+}
+article a.active {
+    position:relative;
+    top:2px;
+    border-bottom: #fff;
+}
+
+article a:Hover {
+    text-decoration:none;
+    color:#000;
+    width:60px;
+    font-size:18px;
+    color:#fff;
+    background-color:#64355A;
+    padding-left:5px;
+    padding-right:5px;
+    border-top: 1px solid black;
+    border-left: 1px solid black;
+    border-right: 1px solid black;    
+}
+
+article section.set1 {
+    height:550px;
+    display:block;
+    border:1px solid #64355A;
+}
+
+article section.set2 {
+    height:550px;
+    display:none;
+    border:1px solid #64355A;
+}
+
+.aliases, .perform {
+    width:400px;
+    overflow:auto;
+}
+
+.aliases thead tr td {
+    border-bottom: 1px solid #64355A;   
+}
+.aliases tr td, .perform tr td {
+    padding: 3px;
+    text-align:left;
+}
+
+.aliases tr, .perform tr{
+    padding:3px;
+    color:#64355A;
+}
+
+table tr.selected {
+    padding:3px;
+    background-color:#64355A;
+    color:#fff;
+}
+/*
+article.infobox section p {
+    font-family: Verdana;
+    font-size: 15px;
+    margin: 10px 10px 0 10px;
+}
+​*/
+
 body {
     margin:0;
     padding:0;
@@ -66,7 +146,7 @@ body {
 .icon_msg {
     cursor:pointer;
     float:left;
-    width:102px;
+    min-width:102px;
     height:21px;
     margin-top:3px;
     border-top: 1px solid #fff;
@@ -85,7 +165,7 @@ body {
 .icon_waiting {
     cursor:pointer;
     float:left;
-    width:102px;
+    min-width:102px;
     height:21px;
     margin-top:3px;
     border-top: 1px solid #fff;
@@ -101,9 +181,13 @@ body {
     margin-left:10px;
 }
 .dock_icon {
+   -o-text-overflow: ellipsis;   /* Opera */
+    text-overflow: ellipsis;   /* IE, Safari (WebKit) */
+    overflow:hidden;              /* don't show excess chars */
+    white-space:nowrap;           /* force single line */
     cursor:pointer;
     float:left;
-    width:102px;
+    min-width:102px;
     height:21px;
     margin-top:3px;
     border-top: 1px solid #fff;
@@ -210,6 +294,13 @@ body {
   margin-right:15px;
 }
 
+.topic {
+   -o-text-overflow: ellipsis;   /* Opera */
+    text-overflow: ellipsis;   /* IE, Safari (WebKit) */
+    overflow:hidden;              /* don't show excess chars */
+    white-space:nowrap;           /* force single line */
+}
+
 .login_label, .login_input, .login_error
 {
   padding:10px;
@@ -232,7 +323,7 @@ body {
 }
 .login_input, .config_input {
   vertical-align:bottom;
-  padding:10px;
+  padding:5px;
   color:#000;
   text-align:left;
   float:left; 
index b32db30633b029789083cb20a1f7fd44a0848ae7..553a23e97645ed86f57ea741a7aa81954921627a 100644 (file)
@@ -59,6 +59,7 @@
         element.win.toFront();
     },
     close: function(id, event) {
+    
         var win = this.getWindow(id)
         if (win && win.visible) {    
             $$('.con_panel span').each(function(icon) {
                     }
                 });        
             if (win.getTitle() == "status"){
-                IRCConnection.quit();                
+                IRCConnection.quit();
+//                IRCConnection.channels = "";                
                 $$('#dock a').first().show();                
             } else {
-                if (win.getTitle().substring(0,1) == "#"){
-                    IRCConnection.handleInput(win.getTitle(), '/part BYE BYE');                            
+                if (win.getTitle().match(/\#/g)){
+                    IRCConnection.handleInput(IRCConnection.getActiveChan().name, '/part BYE BYE');                            
 //                    IRCConnection.delChannel(win.getTitle().split(' ')[0]);
                 } else {
                     IRCConnection.delChannel(win.getTitle());                    
@@ -110,6 +112,20 @@ function changeTheme(event) {
     currentTheme = index;
 }
 
+function showSettingsPane(link){
+    if(link=="link1"){
+        $$('article .set1').each(function(set){set.style.display='block'});
+        $$('article .set2').each(function(set){set.style.display='none'});
+        $$('article .link1').each(function(link){link.addClassName('active')});
+        $$('article .link2').each(function(link){link.removeClassName('active')});        
+    } else {
+        $$('article .set1').each(function(set){set.style.display='none'});
+        $$('article .set2').each(function(set){set.style.display='block'});
+        $$('article .link1').each(function(link){link.removeClassName('active')});
+        $$('article .link2').each(function(link){link.addClassName('active')});        
+    }
+}
+
 function getSelection(el)
 {
 //   var textComponent = document.getElementById('Editor');
@@ -166,7 +182,7 @@ function setCaretPosition(el, caretPos) {
 
 function refreshUserLists(){
     var objChannel = IRCConnection.getActiveChan();
-    if(objChannel) objChannel.updateUserList();
+    if(objChannel && objChannel.name.match(/\#/)) objChannel.updateUserList();
 }
 
 function handleTab(e){
@@ -221,9 +237,9 @@ function resume(){
                         objChannel = Object.create(Channel).init(channels[x].name);
                         objChannel.users = channels[x].users;
                         objChannel.createWindow();
-                        objChannel.setTopic(channels[x].topic);                        
                         objChannel.win.setLocation(parseInt(channels[x].win.options.top), parseInt(channels[x].win.options.left));                        
                         objChannel.win.setSize(parseInt(channels[x].win.options.width), parseInt(channels[x].win.options.height));                        
+                        objChannel.setTopic(channels[x].topic);                        
                         $$('#'+objChannel.win.getContent().id+' td div').each(function(td){td.style.height = objChannel.win.getSize()['height']-23+'px'});                     
                         IRCConnection.channels.push(objChannel);
                         objChannel.updateUserList();                               
@@ -301,6 +317,7 @@ function handleKeyPress(e){
 function init(){
     getEmoticons();
     IRCConnection.getSettings();
+//    IRCConnection.saveSettings($('config').serialize(true));    
     resume();
     window.setInterval("refreshUserLists()", 20000);    
     $$("#theme select").first().selectedIndex = currentTheme;
@@ -323,6 +340,8 @@ function init(){
             });
         },
         onEndResize: function(eventName, mwin) {
+            Windows.focus(mwin.getId());                    
+            mwin.toFront();                            
             if(mwin.getSize()['width'] < 300)                
                 mwin.setSize(300, mwin.getSize()['height']);                    
             if(mwin.getSize()['height'] < 200)
@@ -330,8 +349,15 @@ function init(){
             if (mwin.getTitle() == "status") {
                 mwin.getContent().childNodes[1].childNodes[1].style.height = mwin.getSize()['height']-23+'px';
             } else {
-                if (mwin.getTitle() != "Debug") {    
-                    $$('#'+mwin.getContent().id+' td')[1].style.height = mwin.getSize()['height']-23+'px';
+                if (mwin.getTitle() && mwin.getTitle() != "Debug") {   
+                    if(mwin.getTitle().match(/\#/)){ 
+                        $$('#'+mwin.getContent().id+' td')[1].style.height = mwin.getSize()['height']-23+'px';                    
+                        IRCConnection.getActiveChan().setTopic(IRCConnection.getActiveChan().getTopic());
+                    }
+//                    debug($$('#'+mwin.getContent().id+' td')[1].style.height);
+//                    $$('#'+mwin.getContent().id+' .content').last().style.height = mwin.getSize()['height']-23+'px';
+//                    debug($$('#'+mwin.getContent().id+' td')[1].style.height);
+//                    debug($$('#'+mwin.getContent().id+' td input').first().style.top);
                     $$('#'+mwin.getContent().id+' td div').each(function(td){td.style.height = mwin.getSize()['height']-23+'px'});                    
                 }                
             }
diff --git a/scripts/.dontremove b/scripts/.dontremove
deleted file mode 100644 (file)
index e69de29..0000000