]> git.wh0rd.org - chrome-ext/tabs-backup.git/blobdiff - popup.js
backup: filter out chrome-untrusted:// windows
[chrome-ext/tabs-backup.git] / popup.js
index a8f1a04d29eb9b9777b466ef220203b483857024..176e068473e2d61073613974cfd73df05e582b76 100644 (file)
--- a/popup.js
+++ b/popup.js
@@ -34,11 +34,11 @@ document.addEventListener('DOMContentLoaded', function () {
 });
 
 function menu_ShowOptions () {
-       chrome.tabs.create({url:chrome.extension.getURL("options.html")});
+       chrome.runtime.openOptionsPage();
 }
 
 function menu_ShowAdvancedView() {
-       chrome.tabs.create({url:chrome.extension.getURL("advanced.html")});
+       chrome.tabs.create({url: "/advanced.html"});
 }
 
 function menu_ShowOlderBackups () {
@@ -140,7 +140,10 @@ function insertBackupItem (backupName, backupObj, insertAtBeginning, doAnimation
                return function(event) {
                        bootbox.confirm("Open Windows & Tabs of backup '" + backupName + "'?", function(confirmed) {
                                if (confirmed) {
-                                       chrome.extension.getBackgroundPage().restoreNow(backupName);
+                                       chrome.runtime.sendMessage({
+                                               action: 'restoreNow',
+                                               args: [backupName],
+                                       });
                                }
                        });
 
@@ -157,9 +160,10 @@ function insertBackupItem (backupName, backupObj, insertAtBeginning, doAnimation
 
                        bootbox.confirm("Delete backup '" + backupName + "'?", function(confirmed) {
                                if (confirmed) {
-                                       chrome.extension.getBackgroundPage().deleteBackup(backupName, function() {
-                                               updateStorageInfo();
-                                       });
+                                       chrome.runtime.sendMessage({
+                                               action: 'deleteBackup',
+                                               args: [backupName],
+                                       }, () => updateStorageInfo());
 
                                        //if (elem.parentNode) {
                                        //  elem.parentNode.removeChild(elem);
@@ -298,9 +302,9 @@ function updateStorageInfo() {
                if (bytesInUse < 1024) {
                        storageText = bytesInUse.toFixed(2) + " bytes";
                } else if (bytesInUse < 1024 * 1024) {
-                       storageText = (bytesInUse / 1024).toFixed(2)  + " Kb";
+                       storageText = (bytesInUse / 1024).toFixed(2)  + " KiB";
                } else {
-                       storageText = (bytesInUse / (1024 * 1024)).toFixed(2) + " Mb";
+                       storageText = (bytesInUse / (1024 * 1024)).toFixed(2) + " MiB";
                }
 
                var storageSpan = document.getElementById("storageSpan");
@@ -321,7 +325,9 @@ function menu_backupNow() {
 
        lastTimeBackupNowClicked = new Date().getTime();
 
-       chrome.extension.getBackgroundPage().backupNowManual(function(success, backupName, backupObj) {
+       chrome.runtime.sendMessage({
+               action: 'backupNowManual',
+       }, function({success, backupName, backupObj}) {
                if (success) {
                        //updateBackupsList();
                        insertBackupItem (backupName, backupObj, true /*insertAtBeginning*/, true /*doAnimation*/);
@@ -336,18 +342,8 @@ function menu_backupNow() {
 }
 
 function menu_restoreNow() {
-       chrome.extension.getBackgroundPage().restoreNow('full_backup');
+       chrome.runtime.sendMessage({
+               action: 'restoreNow',
+               args: ['full_backup'],
+       });
 }
-
-//document.onload(function () {
-//var a = document.getElementById("myid");
-//a.innerHTML = "ciaociao";
-//});
-
-/*
-var storageLocal = chrome.storage.local;
-storageLocal.getBytesInUse(null, function(bytesInUse) {
-       var elem = document.createElement("div");
-       elem.innerHTML = "<b>BYTES IN USE: " + bytesInUse + "</b><br />";
-       document.body.appendChild(elem);
-});*/