Skip to content

Commit

Permalink
share ui, more dumps
Browse files Browse the repository at this point in the history
  • Loading branch information
mixedpuppy committed Nov 16, 2012
1 parent ad2e079 commit 437f57d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
8 changes: 7 additions & 1 deletion sidebar.css
Expand Up @@ -61,7 +61,13 @@ BODY {
padding-right:4px;
}
#content {
padding-top:4px;
padding:4px;
margin: 3px;
background-color: white;
}
.textbox {
background-color: white;
padding-top:4px;
margin: 3px;
border: 1px solid blue;
}
3 changes: 2 additions & 1 deletion sidebar.htm
Expand Up @@ -58,7 +58,8 @@
<li><a href="http://www.mozilla.org">non-same-origin-link</a></li>
</ul>

<div>Host: <div id="domain"></div></div>
<div>Shared: <div id="shared" class="textbox"></div></div>
<div>Host: <div id="domain" class="textbox"></div></div>
</div>


Expand Down
13 changes: 11 additions & 2 deletions sidebar.js
Expand Up @@ -70,17 +70,26 @@ messageHandlers = {
else
userIsDisconnected();
},
'social.user-recommend': function(data) {
$("#shared").text(data.url);
},
'social.user-unrecommend': function(data) {
$("#shared").text("");
}
};

navigator.mozSocial.getWorker().port.onmessage = function onmessage(e) {
//dump("SIDEBAR Got message: " + e.data.topic + " " + e.data.data +"\n");
dump("SIDEBAR Got message: " + e.data.topic + " " + e.data.data +"\n");
var topic = e.data.topic;
var data = e.data.data;
if (messageHandlers[topic])
messageHandlers[topic](data);
if (topic && topic == "social.port-closing") {
dump("!!!!!!!!! port has closed\n");
}
};
navigator.mozSocial.getWorker().port.postMessage({topic: "broadcast.listen", data: true});

dump("**** sidebar portid is "+navigator.mozSocial.getWorker().port._portid+"\n");
// here we ask the worker to reload itself. The worker will send a reload
// message to the Firefox api.
function workerReload() {
Expand Down
10 changes: 10 additions & 0 deletions worker.js
@@ -1,4 +1,5 @@
/* import a helper library */
dump("************** worker.js is executing ****************\n");
importScripts("workerScript.js");

// just a demo icon that we user for our toolbar button and our
Expand Down Expand Up @@ -33,6 +34,12 @@ function broadcast(topic, payload)
}
}

ononline = function() {
dump("!!!!!!! ononline called "+navigator.onLine+"\n");
}
onoffline = function() {
dump("!!!!!!! onoffline called "+navigator.onLine+"\n");
}
// Called when any port connects to the worker
onconnect = function(e) {
try {
Expand All @@ -49,6 +56,9 @@ onconnect = function(e) {
}
// handle the special message that tells us a port is closing.
if (msg.topic && msg.topic == "social.port-closing") {
if (port == apiPort) {
dump("!!!!!!!!!!!!! apiPort has closed!\n");
}
var index = _broadcastReceivers.indexOf(port);
if (index != -1) {
log("removed receiver " + index);
Expand Down

0 comments on commit 437f57d

Please sign in to comment.