Skip to content

Commit

Permalink
passing stretch to collaborator
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit Kapadia committed Jun 20, 2013
1 parent 82a1261 commit ff73208
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 16 deletions.
20 changes: 10 additions & 10 deletions Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ task 'build', 'Build from server/', ->

task 'server', 'Watch for changes', ->

# watch.createMonitor('.', (monitor) ->
#
# monitor.on("changed", (f, cur, prev) ->
# ext = path.extname(f)
# if ext in ['.coffee', '.styl']
# exec('hem build', ->
# console.log 'Build complete'
# )
# )
# )
watch.createMonitor('.', (monitor) ->

monitor.on("changed", (f, cur, prev) ->
ext = path.extname(f)
if ext in ['.coffee', '.styl']
exec('hem build', ->
console.log 'Build complete'
)
)
)

coffee = spawn 'node_modules/.bin/coffee', ['-w', '-c', '-m', '-o', '.', 'server']
nodemon = spawn 'node_modules/.bin/nodemon', ['server.js']
Expand Down
13 changes: 13 additions & 0 deletions app/controllers/Image.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,24 @@ class Image extends Controller
@socket.on('scale', (min, max) =>
@wfits.setExtent(min, max)
)

@socket.on('stretch', (fn) =>
@wfits.setStretch(fn)
)

# TODO: Finish this feature!
@socket.on('mousemove', (x, y) =>
console.log 'onmousemove', x, y
)

onStretch: (e) =>
stretch = e.target.dataset.fn
if e.type is 'click'
@currentStretch = stretch
@wfits.setStretch(stretch)

if @socket
@socket.emit 'stretch', stretch

onPointer: (e) =>
@wfits.setCursor(e.target.dataset.type)
Expand Down Expand Up @@ -170,6 +182,7 @@ class Image extends Controller

mouseCallbacks.onmousemove = (x, y, opts) =>
_onmousemove(x, y, opts)
@socket.emit 'mousemove', x, y
@socket.emit 'translation', [@wfits.xOffset, @wfits.yOffset]

mouseCallbacks.onzoom = =>
Expand Down
10 changes: 5 additions & 5 deletions app/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class Luminosity extends Controller
# Initialize controllers
@el = $('#luminosity')

# Start socket and determine hostname and port for sockets
if location.hostname is '0.0.0.0'
socket = io.connect('http://localhost', {port: 8080})
else
socket = io.connect()
# # Start socket and determine hostname and port for sockets
# if location.hostname is '0.0.0.0'
# socket = io.connect('http://localhost', {port: 8080})
# else
socket = io.connect()

# Initialize Drop controller with DOM element and socket
drop = new Drop({el: @el, socket: socket})
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link rel="stylesheet" href="application.css" type="text/css" charset="utf-8">

<!-- <script src="http://cdn.socket.io/stable/socket.io.js"></script> -->
<!-- <script src="http://0.0.0.0:8080/socket.io/socket.io.js"></script> -->
<script src="http://0.0.0.0:8080/socket.io/socket.io.js"></script>

<script src="application.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
Expand Down
8 changes: 8 additions & 0 deletions server/server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ io.sockets.on('connection', (socket) ->
status: true

socket.on 'sharing-data', (msg) ->
console.log "SHARING DATA"
socket.broadcast.emit 'request-to-share', msg.filename

socket.on 'translation', (xOffset, yOffset) ->
Expand All @@ -33,6 +34,13 @@ io.sockets.on('connection', (socket) ->

socket.on 'scale', (min, max) ->
socket.broadcast.emit 'scale', min, max

socket.on 'mousemove', (x, y) ->
console.log 'onmousemove'
socket.broadcast.emit 'mousemove', x, y

socket.on 'stretch', (fn) ->
socket.broadcast.emit 'stretch', fn
)


Expand Down
154 changes: 154 additions & 0 deletions test/public/specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@


(function(/*! Stitch !*/) {
if (!this.specs) {
var modules = {}, cache = {}, require = function(name, root) {
var path = expand(root, name), module = cache[path], fn;
if (module) {
return module.exports;
} else if (fn = modules[path] || modules[path = expand(path, './index')]) {
module = {id: path, exports: {}};
try {
cache[path] = module;
fn(module.exports, function(name) {
return require(name, dirname(path));
}, module);
return module.exports;
} catch (err) {
delete cache[path];
throw err;
}
} else {
throw 'module \'' + name + '\' not found';
}
}, expand = function(root, name) {
var results = [], parts, part;
if (/^\.\.?(\/|$)/.test(name)) {
parts = [root, name].join('/').split('/');
} else {
parts = name.split('/');
}
for (var i = 0, length = parts.length; i < length; i++) {
part = parts[i];
if (part == '..') {
results.pop();
} else if (part != '.' && part != '') {
results.push(part);
}
}
return results.join('/');
}, dirname = function(path) {
return path.split('/').slice(0, -1).join('/');
};
this.specs = function(name) {
return require(name, '');
}
this.specs.define = function(bundle) {
for (var key in bundle)
modules[key] = bundle[key];
};
this.specs.modules = modules;
this.specs.cache = cache;
}
return this.specs.define;
}).call(this)({
"controllers/BinaryTable": function(exports, require, module) {(function() {
var require;

require = window.require;

describe('BinaryTable', function() {
var BinaryTable;
BinaryTable = require('controllers/binarytable');
return it('can noop', function() {});
});

}).call(this);
}, "controllers/CompressedImage": function(exports, require, module) {(function() {
var require;

require = window.require;

describe('CompressedImage', function() {
var CompressedImage;
CompressedImage = require('controllers/compressedimage');
return it('can noop', function() {});
});

}).call(this);
}, "controllers/DataCube": function(exports, require, module) {(function() {
var require;

require = window.require;

describe('DataCube', function() {
var DataCube;
DataCube = require('controllers/datacube');
return it('can noop', function() {});
});

}).call(this);
}, "controllers/Drop": function(exports, require, module) {(function() {
var require;

require = window.require;

describe('Drop', function() {
var Drop;
Drop = require('controllers/drop');
return it('can noop', function() {});
});

}).call(this);
}, "controllers/FitsHandler": function(exports, require, module) {(function() {
var require;

require = window.require;

describe('FitsHandler', function() {
var FitsHandler;
FitsHandler = require('controllers/fitshandler');
return it('can noop', function() {});
});

}).call(this);
}, "controllers/Image": function(exports, require, module) {(function() {
var require;

require = window.require;

describe('Image', function() {
var Image;
Image = require('controllers/image');
return it('can noop', function() {});
});

}).call(this);
}, "controllers/Table": function(exports, require, module) {(function() {
var require;

require = window.require;

describe('Table', function() {
var Table;
Table = require('controllers/table');
return it('can noop', function() {});
});

}).call(this);
}, "models/Source": function(exports, require, module) {(function() {
var require;

require = window.require;

describe('Source', function() {
var Source;
Source = require('models/source');
return it('can noop', function() {});
});

}).call(this);
}
});

require('lib/setup'); for (var key in specs.modules) specs(key);

0 comments on commit ff73208

Please sign in to comment.