-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
68 lines (62 loc) · 2.17 KB
/
popup.js
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
document.addEventListener('DOMContentLoaded', function () {
document.getElementById('exportimport').addEventListener('click', function () {
chrome.runtime.sendMessage({ command: 'exportimportwindow' });
window.close();
});
document.getElementById('play').addEventListener('click', function () {
chrome.runtime.sendMessage({ command: 'play' });
window.close();
});
document.getElementById('stop').addEventListener('click', function () {
chrome.runtime.sendMessage({ command: 'stop' });
window.close();
});
document.getElementById('playone').addEventListener('click', function () {
chrome.runtime.sendMessage({ command: 'playone' });
window.close();
});
document.getElementById('playall').addEventListener('click', function () {
chrome.runtime.sendMessage({ command: 'playall' });
window.close();
});
});
var myApp = angular.module("my-app", []);
myApp.controller("PopupCtrl", async function($scope, $http){
$scope.updateSteps = async function() {
let result = await sendMessageToBackground({command: 'getsteps'});
console.log(result);
$scope.steps = result.steps;
if (!$scope.steps)
{
$scope.steps = [];
}
$scope.steps.push({});
$scope.selectedStep = result.currentStep;
$scope.$digest();
}
await $scope.updateSteps();
$scope.clickX = async function(num) {
// Don't delete the last one (placeholder) since background script doesn't even know about it
if (num == $scope.steps.length - 1)
{
return;
}
if (confirm("Are you sure you want to delete this step?"))
{
let result = await sendMessageToBackground({command: 'deletestep', stepNum: num});
if (result.success)
{
await $scope.updateSteps();
}
}
}
$scope.selectStep = async function(num) {
let result = await sendMessageToBackground({command: 'selectstep', stepNum: num});
if (result.success)
{
$scope.selectedStep = num;
$scope.$digest();
}
}
}
);