summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-08-04 10:55:51 -0400
committerJules Laplace <jules@okfoc.us>2015-08-04 10:55:51 -0400
commit1a882d4adf6307dfbd764ae6aaf1a62a724851f1 (patch)
tree481aef83b95f951fd93a111c48b350cd3b6d3886
parent460dadfdd2c3d91d3759542990702362b85703d3 (diff)
rearrange stuff and stub in chat
-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
-rw-r--r--views/pages/index.ejs18
-rw-r--r--views/pages/room.ejs3
-rw-r--r--views/partials/scripts.ejs8
8 files changed, 100 insertions, 18 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
diff --git a/views/pages/index.ejs b/views/pages/index.ejs
index 45c6a84..97d16d2 100644
--- a/views/pages/index.ejs
+++ b/views/pages/index.ejs
@@ -3,24 +3,12 @@
<head>
<title>yt-chat</title>
<link rel="stylesheet" href="/css/css.css">
+<style>
+</style>
</head>
<body>
-<div id="video"></div>
-
-<div id="chat">
- <div id="messages"></div>
- <form>
- <input type="text" id="message">
- </form>
-</div>
-
-<script type="text/html" id="message_template">
- <div class="row">
- <span class="nick"></span>
- <span class="msg"></span>
- </div>
-</script>
+<input type="text" id="create-room" placeholder="enter a url to make a room">
</body>
<% include ../partials/scripts %>
diff --git a/views/pages/room.ejs b/views/pages/room.ejs
index ec1f353..36e4140 100644
--- a/views/pages/room.ejs
+++ b/views/pages/room.ejs
@@ -1,11 +1,13 @@
<html>
<head>
<title>yt-chat</title>
+<link rel="stylesheet" href="/css/css.css">
<style>
</style>
</head>
<body>
+
<div id="video"></div>
<div id="chat">
@@ -22,6 +24,7 @@
</div>
</script>
+
</body>
[[ include ../partials/scripts ]]
</html> \ No newline at end of file
diff --git a/views/partials/scripts.ejs b/views/partials/scripts.ejs
index 1644c71..0e3bc02 100644
--- a/views/partials/scripts.ejs
+++ b/views/partials/scripts.ejs
@@ -1,8 +1,10 @@
<script src="js/vendor/zepto.min.js"></script>
-<script src="js/lib/view.js"></script>
-<script src="js/lib/formview.js"></script>
+<script src="js/lib/view/view.js"></script>
+<script src="js/lib/view/formview.js"></script>
+<script src="js/lib/view/router.js"></script>
<script src="js/lib/parser.js"></script>
<script src="js/lib/user.js"></script>
-<script src="js/app.js"></script>
+<script src="js/site/index.js"></script>
+<script src="js/index.js"></script>
<script type="text/javascript" src="http://www.youtube.com/player_api"></script>