-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a few more pieces to download locally instead of from nlp
- Loading branch information
1 parent
f55cdf8
commit 558070b
Showing
6 changed files
with
1,009 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; -*- | ||
// vim:set ft=javascript ts=2 sw=2 sts=2 cindent: | ||
var Configuration = (function(window, undefined) { | ||
var abbrevsOn = true; | ||
var textBackgrounds = "striped"; | ||
var svgWidth = '100%'; | ||
var rapidModeOn = false; | ||
var confirmModeOn = true; | ||
var autorefreshOn = false; | ||
|
||
var visual = { | ||
margin: { x: 2, y: 1 }, | ||
arcTextMargin: 1, | ||
boxSpacing: 1, | ||
curlyHeight: 4, | ||
arcSpacing: 9, //10; | ||
arcStartHeight: 19, //23; //25; | ||
} | ||
|
||
return { | ||
abbrevsOn: abbrevsOn, | ||
textBackgrounds: textBackgrounds, | ||
visual: visual, | ||
svgWidth: svgWidth, | ||
rapidModeOn: rapidModeOn, | ||
confirmModeOn: confirmModeOn, | ||
autorefreshOn: autorefreshOn, | ||
}; | ||
})(window); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
// -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; -*- | ||
// vim:set ft=javascript ts=2 sw=2 sts=2 cindent: | ||
// TODO: does 'arguments.callee.caller' work? | ||
|
||
var Dispatcher = (function($, window, undefined) { | ||
var Dispatcher = function() { | ||
var that = this; | ||
|
||
var table = {}; | ||
|
||
var on = function(message, host, handler) { | ||
if (handler === undefined) { | ||
handler = host; | ||
host = arguments.callee.caller; | ||
} | ||
if (table[message] === undefined) { | ||
table[message] = []; | ||
} | ||
table[message].push([host, handler]); | ||
return this; | ||
}; | ||
|
||
// Notify listeners that we encountered an error in an asynch call | ||
var inAsynchError = false; // To avoid error avalanches | ||
var handleAsynchError = function(e) { | ||
if (!inAsynchError) { | ||
inAsynchError = true; | ||
// TODO: Hook printout into dispatch elsewhere? | ||
console.warn('Handled async error:', e); | ||
that.post('dispatchAsynchError', [e]); | ||
inAsynchError = false; | ||
} else { | ||
console.warn('Dropped asynch error:', e); | ||
} | ||
}; | ||
|
||
var post = function(asynch, message, args, returnType) { | ||
if (typeof(asynch) !== 'number') { | ||
// no asynch parameter | ||
returnType = args; | ||
args = message; | ||
message = asynch; | ||
asynch = null; | ||
} | ||
if (args === undefined) { | ||
args = []; | ||
} | ||
var results = []; | ||
// DEBUG: if (typeof(message) != "string" || !(message.match(/mouse/) || message == "hideComment")) console.log(message, args); | ||
|
||
if (typeof(message) === 'function') { | ||
// someone was lazy and sent a simple function | ||
var host = arguments.callee.caller; | ||
if (asynch !== null) { | ||
result = setTimeout(function() { | ||
try { | ||
message.apply(host, args); | ||
} catch(e) { | ||
that.handleAsynchError(e); | ||
} | ||
}, asynch); | ||
} else { | ||
result = message.apply(host, args); | ||
} | ||
results.push(result); | ||
} else { | ||
// a proper message, propagate to all interested parties | ||
var todo = table[message]; | ||
if (todo !== undefined) { | ||
$.each(todo, function(itemNo, item) { | ||
var result; | ||
if (asynch !== null) { | ||
result = setTimeout(function() { | ||
try { | ||
item[1].apply(item[0], args); | ||
} catch (e) { | ||
that.handleAsynchError(e); | ||
} | ||
}, asynch); | ||
} else { | ||
result = item[1].apply(item[0], args); | ||
} | ||
results.push(result); | ||
}); | ||
/* DEBUG | ||
} else { | ||
console.warn('Message ' + message + ' has no subscribers.'); // DEBUG | ||
*/ | ||
} | ||
} | ||
if (returnType == 'any') { | ||
var i = results.length; | ||
while (i--) { | ||
if (results[i] !== false) return results[i]; | ||
} | ||
return false; | ||
} | ||
if (returnType == 'all') { | ||
var i = results.length; | ||
while (i--) { | ||
if (results[i] === false) return results[i]; | ||
} | ||
} | ||
return results; | ||
}; | ||
|
||
var proxy = function(destination, message) { | ||
this.on(message, function() { | ||
destination.post(message, Array.prototype.slice.call(arguments)); | ||
}); | ||
}; | ||
|
||
var dispatcher = { | ||
on: on, | ||
post: post, | ||
proxy: proxy, | ||
}; | ||
Dispatcher.dispatchers.push(dispatcher); | ||
return dispatcher; | ||
}; | ||
|
||
Dispatcher.dispatchers = []; | ||
Dispatcher.post = function(asynch, message, args, returnType) { | ||
$.each(Dispatcher.dispatchers, function(dispatcherNo, dispatcher) { | ||
dispatcher.post(asynch, message, args, returnType); | ||
}); | ||
}; | ||
|
||
return Dispatcher; | ||
})(jQuery, window); |
Oops, something went wrong.