Skip to content

Commit

Permalink
Hook up funf.
Browse files Browse the repository at this point in the history
  • Loading branch information
cscott committed Oct 9, 2012
1 parent c86337a commit 479f6eb
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
3 changes: 3 additions & 0 deletions TODO
Expand Up @@ -17,6 +17,9 @@ don't try to recognize letters if aspect ratio is way off or stroke is too long
still not reliably snapshotting tail end of command list; first 'undo' should
always be fast
hook up funf
- funf letters recognized (and prob)
- funf thumbnails at close


eyedropper tool.
lasso tool
Expand Down
5 changes: 4 additions & 1 deletion ncolors.js
Expand Up @@ -4,7 +4,7 @@
*/
/*global define:false, console:false, MessageChannel:false, window:false,
setTimeout:false, clearTimeout:false, navigator:false */
define(['require', 'domReady!', /*'./src/audio-map.js',*/ './src/brush', './src/brushdialog', './src/color', './src/compat', './src/dom', './src/drawcommand', './src/drawing', './src/layer', './src/gallery', './lib/hammer', './src/postmessage', './src/prandom!', './src/recog', './src/sound', './src/sync', './lib/BlobBuilder', './lib/FileSaver', 'font!custom,families:[Delius,DejaVu LGC Sans Book],urls:[fonts/style.css]'], function(require, document, /*audioMap,*/ Brush, BrushDialog, Color, Compat, Dom, DrawCommand, Drawing, Layer, Gallery, Hammer, postMessage, prandom, Recog, Sound, Sync, BlobBuilder, saveAs) {
define(['require', 'domReady!', /*'./src/audio-map.js',*/ './src/brush', './src/brushdialog', './src/color', './src/compat', './src/dom', './src/drawcommand', './src/drawing', './src/funf', './src/gallery', './lib/hammer', './src/layer', './src/postmessage', './src/prandom!', './src/recog', './src/sound', './src/sync', './src/version', './lib/BlobBuilder', './lib/FileSaver', 'font!custom,families:[Delius,DejaVu LGC Sans Book],urls:[fonts/style.css]'], function(require, document, /*audioMap,*/ Brush, BrushDialog, Color, Compat, Dom, DrawCommand, Drawing, Funf, Gallery, Hammer, Layer, postMessage, prandom, Recog, Sound, Sync, version, BlobBuilder, saveAs) {
'use strict';
// Android browser doesn't support MessageChannel
// -- however, it also has a losing canvas. so don't worry too much.
Expand All @@ -24,6 +24,9 @@ define(['require', 'domReady!', /*'./src/audio-map.js',*/ './src/brush', './src/
TOUCH_EVENT_INTERVAL_MS = 0;
}

// start up Funf logger
var funf = new Funf('NellColors'+version);

// transfer 'dev' tag from parent to this context
if (window.parent.document.body.classList.contains('dev')) {
document.body.classList.add('dev');
Expand Down
59 changes: 59 additions & 0 deletions src/funf.js
@@ -0,0 +1,59 @@
// encapsulate Funf functionality
define([], function() {

var FUNF_ACTION_RECORD = 'edu.mit.media.funf.RECORD';
var FUNF_ACTION_ARCHIVE = 'edu.mit.media.funf.ARCHIVE';
var FUNF_DATABASE_NAME = 'mainPipeline';

var Funf = function(appName) {
console.assert(appName.indexOf('-') < 0,
"funf doesn't like hyphens in the appName");
this.appName = appName;
};
Funf.prototype = {};
Funf.prototype.record = function(name, value) {
if (typeof value === 'object' /* includes arrays */) {
// protect complex values from funf flattening
value = JSON.stringify(value);
}
console.log('CSA FUNF '+name+' / '+value);
try {
// send custom event; there's a Firefox add-on which will
// turn this into an Android Intent:
// https://github.com/cscott/intent-addon
var event = document.createEvent('CustomEvent');
var o = { name: name, value: value, millis: Date.now() };
var intent = {
action: FUNF_ACTION_RECORD,
method: 'sendBroadcast',
extras: {
DATABASE_NAME: FUNF_DATABASE_NAME,
TIMESTAMP: Math.floor(Date.now()/1000),
NAME: this.appName,
VALUE: JSON.stringify(o)
}
};
event.initCustomEvent("intent-addon", true, true, intent);
document.documentElement.dispatchEvent(event);
} catch(e) {
console.log("Sending custom event failed: "+e);
}
};
Funf.prototype.archive = function() {
try {
var event = document.createEvent('CustomEvent');
var intent = {
action: FUNF_ACTION_ARCHIVE,
method: 'sendBroadcast',
extras: {
DATABASE_NAME: FUNF_DATABASE_NAME
}
};
event.initCustomEvent("intent-addon", true, true, intent);
document.documentElement.dispatchEvent(event);
} catch(e) {
console.log("Sending custom event failed: "+e);
}
};
return Funf;
});

0 comments on commit 479f6eb

Please sign in to comment.