Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion css/PopupStatus.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@
text-align: center;
font-weight: bold;

}
}


#TopLabel {
color: #79BCEA;
text-align:center
}

37 changes: 12 additions & 25 deletions js/Buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ 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
* 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) {
Expand All @@ -60,7 +58,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
Expand Down Expand Up @@ -90,7 +88,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,
Expand Down Expand Up @@ -119,9 +117,8 @@ 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) {
var newScrollView = ""
chrome.tabs.query(queryInfo, function(tabs) {
var newScrollView = "";
// Create new folder
if (document.getElementById("saveInNew").checked) {

Expand Down Expand Up @@ -168,7 +165,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 += "<li>" + tabs[i].title + "</li>";
}
Expand Down Expand Up @@ -197,14 +194,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
Expand Down Expand Up @@ -232,21 +229,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"));
});
}
});
Expand All @@ -259,7 +246,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();
Expand All @@ -270,14 +257,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";
Expand Down
24 changes: 10 additions & 14 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,29 @@
<meta charset = "UTF-8">
<html>
<head>
<meat name = "description" content = "An extension to save the links of all open tabs to read later">
<meta name = "description" content = "An extension to save the links of all open tabs to read later">
<meta name = "author" content = "Umayah Abdennabi">
<meta name = "author" content = "Muhammad Khalid">
<meta name = "keywords" content = "bookmark, save, links, tabs, chrome-extension">
<link rel = "stylesheet" type = "text/css" href = "css/Buttons.css"/>
<link rel = "stylesheet" type = "text/css" href = "css/PopupStatus.css"/>
</head>
<body bgcolor = "#ffffff">
<center><h3><font color=#79BCEA>
<p id="TopLabel">
Open Tabs
</p>
</font></h3></center>

<h3 id="TopLabel">Open Tabs</h3>
<div class="scrollContainer">
<div class="innerScroll">
<ol id="openLinks"></ol>
</div>
</div>
<center>
<p id="saveInNewP">
<input type=checkbox id="saveInNew">Save in new folder.
<input type=textbox id="saveInNewName" value="">
</p>
<div id="saveInNewP">
<label for='saveInNew'>Save in new folder</label>
<input type=checkbox id="saveInNew">
<input type=text id="saveInNewName" value="">
</div>
<button id = "SaveLinks">Save Checked Links</button>
<p id = "StatusLabel"></p>
</center>
<a href="http://sudohalt.github.io/LinkSave/" id="infoPage">info</a>
<p id = "StatusLabel"></p>
<a href="http://sudohalt.github.io/LinkSave/" target="_blank" id="infoPage">info</a>
<script src = "js/jquery-2.1.3.min.js"></script>
<script src = "js/Buttons.js"></script>
<script src = "js/StatusLabel.js"></script>
Expand Down