Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

client styling

  • Loading branch information...
commit 020e513d854bcef1490046b20ddde74986782d1e 1 parent 1f8b8c6
Marvin Killing authored
Showing with 34 additions and 26 deletions.
  1. +18 −19 client/client.coffee
  2. +16 −7 client/style.css
View
37 client/client.coffee
@@ -2,40 +2,39 @@ tojson: JSON.stringify
fromjson: JSON.parse
ctr: window.webkitNotifications
-controls: ->
- $("#controls").children()
-
-disable: (controls)->
- controls.attr "disabled", "disabled"
-
-enable: (controls) ->
- controls.removeAttr "disabled"
+controls: -> $("#controls").children()
+disable: (controls) -> controls.attr "disabled", "disabled"
+enable: (controls) -> controls.removeAttr "disabled"
notify: (title, text)->
if ctr.checkPermission() is 0
notification: ctr.createNotification(null, title, text)
notification.show()
-announce: (cssclass, text)->
- new_msg: $("<div>").addClass(cssclass).text(text)
+announce: (text) ->
+ new_msg: $("<div>").addClass("announcement").text(text)
$('#chatwindow').append new_msg
+message: (you, msg) ->
+ if not you then notify "Stranger", msg
+ prefix: if you then "You:" else "Stranger:"
+ prefix_class: if you then "mymessage" else "strangermessage"
+
+ new_msg: $("<div>").addClass("announcement").
+ append($("<div>").text(prefix).addClass(prefix_class)).
+ append($("<div>").text(msg).addClass("message"))
+ $('#chatwindow').append new_msg
+
handle_message: (data) ->
switch data.type
when "connect"
enable controls()
- announce "announcement", "You're now chatting with a random stranger. Say hey!"
+ announce "You're now chatting with a random stranger. Say hey!"
when "disconnect"
disable controls()
- announce "announcement", "disconnected :("
+ announce "disconnected :("
when "message"
- cssclass: "strangermessage"
-
- if data.you
- cssclass: "mymessage"
- notify "Stranger", data.msg
-
- announce cssclass, data.msg
+ message data.you, data.msg
$(document).ready ->
disable controls()
View
23 client/style.css
@@ -1,22 +1,35 @@
.mymessage {
- font-color: blue;
+ color: blue;
}
.strangermessage {
- font-color: red;
+ color: red;
}
.announcement {
- font-color: black;
+ padding: 5px 2px;
+ font-weight: bold;
+ clear: left;
+}
+
+.announcement > * {
+ float: left;
+}
+
+.message {
+ padding-left: 10px;
+ font-weight: normal;
}
#chatwindow {
width: 100%;
height: 80%;
border: 1px solid;
+ font-family: Arial, sans-serif;
}
#controls {
+ padding-top: 20px;
width: 100%;
height: 20%;
}
@@ -24,8 +37,4 @@
#controls > * {
float: left;
height: 50%;
-}
-
-#textarea {
- width: 70%;
}
Please sign in to comment.
Something went wrong with that request. Please try again.