Commits

srirambms  committed a554990

Update popup.html, logo. Added options.

  • Participants
  • Parent commits 1b0cfda

Comments (0)

Files changed (5)

File Cerberus.crx

Binary file added.

File manifest.json

 {
-	"name": "Wiki Watchdog",
+	"name": "Cerberus",
 	"version": "1.0",
 	"description":"Chrome extension keep track of changes to wiki articles in your watchlist",
-	"icon": "res/logo.jpg",
-	"permissions": ["http://*.wikipedia.org/w/api.php"],
+	"icon": "res/logo.png",
+      "options_page": "options.html",
+	"permissions": ["http://*.wikipedia.org/w/api.php*"],
 	"browser_action": {
-    					"default_icon": "res/logo.jpg",
+    					"default_icon": "res/logo.png",
     					"popup": "popup.html"
  				}
 	

File options.html

+<html>
+<head><title>Wiki Watchdog Options</title></head>
+<script type="text/javascript">
+
+// Saves options to localStorage.
+function save_options() {
+  var select = document.getElementById("numList");
+  var numDispElements = select.children[select.selectedIndex].value;
+  localStorage["num_display_elements"] = numDispElements;
+
+  var check = document.getElementById("checkbox").checked;
+  if ( Boolean(check) == true)
+     localStorage["disp_all_rev"] = true;
+  else
+     localStorage["disp_all_rev"] = false;
+
+  close_options();
+}
+
+function close_options() {
+window.close();
+}
+
+// Restores select box state to saved value from localStorage.
+function restore_options() {
+  var num_elements = localStorage["num_display_elements"];
+  var checked_state = localStorage["disp_all_rev"];
+  
+  var check = document.getElementById("checkbox");
+  if (checked_state == "true")
+      check.checked = true;
+  else
+      check.checked = false;   //takes care of undef value
+
+
+  if (!num_elements) {
+    num_elements = 10;
+    return;
+  }
+  var select = document.getElementById("numList");
+  for (var i = 0; i < select.children.length; i++) {
+    var child = select.children[i];
+    if (child.value == num_elements) {
+      child.selected = "true";
+      break;
+    }
+  }
+  
+  
+  
+  
+  
+
+}
+
+</script>
+
+<body onload="restore_options()" style ="width: 350px; height: 400px">
+
+<! TODO: Use CSS for formatting >
+
+<div align="center">
+<b>Cerberus Settings</b>
+<br><hr><br>
+Maximum Number of 'Watch List' items displayed:
+<select id="numList">
+ <option value="10">10</option>
+ <option value="20">20</option>
+ <option value="50">50</option>
+</select>
+<br>
+<br>
+<input id = "checkbox" type="checkbox" name="allrev"/> Include multiple revisions of the same page?<br />
+<br><br><hr>
+<button onclick="save_options()">Save</button>&nbsp;&nbsp;&nbsp;<button onclick="close_options()">Close</button>
+</div>
+</body>
+</html>
+<style>
+body {
+  min-width:350px;
+  overflow-x:hidden;
+  
+}
+
+
+p {
+text-align:left;
+font-family:"Calibri", Times, serif;
+font-size: 14px;
+margin: 2px
+}
+
+div {
+border-style: solid;
+border-width: 1px;
+padding: 2px;
+margin: 3px;
+border-radius: 5px;
+background-color: #EEEEEF;
+
+}
+
+.note {
+font-size: 12px;
+font-style: italic;
+}
+</style>
+<script>
+
+var request = new XMLHttpRequest();
+
+
+query = "http://en.wikipedia.org/w/api.php?action=feedwatchlist&hours=72";
+
+if(localStorage["disp_all_rev"]=="true")
+   query +="&allrev";
+
+
+request.open("GET",query,true);
+
+request.onload = showlist;
+request.send();
+
+function showlist () {
+var watchlist = request.responseXML.getElementsByTagName("item");
+var aSettingsLink = document.createElement("a");
+aSettingsLink.setAttribute('href',"options.html");
+aSettingsLink.innerText = "Settings";
+document.body.appendChild(aSettingsLink);
+var end = parseInt(localStorage["num_display_elements"]);
+if (watchlist.length < end ){
+ end = watchlist.length;
+} 
+//for (var i = 0, temp; temp = watchlist[i]; i++){
+  for (var i =0; i < end;i++){
+   temp = watchlist[i]
+   var iDiv = document.createElement("div")
+
+   
+   var pText = document.createElement("p");
+   var pTitleLink = document.createElement("a");
+   if (watchlist[0].childNodes[1].textContent == "Error (wlnotloggedin)"){
+   //loginWindow = window.open("http://en.wikipedia.org/w/index.php?title=Special:UserLogin&action=submitlogin", "Login");
+   //loginWindow.createPopup();
+   pText.appendChild(document.createTextNode("You are not currently logged in. Click to login "));
+   pTitleLink.setAttribute('href',"http://en.wikipedia.org/w/index.php?title=Special:UserLogin&action=submitlogin");
+   pTitleLink.setAttribute('target',"_blank");
+   pTitleLink.setAttribute('onClick',"Javascript:window.close()");
+   pTitleLink.innerText = "here";
+   pText.appendChild(pTitleLink);
+   iDiv.appendChild(pText);
+   document.body.appendChild(iDiv);
+   return;
+   
+}
+
+   
+
+
+   var pHistoryLink = document.createElement("a");
+
+   pHistoryLink.setAttribute('href',"http://en.wikipedia.org/w/index.php?title="+temp.childNodes[1].textContent+"&action=history");
+   pHistoryLink.setAttribute('target',"_blank");
+   pHistoryLink.innerText = temp.childNodes[9].textContent;
+   
+   var pChangedOn = document.createTextNode("Changed on (Click to see history): ");
+   //var pClickHere = document.createTextNode("(Click to see history)");
+   
+   pText.appendChild(pChangedOn);
+   pText.appendChild(pHistoryLink);
+   //pText.appendChild(pClickHere);
+
+   pTitleLink.setAttribute('href',temp.childNodes[5].textContent);
+   pTitleLink.setAttribute('target',"_blank");
+   pTitleLink.innerText = temp.childNodes[1].textContent;
+   
+   
+   iDiv.appendChild(pTitleLink);
+   iDiv.appendChild(pText);
+   
+   document.body.appendChild(iDiv);
+}
+}
+
+				
+
+
+
+</script>

File res/logo.png

Added
New image