var PinPoint = PinPoint || {};

window.addEventListener('load', function() {
  var dashLink = document.getElementById("dash-link");
  dashLink.addEventListener("click", function(){
    chrome.tabs.create({url: "dashboard.html"});
  });
});

// Chrome API event listener
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse){
  var enabled = localStorage.enabled === "true"
  if (message.method === "add note"){
    addNote(message.url, message.note);
  }
  else if (message.method === "remove note"){
    removeNote(message.url, message.seconds);
  }
  sendResponse({notesArray: getNotes(message.url), enable: enabled});
});

// Chrome API icon event listener
chrome.browserAction.setPopup({popup: "popup.html"});

// event listeners for enable and disable feature on popup
window.onload = function(){
  var onButton = document.getElementById('on');
  var offButton = document.getElementById('off');

  // sets default state of app after intall to true
  if (localStorage.enabled === undefined) {
    localStorage.enabled = true;
  }
  // sets enabled in localStorage to true
  onButton.addEventListener('click', function(){
    localStorage["enabled"] = true
  });
  // sets enabled in localStorage to false
  offButton.addEventListener('click', function(){
    localStorage["enabled"] = false
  });
}




@@ -29,217 +29,8 @@
 %7D;%0A%0A
-window.addEventListener('load', function() %7B%0A  var dashLink = document.getElementById(%22dash-link%22);%0A  dashLink.addEventListener(%22click%22, function()%7B%0A    chrome.tabs.create(%7Burl: %22dashboard.html%22%7D);%0A  %7D);%0A%7D);%0A%0A
 // C
@@ -458,32 +458,46 @@
 n event listener
+ to open popup
 %0Achrome.browserA
@@ -720,16 +720,70 @@
 ('off');
+%0A%09var dashLink = document.getElementById(%22dash-link%22);
 %0A%0A  // s
@@ -1126,32 +1126,32 @@
 k', function()%7B%0A
-
     localStorage
@@ -1176,13 +1176,156 @@
 e%0A  %7D);%0A
+  // sets event listener for dashboard%0A  dashLink.addEventListener(%22click%22, function()%7B%0A    chrome.tabs.create(%7Burl: %22dashboard.html%22%7D);%0A  %7D);%0A
 %7D%0A%0A%0A%0A

remove second window.onload and organized code