-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
76 lines (58 loc) · 1.88 KB
/
popup.js
File metadata and controls
76 lines (58 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
console.log('popup.js');
Firebase.INTERNAL.forceWebSockets();
var uniqueId = null;
var fb;
var genId = function() {
var idLength = 6;
var text = "";
var charset = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
for( var i=0; i < idLength; i++ ) {
text += charset.charAt(Math.floor(Math.random() * charset.length));
}
return text;
}
var generateAndStoreUniqueId = function() {
uniqueId = genId();
localStorage.setItem("ctrl-uniqueId", uniqueId);
};
$(function() {
$("#ctrl-uniqueId").text(uniqueId);
$('.ctrl-checkbox').click(function(event) {
if ($(this).hasClass('ctrl-checked')) {
$(this).removeClass('ctrl-checked');
$(this).addClass('ctrl-unchecked');
$('.ctrl-menu').removeClass('developer-mode');
}
else {
$(this).addClass('ctrl-checked');
$(this).removeClass('ctrl-unchecked');
$('.ctrl-menu').addClass('developer-mode');
}
});
$('#ctrl-build').on('click', function() {
window.close();
chrome.tabs.query({active: true, currentWindow: true}, function (tabs){
chrome.tabs.sendMessage(tabs[0].id, {action: "launchControlBox"});
});
});
$('#ctrl-marketplace').on('click', function() {
window.close();
chrome.tabs.query({active: true, currentWindow: true}, function (tabs){
chrome.tabs.sendMessage(tabs[0].id, {action: "redirectToMarketplace"});
});
});
});
uniqueId = localStorage.getItem("ctrl-uniqueId");
if(uniqueId == null) {
generateAndStoreUniqueId();
}
chrome.tabs.query({active: true, currentWindow: true}, function (tabs){
chrome.tabs.sendMessage(tabs[0].id, {'uniqueId': uniqueId});
});
fb = new Firebase('https://8tracks-pebble.firebaseio.com/codes/' + uniqueId);
var app = angular.module("popup", ["firebase"]);
app.controller("appCtrl", function($scope, $firebase) {
var plugins = fb.child('plugins');
var sync = $firebase(plugins);
$scope.plugins = sync.$asArray();
});