Permalink
Browse files

Start fleshing out client boilerplate

  • Loading branch information...
1 parent 2df54c6 commit 7b581956dc7d028f2f0fe8368b1011c97180eb85 @brendonh committed Aug 11, 2012
View
@@ -1,2 +0,0 @@
-CubesInSpace
-============
View
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <script src="/js/dev/require-jquery.js" data-main="/js/dev/index.js"></script>
+ </head>
+
+ <body>
+
+ <div id="box">
+ Sorry, no canvas support.
+ </div>
+
+ <div id="info" style="position: absolute; left: 850px; top: 10px">
+ <p style="color: #000099">
+ Use arrow keys.
+ </p>
+ <p>FPS: <strong class="fps">??</strong></p>
+ <p>Faces: <strong class="faces">??</strong></p>
+ <p>Renderer: <strong class="renderer">??</strong></p>
+ </div>
+
+ </body>
+</html>
@@ -0,0 +1,7 @@
+({
+ appDir: "./",
+ baseUrl: "./",
+ dir: "../production",
+ modules: [
+ ]
+})
@@ -0,0 +1,29 @@
+define([
+ "Backbone",
+ "models/Server"
+], function(Backbone, Server) {
+
+ var Servers = Backbone.Collection.extend({
+ model: Server,
+
+ ensure: function(url) {
+ var server = this.get(url);
+ if (!server) {
+ server = new Server({url: url})
+ this.add(server);
+ }
+ server.connect();
+ return server.get("dConnected");
+ },
+
+ closeAll: function() {
+ this.each(function(socket) {
+ socket.disconnect();
+ });
+ }
+
+ });
+
+ return Servers;
+
+});
View
@@ -0,0 +1 @@
+
View
@@ -0,0 +1,39 @@
+require.config({
+ "paths": {
+ "jquery": "require-jquery",
+ "text": "libs/requirejs/text",
+ "dispatch": "libs/dispatch",
+ "router": "libs/router",
+ "Underscore": "libs/underscore-min",
+ "Backbone": "libs/backbone-min"
+ },
+ "shim": {
+ "Underscore": {
+ "deps": ["jquery"],
+ "exports": "_"
+ },
+ "Backbone": {
+ "deps": ["Underscore", "jquery"],
+ "exports": "Backbone"
+ }
+ },
+ "deps": ["index"],
+ "baseUrl": "/js/dev"
+})
+
+require([
+ "jquery",
+ "Backbone",
+ "collections/Servers"
+], function($, Backbone, Servers){
+ var servers = new Servers();
+
+ window.onbeforeunload = function() {
+ servers.closeAll();
+ }
+
+ var d = servers.ensure("ws://dev.brendonh.org:9998/")
+ d.done(function() {
+ console.log("Connected!");
+ });
+});

Large diffs are not rendered by default.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 7b58195

Please sign in to comment.