From e2334cbe4e1097eb63e9aeae8c5fb657255b7cb5 Mon Sep 17 00:00:00 2001 From: LuqmanRom Date: Fri, 19 Jun 2015 16:15:45 -0500 Subject: [PATCH 1/4] Remove unncessary if statement --- js/Buttons.js | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/js/Buttons.js b/js/Buttons.js index e2c084a..4fb2af5 100755 --- a/js/Buttons.js +++ b/js/Buttons.js @@ -39,7 +39,6 @@ function saveTabs(params) { var queryInfo = { 'lastFocusedWindow': true }; - var folderExists = "" /* Get the bookmark tree and use the findFolder to see if the LinkSave folder * exists. If it does exist we create the bookmarks in that folder, or in a * new folder within it if the checkbox is clicked. If the folder does not exist @@ -232,21 +231,11 @@ function viewTabs() { //toggle the state of the checkbox checkbox.checked = !checkbox.checked; //console.log(title + " updated: " + checkbox.checked); - - } function attachChangeListener(element, index) { $(element).change(function() { - if ($(this).is(":checked")) { - //match the array's value to that of the new checkbox state - checkedTabsArr[index] = true; - //console.log(checkedTabsArr); - } else { - //match the array's value to that of the new checkbox state - checkedTabsArr[index] = false; - // console.log(checkedTabsArr); - } + checkedTabsArr[index] = Boolean($(this).is(":checked")); }); } }); @@ -259,7 +248,7 @@ viewTabs(); document.getElementById("SaveLinks").addEventListener("click", function() { var folderName; if (document.getElementById('saveInNew').checked) { - folderName = document.getElementById('saveInNewName').value + folderName = document.getElementById('saveInNewName').value; if (folderName === "") { var date = new Date(); folderName = date.getHours() + ":" + date.getMinutes() + " " + (date.getMonth() + 1) + "/" + date.getDay() + "/" + date.getFullYear(); @@ -270,14 +259,14 @@ document.getElementById("SaveLinks").addEventListener("click", function() { saveTabs(folderName); }); + +// Hide the input box if the checkbox is not checked document.getElementById("saveInNew").addEventListener("click", function() { var cond = !document.getElementById('saveInNew').checked; if (cond) { document.getElementById('saveInNewName').value = ""; document.getElementById('saveInNewName').disabled = true; document.getElementById("saveInNewName").style.visibility = "hidden"; - - } else { document.getElementById('saveInNewName').disabled = false; document.getElementById("saveInNewName").style.visibility = "visible"; From 2d5633c6147922cd4b8dabfde14cea4117df49fa Mon Sep 17 00:00:00 2001 From: LuqmanRom Date: Fri, 19 Jun 2015 16:21:33 -0500 Subject: [PATCH 2/4] Declare all the variables in for loop explicitly --- js/Buttons.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/js/Buttons.js b/js/Buttons.js index 4fb2af5..84d8a09 100755 --- a/js/Buttons.js +++ b/js/Buttons.js @@ -59,7 +59,7 @@ function saveTabs(params) { function(tabs) { // Clear the scroll box, and update it with the links that were saved // Go through all the open tabs and save each one, and update the scroll view - var newScrollView = "" + var newScrollView = ""; // The user wants to save the tabs in a new folder (within LinkSave folder) if (document.getElementById("saveInNew").checked) { // The name of the new folder will be the date if nothing is entered otherwise @@ -89,7 +89,7 @@ function saveTabs(params) { } }); // end chrome.bookmarks.create } else { // User just wants to save everything in the root of the LinkSave folder - for (i = 0; i < tabs.length; i++) { + for (var i = 0; i < tabs.length; i++) { if (document.getElementById(i.toString()).checked) { chrome.bookmarks.create({ 'parentId': bookmarkId, @@ -120,7 +120,7 @@ function saveTabs(params) { } else { // The Folder has already been created, so do the same as above just not creating the LinkSave folder chrome.tabs.query(queryInfo, function(tabs) { - var newScrollView = "" + var newScrollView = ""; // Create new folder if (document.getElementById("saveInNew").checked) { @@ -167,7 +167,7 @@ function saveTabs(params) { if (document.getElementById("saveInNew").checked) { document.getElementById("openLinks").innerHTML = ""; - for (i = 0; i < tabs.length; i++) { + for (var i = 0; i < tabs.length; i++) { if (checkedTabsArr[i.toString()]) { document.getElementById("openLinks").innerHTML += "
  • " + tabs[i].title + "
  • "; } @@ -196,14 +196,14 @@ function viewTabs() { // Go through all the tabs open, and add them to the scrollview along with a number and checkbox chrome.tabs.query(queryInfo, function(tabs) { - for (i = 0; i < tabs.length; i++) { + for (var i = 0; i < tabs.length; i++) { var thisTab = tabs[i]; // add checkboxes to each link for the user to include or disclude // start by creating a blank checkbox element var thisCheckbox = document.createElement('input'); thisCheckbox.type = "checkbox"; - thisCheckbox.id = i; + thisCheckbox.id = i.toString(); thisCheckbox.checked = true; //Add the event listener to the newly created checkbox From 5d2460c02e1392a37168fe396729d0044f1a2a0e Mon Sep 17 00:00:00 2001 From: LuqmanRom Date: Fri, 19 Jun 2015 16:30:17 -0500 Subject: [PATCH 3/4] Remove deprecated HTML tag. Move the styling to CSS --- css/PopupStatus.css | 6 ++++++ js/Buttons.js | 6 ++---- popup.html | 9 +++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/css/PopupStatus.css b/css/PopupStatus.css index 448c498..7c15819 100755 --- a/css/PopupStatus.css +++ b/css/PopupStatus.css @@ -5,4 +5,10 @@ text-align: center; font-weight: bold; +} + + +#TopLabel { + color: #79BCEA; + text-align:center } \ No newline at end of file diff --git a/js/Buttons.js b/js/Buttons.js index 84d8a09..3848a7e 100755 --- a/js/Buttons.js +++ b/js/Buttons.js @@ -44,8 +44,7 @@ function saveTabs(params) { * new folder within it if the checkbox is clicked. If the folder does not exist * we create it and then do the above. Since the operations are asynchronous * we must do everything in the callback functions, so there is a lot of nesting */ - chrome.bookmarks.getTree( - function(bookmarks) { + chrome.bookmarks.getTree(function(bookmarks) { var bookmarkId = findFolder(bookmarks, "LinkSave bookmarks"); // bookmark folder does not exist so create it if (bookmarkId == false) { @@ -118,8 +117,7 @@ function saveTabs(params) { }); // end chrome.tabs.query }); // end chrome.bookmarks.create } else { // The Folder has already been created, so do the same as above just not creating the LinkSave folder - chrome.tabs.query(queryInfo, - function(tabs) { + chrome.tabs.query(queryInfo, function(tabs) { var newScrollView = ""; // Create new folder if (document.getElementById("saveInNew").checked) { diff --git a/popup.html b/popup.html index 7bce73e..021cc3b 100755 --- a/popup.html +++ b/popup.html @@ -3,7 +3,7 @@ - + @@ -11,11 +11,8 @@ -

    -

    - Open Tabs -

    -

    + +

    Open Tabs

    From 03604d2929dae8e02217aad3badbbeb2c5867d6b Mon Sep 17 00:00:00 2001 From: LuqmanRom Date: Fri, 19 Jun 2015 16:45:56 -0500 Subject: [PATCH 4/4] Fixed info link and other minors --- css/PopupStatus.css | 3 ++- popup.html | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/css/PopupStatus.css b/css/PopupStatus.css index 7c15819..c6f2187 100755 --- a/css/PopupStatus.css +++ b/css/PopupStatus.css @@ -11,4 +11,5 @@ #TopLabel { color: #79BCEA; text-align:center -} \ No newline at end of file +} + diff --git a/popup.html b/popup.html index 021cc3b..955af5d 100755 --- a/popup.html +++ b/popup.html @@ -18,15 +18,14 @@

    Open Tabs

    -
    -

    - Save in new folder. - -

    +
    + + + +
    -

    -
    - info +

    + info