Permalink
Browse files

Hook everything up on the selector screen.

  • Loading branch information...
1 parent dd9181f commit ae4e00962f1c309d5617492714cdeb009da99cdb @mythmon committed Jan 7, 2013
Showing with 567 additions and 97 deletions.
  1. +5 −0 clientConnection.js
  2. +3 −3 crimsontwins.js
  3. +62 −33 manager.js
  4. +48 −20 static/css/crimsontwins.less
  5. +365 −0 static/css/lib/vendor-prefix.less
  6. +68 −23 static/js/managed.js
  7. +6 −1 utils.js
  8. +10 −17 web.js
View
@@ -0,0 +1,5 @@
+var now = require('now');
+
+var web = require('./web');
+
+exports.everyone = now.initialize(web.httpServer);
View
@@ -1,3 +1,3 @@
-require('./config.js');
-require('./web.js');
-require('./chat.js');
+require('./config');
+require('./manager');
+require('./chat');
View
@@ -1,47 +1,76 @@
var _ = require('underscore');
+var config = require('./config.js');
var utils = require('./utils');
+var clientConnection = require('./clientConnection');
-/* Class Manager
- *
- * Manages clients, screens, and content.
+var everyone = clientConnection.everyone;
+
+/* Manages clients, screens, and content.
*
* - Client: A connected web browser. Shows one or more Screens.
* - Screen: A place for content to live. Viewed by one or more clients.
* - Content: A thing shown on a screen.
*/
-function Manager(options) {
- _.extend(this, {
- }, options, {
- clients: [],
- screens: []
- });
-}
-
-Manager.prototype.addClient = function(client) {
- this.clients.push(client);
+
+var clients = [];
+var screens = [];
+
+var addClient = function(client) {
+ clients.push(client);
};
/* This is a now.js function. */
-Manager.prototype.getScreens = function(callback) {
- var screens = [
- {
- title: "Tomax",
- content: {type: 'image', url: '/img/nope.gif'}
- },
- {
- title: "Xomat",
- content: {type: 'url', url: 'http://scrumbu.gs/t/james-rifles/2012.23/'}
- },
- {
- title: "PDX",
- content: {type: 'image', url: 'https://gs1.wac.edgecastcdn.net/8019B6/data.tumblr.com/tumblr_lxqes0ox2J1r5691eo1_400.gif'}
- }
- ];
- if (callback === undefined) {
- return screens;
- }
- utils.async(callback, screens);
+var getScreens = function() {
+ return screens;
+};
+
+
+var nextContent = 0;
+var contentSet = [
+ {type: 'url', url: 'http://wikipedia.org'},
+ {type: 'image', url: '/img/nope.gif'},
+ {type: 'image', url: 'http://i.imgur.com/46xWL.gif'},
+ {type: 'image', url: 'https://s3.amazonaws.com/data.tumblr.com/tumblr_lxf2q5Rdcz1r1ibsxo1_500.gif'},
+ {type: 'image', url: 'https://images.4chan.org/wsg/src/1357060530091.gif'},
+];
+
+var addScreen = function(name) {
+ var screen = {
+ id: utils.getId(),
+ name: name,
+ content: contentSet[nextContent]
+ };
+ nextContent = (nextContent + 1) % contentSet.length;
+ screens.push(screen);
+ everyone.now.screenAdded(screen);
};
-exports.Manager = Manager;
+/********** Now.js connections **********/
+// Now.js sometimes has some different calling conventions, so translate.
+everyone.now.addClient = function() {
+ addClient(this);
+};
+
+everyone.now.getScreens = function(callback) {
+ var screens = getScreens();
+ utils.async(callback, screens);
+};
+
+everyone.now.addScreen = function(name) {
+ addScreen(name);
+};
+
+everyone.now.changeScreen = function(name) {
+ var screen;
+ _.each(screens, function(s) {
+ if (s.name === name) {
+ screen = s;
+ }
+ });
+ if (screen !== undefined) {
+ screen.content = contentSet[nextContent];
+ nextContent = (nextContent + 1) % contentSet.length;
+ everyone.now.screenChanged(screen);
+ }
+};
@@ -1,13 +1,12 @@
-body {
- overflow: hidden;
-}
+@import 'lib/vendor-prefix.less';
#wrap {
position: relative;
background: url(/img/debut_dark.png);
+ overflow: hidden;
}
-.container, .preview {
+.container, .preview .content {
position: absolute;
top: 0;
left: 0;
@@ -37,8 +36,10 @@ body {
.selector {
list-style: none;
+ margin: 0;
+ padding: 0;
- li {
+ .preview {
position: relative;
display: inline-block;
margin: 10px;
@@ -51,34 +52,38 @@ body {
text-align: center;
}
- .preview {
+ .content {
position: relative;
width: 240px;
height: 180px;
border: 1px solid #555;
background: url(/img/debut_dark.png);
- > i.add {
- font-size: 64px;
- width: 64px;
- height: 64px;
- line-height: 58px;
- border-size: 10px;
- border-radius: 64px;
- display: block;
+ > i {
+ .translate(-50%, -50%);
+ .scale(2);
+ .transform(translate(-50%, -50%) scale(2));
+ display: block;
position: absolute;
top: 50%;
left: 50%;
- margin: -32px;
+ }
+
+ &:hover {
+ > i {
+ color: #5B5;
+ border-color: #5B5;
+ }
}
iframe {
- transform-origin: 0 0;
- transform: scale(0.2);
+ .transform-origin(0 0);
+ .scale(0.2);
width: 500%;
height: 500%;
position: absolute;
+ pointer-events: none;
}
}
@@ -96,19 +101,42 @@ body {
i {
display: inline-block;
+ font-family: Arial, sans-serif;
+ font-style: normal;
&.add {
color: #ABA;
- border: 5px solid #ABA;
+ border: 4px solid #ABA;
border-radius: 32px;
width: 32px;
height: 32px;
- font-size: 32px;
- line-height: 32px;
+ font-size: 42px;
+ line-height: 35px;
+ text-align: center;
+ font-weight: bold;
+
+ &:before {
+ content: "+";
+ position: absolute;
+ top: 0;
+ left: 2px;
+ }
+ }
+
+ &.hydra {
+ color: #ABA;
+ border: 6px solid #ABA;
+ width: 32px;
+ height: 32px;
+ font-size: 68px;
+ line-height: 40px;
text-align: center;
&:before {
content: "+";
+ position: absolute;
+ top: -3px;
+ left: -7px;
}
}
}
Oops, something went wrong.

0 comments on commit ae4e009

Please sign in to comment.