summaryrefslogtreecommitdiff
path: root/public/js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js')
-rw-r--r--public/js/index.js (renamed from public/js/app.js)1
-rw-r--r--public/js/lib/chat.js27
-rw-r--r--public/js/lib/view/formview.js (renamed from public/js/lib/formview.js)0
-rw-r--r--public/js/lib/view/router.js61
-rw-r--r--public/js/lib/view/view.js (renamed from public/js/lib/view.js)0
5 files changed, 89 insertions, 0 deletions
diff --git a/public/js/app.js b/public/js/index.js
index 2738928..d1af979 100644
--- a/public/js/app.js
+++ b/public/js/index.js
@@ -2,6 +2,7 @@ var app = (function(){
var app = {}
app.init = function(){
+ // app.socket =
}
document.addEventListener('DOMContentLoaded', app.init)
diff --git a/public/js/lib/chat.js b/public/js/lib/chat.js
new file mode 100644
index 0000000..946954b
--- /dev/null
+++ b/public/js/lib/chat.js
@@ -0,0 +1,27 @@
+var ChatView = View.extend({
+
+ template: $("#collaborator-template").html(),
+
+ events: {
+ "submit form": "send"
+ },
+
+ initialize: function(){
+ this.$msg = this.$("#message")
+ this.$messages = this.$("#messages")
+ },
+
+ add: function(msg){
+ var $el = $( this.template )
+ $el.find(".nick").html(msg.nick)
+ $el.find(".msg").html(msg.msg)
+ },
+
+ send: function(){
+ },
+
+ empty: function(){
+ this.$messages.empty()
+ }
+
+})
diff --git a/public/js/lib/formview.js b/public/js/lib/view/formview.js
index f5845e7..f5845e7 100644
--- a/public/js/lib/formview.js
+++ b/public/js/lib/view/formview.js
diff --git a/public/js/lib/view/router.js b/public/js/lib/view/router.js
new file mode 100644
index 0000000..28905b2
--- /dev/null
+++ b/public/js/lib/view/router.js
@@ -0,0 +1,61 @@
+var Router = View.extend({
+
+ route: function(){
+
+ this.originalPath = window.location.pathname
+
+ var routes = is_mobile ? this.mobileRoutes : this.routes,
+ pathname = window.location.pathname,
+ path = pathname.split("/");
+
+ for (var i = 0; i < path.length; i++) {
+ if (! path[i].length) {
+ path[i] = null
+ }
+ }
+
+ if (pathname in routes) {
+ this[this.routes[pathname]](null)
+ return
+ }
+
+ if (path[path.length-1] == null) {
+ path.pop()
+ }
+
+ for (var route in routes) {
+ var routePath = route.split("/")
+ if (routePath[1] == path[1]) {
+ if (routePath[2] && routePath[2].indexOf(":") !== -1 && path[2] && (path[3] === routePath[3]) ) {
+ this[this.routes[route]](null, path[2])
+ return
+ }
+ else if (routePath[2] == path[2]) {
+ if (routePath[3] && path[3]) {
+ if (routePath[3].indexOf(":") !== -1) {
+ this[this.routes[route]](null, path[3])
+ return
+ }
+ else if (routePath[3] == path[3]) {
+ this[this.routes[route]](null)
+ return
+ }
+ }
+ else if (! routePath[3] && ! path[3]) {
+ this[this.routes[route]](null)
+ return
+ }
+ }
+ else if (! routePath[2] && (! path[2].length || ! path[2])) {
+ this[this.routes[route]](null)
+ return
+ }
+ }
+ }
+
+ if (is_mobile) {
+ window.location.href = "/"
+ }
+ }
+
+})
diff --git a/public/js/lib/view.js b/public/js/lib/view/view.js
index 87d6ee4..87d6ee4 100644
--- a/public/js/lib/view.js
+++ b/public/js/lib/view/view.js