From a89471137ca36a4a9b412476e736962bfb602ee9 Mon Sep 17 00:00:00 2001 From: Zach Manring Date: Thu, 30 Jan 2014 21:28:03 -0500 Subject: [PATCH] Removing update.html page. --- assets/javascripts/background.js | 89 ++++++---- assets/javascripts/context.js | 9 +- assets/javascripts/popup.js | 271 ++++++++++++++++--------------- assets/javascripts/tab.js | 16 +- manifest.json | 18 +- 5 files changed, 223 insertions(+), 180 deletions(-) diff --git a/assets/javascripts/background.js b/assets/javascripts/background.js index e18e8e1..b6b2333 100644 --- a/assets/javascripts/background.js +++ b/assets/javascripts/background.js @@ -1,12 +1,13 @@ // Analytics var _gaq = _gaq || []; - _gaq.push(['_setAccount', 'UA-38039307-2']); +_gaq.push(['_setAccount', 'UA-38039307-2']); // Had to load it via js or google analytics throws a tantrum (function() { var ga = document.createElement('script'); ga.src = 'https://ssl.google-analytics.com/ga.js'; - var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); + var s = document.getElementsByTagName('script')[0]; + s.parentNode.insertBefore(ga, s); })(); @@ -21,7 +22,7 @@ YUM.createContextMenu = function() { chrome.contextMenus.create({ 'id': 'chrome-ext-delicious-private-context', 'contexts': ['page', 'selection'], - 'title':'Add link', + 'title': 'Add link', 'onclick': YUM.injectModal }); }; @@ -38,7 +39,8 @@ YUM.getSuggestion = function(query) { link['extended'], link['href'], ((link['shared'] === 'no') ? 'private' : ''), link['tags'].join(' '), - link['time']].join(' ').toLowerCase(); + link['time'] + ].join(' ').toLowerCase(); return words.every(function(word) { return (search.indexOf(word) !== -1); @@ -47,7 +49,7 @@ YUM.getSuggestion = function(query) { }); var suggestedList = []; - for (var i=0; i/g, ">") - .replace(/"/g, """); + .replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """); }; YUM.injectModal = function(info, tab) { - chrome.tabs.insertCSS(null, { file:"/assets/stylesheets/tab.css" }); - chrome.tabs.executeScript(null, { file:"/assets/javascripts/context.js" }); + chrome.tabs.insertCSS(null, { + file: "/assets/stylesheets/tab.css" + }); + chrome.tabs.executeScript(null, { + file: "/assets/javascripts/context.js" + }); - chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { - chrome.tabs.sendMessage(tabs[0].id, {data: info}); + chrome.tabs.query({ + active: true, + currentWindow: true + }, function(tabs) { + chrome.tabs.sendMessage(tabs[0].id, { + data: info + }); }); _gaq.push(['_trackEvent', 'modalOpened', 'contextMenu']); @@ -82,18 +93,24 @@ YUM.injectModal = function(info, tab) { YUM.isCurrentTabSaved = function() { var searchString = localStorage.getItem('chrome-ext-delicious-links'); if (searchString) { - chrome.tabs.getSelected(null,function(tab) { + chrome.tabs.getSelected(null, function(tab) { - if (searchString.indexOf('"' + tab.url + '"') >= 0 ) { - chrome.browserAction.setBadgeText({text:'√'}); - chrome.browserAction.setBadgeBackgroundColor({color: '#468ED9'}); + if (searchString.indexOf('"' + tab.url + '"') >= 0) { + chrome.browserAction.setBadgeText({ + text: '√' + }); + chrome.browserAction.setBadgeBackgroundColor({ + color: '#468ED9' + }); chrome.contextMenus.update('chrome-ext-delicious-private-context', { - 'title':'Modify link' + 'title': 'Modify link' }); } else { - chrome.browserAction.setBadgeText({text:''}); + chrome.browserAction.setBadgeText({ + text: '' + }); chrome.contextMenus.update('chrome-ext-delicious-private-context', { - 'title':'Add link' + 'title': 'Add link' }); } }); @@ -113,7 +130,9 @@ YUM.openSelectedSuggestion = function(selection) { if (selection.match(regex)) { _gaq.push(['_trackEvent', 'onInputEntered', 'omnibox']); - chrome.tabs.update(null, {url: selection}); + chrome.tabs.update(null, { + url: selection + }); } }; @@ -128,10 +147,24 @@ YUM.openUpdatePage = function() { // Events YUM.createContextMenu(); -chrome.omnibox.onInputChanged.addListener(function(query, suggest) { suggest(YUM.getSuggestion(query)); }); -chrome.omnibox.onInputEntered.addListener(function(input) { YUM.openSelectedSuggestion(input); }); -chrome.omnibox.setDefaultSuggestion({"description":" "}); -chrome.runtime.onInstalled.addListener(function () { YUM.openUpdatePage(); }); -chrome.runtime.onMessage.addListener(function(message) { if (message.url) { YUM.openNewTab(message.url); } }); -chrome.tabs.onActivated.addListener(function() { YUM.isCurrentTabSaved(); }); -chrome.tabs.onUpdated.addListener(function() { YUM.isCurrentTabSaved(); }); +chrome.omnibox.onInputChanged.addListener(function(query, suggest) { + suggest(YUM.getSuggestion(query)); +}); +chrome.omnibox.onInputEntered.addListener(function(input) { + YUM.openSelectedSuggestion(input); +}); +chrome.omnibox.setDefaultSuggestion({ + "description": " " +}); +// chrome.runtime.onInstalled.addListener(function () { YUM.openUpdatePage(); }); +chrome.runtime.onMessage.addListener(function(message) { + if (message.url) { + YUM.openNewTab(message.url); + } +}); +chrome.tabs.onActivated.addListener(function() { + YUM.isCurrentTabSaved(); +}); +chrome.tabs.onUpdated.addListener(function() { + YUM.isCurrentTabSaved(); +}); diff --git a/assets/javascripts/context.js b/assets/javascripts/context.js index 5b8e7a6..d79ad3e 100644 --- a/assets/javascripts/context.js +++ b/assets/javascripts/context.js @@ -1,4 +1,3 @@ - chrome.runtime.onMessage.addListener( function(request) { @@ -9,9 +8,9 @@ chrome.runtime.onMessage.addListener( var html = [ '
', - '', - '