Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add login page and make haml compile in a specified scope
- Loading branch information
1 parent
c29601e
commit a7d23aa
Showing
6 changed files
with
114 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
!!! XML | ||
!!! Strict | ||
%html{ xmlns: "http://www.w3.org/1999/xhtml" } | ||
%head | ||
%title Login - DinMaker - A real-time chat demo for TopCloud and NodeRouter | ||
%link{ href: "/external/ui-darkness/jquery-ui-1.7.2.custom.css", rel: "stylesheet", type: "text/css" } | ||
%link{ href: "login.css", rel: "stylesheet", type: "text/css" } | ||
%script{ src: "/external/jquery-1.3.2.min.js", type: "text/javascript" } | ||
%script{ src: "/external/jquery-ui-1.7.2.custom.min.js", type: "text/javascript" } | ||
:javascript | ||
function login(form) { | ||
window.open("/" + escape($('input', form).val()), "DinMaker", "status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=0,height=400,width=700"); | ||
} | ||
%body | ||
.ui-widget-overlay | ||
%form{ onsubmit: "return false;" } | ||
#shadow | ||
.ui-widget-shadow | ||
%table#login.ui-widget.ui-widget-content.ui-corner-all | ||
%thead | ||
%tr | ||
%th.ui-widget-header.ui-corner-top{ colspan: "2" } | ||
Enter your desired username for DinMaker | ||
%tr | ||
%th | ||
Name | ||
%td | ||
%input{ name: "name" } | ||
%tr | ||
%th | ||
%td | ||
%button{ title: "Enter the chat room.", onclick: "login(this.form)" } | ||
%span.ui-icon.ui-icon-unlocked | ||
Launch | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,52 @@ | ||
/*jslint white: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true */ | ||
/*globals TC, jQuery*/ | ||
|
||
TC.defineController("Demo", function (params) { | ||
TC.defineController("Demo", function (username) { | ||
|
||
var $ = jQuery, self = this, messages = [], users = {}; | ||
|
||
this.bindData("selected_users", {value: {}}); | ||
this.bindData("new_message", {value: ""}); | ||
|
||
this.send_message = function () { | ||
var message = self.new_message.get(); | ||
if (message === '') { | ||
return; | ||
} | ||
$.ajax({ | ||
type: "POST", | ||
url: "/message/" + username, | ||
processData: false, | ||
data: message | ||
}); | ||
self.new_message.set(""); | ||
} | ||
|
||
this.table_model = { | ||
get_num_rows: function () { | ||
return 1; | ||
return 2; | ||
}, | ||
get_value_at: function (row_index, column) { | ||
return "Tim"; | ||
return ["Tim", "Bob"][row_index]; | ||
} | ||
|
||
|
||
|
||
}; | ||
|
||
function long_poll() { | ||
$.ajax({ | ||
type: "POST", | ||
url: "/listen/" + username, | ||
success: function (data) { | ||
console.log(data); | ||
long_poll(); | ||
}, | ||
error: function (err) { | ||
console.error("Long-Poll Error, retrying in 10 seconds..."); | ||
setTimeout(long_poll, 10000); | ||
} | ||
}); | ||
} | ||
|
||
// Kick off the long poll process on load | ||
$(long_poll); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
table, #shadow, .ui-widget-shadow { width: 400px; height: 160px; } | ||
table#login, #shadow { font-size: 15px; position: absolute; top: 50%; left: 50%; margin-top: -80px; margin-left: -200px; } | ||
table#login td, table#login th { vertical-align: middle; } | ||
#login tr.ui-state-error { font-size: 12px; } | ||
#login tr.ui-state-error td { padding: 5px 10px; } | ||
#login tr.ui-state-error span { float: left; margin-right: 0.3em; } | ||
#login .ui-widget-header { line-height: 2em; height: 2em; } | ||
#login button { font-size: 12px; cursor: pointer; line-height: 1em; padding: 2px 5px 2px 2px; } | ||
#login button .ui-icon { float: left; line-height: 1em; } |