Skip to content

Commit

Permalink
stream now attaches to 'this' context, rather than window - means we …
Browse files Browse the repository at this point in the history
…can tie it away inside of beta object: jsbin
  • Loading branch information
remy committed Feb 19, 2011
1 parent ede87a1 commit 48d82c1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions js/chrome/stream.js
@@ -1,4 +1,4 @@
(function () {
(function (global) {
var $stream = $('<div id="streaming"><span class="msg"></span><span class="n"></span><span class="listen"> (click here to <span class="resume">resume</span><span class="pause">pause</span>)</span></div>').prependTo('body'),
streaming = false,
$body = $('body'),
Expand Down Expand Up @@ -86,7 +86,7 @@ forbind.on({

$stream.one('click', function () {
window.location.search.replace(/stream=(.+?)\b/, function (n, key) {
window.stream.join(key);
global.stream.join(key);
});
});
} else {
Expand Down Expand Up @@ -133,7 +133,7 @@ function updateCount(data) {
}
}

window.stream = {
global.stream = {
create: function () {
key = (Math.abs(~~(Math.random()*+new Date))).toString(32); // OTT?

Expand All @@ -152,19 +152,19 @@ window.stream = {

$(document).one('keyup', function (event) {
if (streaming && event.which == 27) {
window.stream.leave();
global.stream.leave();
}
});

$stream.one('click', function () {
window.stream.leave();
global.stream.leave();
});

for (var type in editors) {
try {
$(editors[type].win.document).one('keyup', function (event) {
if (event.which == 27) {
window.stream.leave();
global.stream.leave();
}
});
} catch (e) {
Expand All @@ -180,12 +180,12 @@ window.stream = {
};

window.location.search.replace(/stream=(.+?)\b/, function (n, key) {
window.stream.join(key);
global.stream.join(key);
});

if (sessionStorage.getItem('streamkey')) {
key = sessionStorage.getItem('streamkey');
forbind.join(key, sessionStorage.getItem('streamwritekey') || undefined);
}

})();
})(this);

0 comments on commit 48d82c1

Please sign in to comment.