Browse files

Implemented correct patch to fix issue #19 and changes to ensure that…

… the NPAPI plugin on Linux (issue #20) is indeed loaded.
  • Loading branch information...
1 parent 2c137a5 commit 6abfaf15bee3ae9e3e0b94faca79d5aa6dc18237 @kench kench committed Jul 1, 2011
View
39 chrome-extension-mac/content_script/event_link.js
@@ -4,23 +4,42 @@ console.log("DepthJS: Loading Event Link");
DepthJS.eventLink.initPort = function() {
if (DepthJS.verbose) console.log("DepthJS: Event link init");
- DepthJS.eventLink.domPort = $("<div id='DepthJS_eventPort' style='display:none'></div>");
+ DepthJS.eventLink.domPort = null;
+ var checkForEventPort = function() {
+ var $eventPort = $("#DepthJS_eventPort")
+ if ($eventPort.length > 0 ) {
+ console.log("DepthJS: Registering eventPort on DepthJS supported web page");
+ DepthJS.eventLink.domPort = $eventPort;
+ DepthJS.eventLink.onEvent({type: "KinectInit", data:{}});
+ return true;
+ }
+ return false;
+ };
$(function() {
- DepthJS.eventLink.domPort.appendTo("body");
+ if (!checkForEventPort()) {
+ // try again in 300msec
+ setTimeout(checkForEventPort, 300);
+ }
});
DepthJS.browser.addContentScriptListener("event", DepthJS.eventLink.onEvent);
};
DepthJS.eventLink.onEvent = function (msg) {
DepthJS.logSortaVerbose(msg.type, "DepthJS: event " + msg.type);
- var handler = DepthJS.eventHandlers["on"+msg.type];
- if (handler != null) {
- handler(msg.data);
+ if (DepthJS.eventLink.domPort != null) {
+ // jQuery's trigger doesn't seem to work here for some reason
+ var e = document.createEvent("Event");
+ e.initEvent("DepthJSEvent", false, false);
+ if (msg.jsonRep == null) {
+ msg.jsonRep = JSON.stringify(msg);
+ };
+ DepthJS.eventLink.domPort.text(msg.jsonRep);
+ DepthJS.eventLink.domPort.get(0).dispatchEvent(e);
+ } else {
+ var handler = DepthJS.eventHandlers["on"+msg.type];
+ if (handler != null) {
+ handler(msg.data);
+ }
}
- // jQuery's trigger doesn't seem to work here for some reason
- var event = document.createEvent("Event");
- event.initEvent(msg.type, false, false);
- DepthJS.eventLink.domPort.text(msg.jsonRep);
- DepthJS.eventLink.domPort.get(0).dispatchEvent(event);
};
}
View
7 chrome-extension-mac/manifest.json
@@ -14,9 +14,10 @@
"permissions": ["tabs", "http://*/*", "https://*/*","notifications"],
- "plugins": [{
- "path": "plugin/depthjs.plugin"
- }],
+ "plugins": [
+ { "path": "plugin/depthjs.so" },
+ { "path": "plugin/depthjs.plugin" }
+ ],
"browser_action": {
"default_icon": "images/logo_128x128.png",
View
2 npapi_plugin/build-linux.sh
@@ -10,6 +10,6 @@ g++ -fPIC -shared -Wno-write-strings -lresolv \
-lfreenect \
-lz \
-Wall \
- -o depthjs \
+ -o depthjs.so \
np_entry.cc npp_entry.cc plugin.cc depthjs.cc \
ocv_freenect.cpp bg_fg_blobs.cpp

0 comments on commit 6abfaf1

Please sign in to comment.