Skip to content
Permalink
Browse files

Start working on UI, really rudimentary client is now functional.

  • Loading branch information...
Shinmera committed Jan 19, 2017
1 parent ea0ac9c commit 517429b0389836890fa6f2899414fba6bcbdd599
Showing with 606 additions and 48 deletions.
  1. +1 −1 Makefile
  2. +30 −0 cl.js
  3. +9 −2 client.js
  4. +5 −16 index.html
  5. +1 −1 lichat.css
  6. +282 −2 lichat.js
  7. +35 −26 lichat.lass
  8. +243 −0 ui.js
@@ -1,4 +1,4 @@
FILES=cl.js stream.js wire-object.js printer.js reader.js client.js
FILES=cl.js stream.js wire-object.js printer.js reader.js client.js ui.js
OUTPUT=lichat

all: $(FILES)
30 cl.js
@@ -103,8 +103,38 @@ var CL = function(){

self.getUniversalTime = function(){
return +new Date()+self.universalUnixOffset;
};

self.universalToUnix = function(universal){
return universal-self.universalUnixOffset;
};

self.pushnew = function(el, arr){
if(arr.indexOf(el) < 0){
arr.push(el);
}
return arr;
}

self.remove = function(el, arr, test){
test = test || function(a,b){return a===b;}
var newarr = [];
for(var item of arr){
if(!test(item, el))
newarr.push(item);
}
return newarr;
}

self.sxhash = function(object){
var str = object.toString();
var hash = 0;
for(var i=0; i<str.length; i++){
hash = ((hash << 5) - hash + str.charCodeAt(i++)) << 0;
}
return hash;
};

return self;
};

@@ -16,6 +16,7 @@ var LichatClient = function(options){
}

self.socket = null;
self.servername = null;
self.handlers = {};

var reader = new LichatReader();
@@ -81,6 +82,7 @@ var LichatClient = function(options){
throw e;
}
status = "RUNNING";
self.servername = update.from;
self.process(update);
break;
case "RUNNING":
@@ -93,9 +95,10 @@ var LichatClient = function(options){
};

self.process = function(update){
console.log("[Lichat] Update:",update);
var handler = self.handlers[update.type];
if(handler){
handler(self, update);
handler(update, self);
}else{
console.log(update);
}
@@ -106,6 +109,10 @@ var LichatClient = function(options){
}

self.removeHandler = function(update){
self.handlers[update] = null;
delete self.handlers[update];
}

self.addHandler("PING", function(){
self.s("PONG");
});
};
@@ -21,8 +21,7 @@ <h1>Log In to Lichat</h1>
<main class="chat" style="display:none">
<div class="channels">
<h2>Channels</h2>
<div>
<a>Test</a>
<div class="lichat-channel-list">
</div>
</div>
<div class="chat-area">
@@ -31,25 +30,14 @@ <h2>Channels</h2>
<a>Join</a>
<a>Leave</a>
</nav>
<div class="output">
<div>
<time>00:00:00</time>
<a>Someone</a>:
<span>Yooo</span>
</div>
<div>
<time>00:00:00</time>
<a>Someone</a>:
<span>YoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYoooYooo</span>
</div>
<div class="lichat-output">
</div>
<textarea class="input"></textarea>
<textarea class="lichat-input"></textarea>
<input type="submit" value="Send" />
</div>
<div class="users">
<h2>Users</h2>
<div>
<a>Someone</a>
<div class="lichat-user-list">
</div>
</div>
</main>
@@ -59,6 +47,7 @@ <h2>Users</h2>
var stat = document.querySelector(".status");
var chat = document.querySelector(".chat");
var client = new LichatClient();
var ui = new LichatUI(chat, client);
var fail = function(reason){
chat.style.display = "none";

Some generated files are not rendered by default. Learn more.

0 comments on commit 517429b

Please sign in to comment.
You can’t perform that action at this time.