Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add jsDoc description to all defined function #23

Closed
wants to merge 1 commit into from
Closed
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
42 changes: 30 additions & 12 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ $("#banner").fadeTo(4000, 500).slideUp(500, function(){
$("#developer").fadeTo(4000, 500).slideUp(500, function(){
$("#developer").slideUp(500);
});
/**
* @description Show how many cookie the browser currently has
*/
function setCookieCount(){
chrome.cookies.getAll({},function(cookies){
count=cookies.length;
Expand All @@ -17,17 +20,19 @@ chrome.cookies.getAll({},function(cookies){
}

setCookieCount();

/**
* @description show all the cookies that are set for the selected domain
*/
function displayCookies(){

setCookieCount();

document.getElementById("cookie").style.display="none";

var tableLog = document.getElementById("cookieslog");
tableLog.style.display="table";
tableLog.innerHTML = "";

var domain = document.getElementById("url").value;
//var tarea_regex = /(http(s?))\:\/\//gi;
if(domain=="" || domain==null){
Expand All @@ -46,22 +51,22 @@ function displayCookies(){
document.getElementById("banner").style.display="none";
chrome.cookies.getAll({url:domain},function(cookies){
//var row = tableLog.insertRow(-1);

for(var i in cookies){


if(i==0){
var firstRow = tableLog.insertRow(-1);
firstRow.insertCell(0).innerHTML="<strong>NAME</strong>";
firstRow.insertCell(1).innerHTML="<strong>VALUE</strong>";
}

console.log(cookies[i]);
//var row = "<tr><td>"+cookies[i].name+"</td><td>"+cookies[i].value+"</td></tr>";
var row = tableLog.insertRow(-1);
var value = cookies[i].value;
var name = cookies[i].name;

if(name.length>10){
name = name.substring(0,10);
name+="...";
Expand All @@ -76,7 +81,9 @@ function displayCookies(){
});
}
}

/**
* @description set a cookie for the domain from the url input
*/
function setCookies(){
document.getElementById("cookieslog").style.display="none";
var domain = document.getElementById("url").value;
Expand Down Expand Up @@ -112,6 +119,9 @@ function setCookies(){
}
//displayCookies();
//setCookies();
/**
* @description attach a change event listener to the browser cookies
*/
function onCookieChanged(){
chrome.cookies.onChanged.addListener(function(cookies){
console.log("cookies are being changed ", cookies.cookie.domain);
Expand All @@ -120,7 +130,9 @@ function onCookieChanged(){
}

onCookieChanged();

/**
* @description remove all cookies currently set
*/
function clearAllCookies(){
console.log("cookies cleared");
chrome.cookies.getAll({}, function(cookies) {
Expand All @@ -132,13 +144,19 @@ onCookieChanged();
document.getElementById("message").innerHTML = "All Cookies are cleared!";
setCookieCount();
}

/**
*
* @param {Object} cookie
* @description remove selected cookie
*/
function removeCookie(cookie) {
var url = "http" + (cookie.secure ? "s" : "") + "://" + cookie.domain +
cookie.path;
chrome.cookies.remove({"url": url, "name": cookie.name});
}

/**
* @description Hide alert banner
*/
function updateBanner(){
document.getElementById("banner").style.display="none";
}
Expand Down