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 = [
'
',
- '
',
- '
',
- '
',
+ '
',
+ '
',
+ '
',
'
'
].join('\n');
@@ -19,4 +18,4 @@ chrome.runtime.onMessage.addListener(
}
- });
\ No newline at end of file
+ });
diff --git a/assets/javascripts/popup.js b/assets/javascripts/popup.js
index 047a50f..57b9d8a 100644
--- a/assets/javascripts/popup.js
+++ b/assets/javascripts/popup.js
@@ -4,32 +4,34 @@
// App
var app = angular.module('yum', ['yum.filters', 'yum.services', 'yum.controllers', 'yum.directives']);
- app.config(['$routeProvider', function($routeProvider) {
- $routeProvider.when('/login', {
- templateUrl: 'views/login.html',
- controller: 'LoginCtrl'
- });
- $routeProvider.when('/new', {
- templateUrl: 'views/new.html',
- controller: 'NewLinkCtrl',
- resolve: {
- tab: function($q, delicious) {
- return delicious.getTab();
+ app.config(['$routeProvider',
+ function($routeProvider) {
+ $routeProvider.when('/login', {
+ templateUrl: 'views/login.html',
+ controller: 'LoginCtrl'
+ });
+ $routeProvider.when('/new', {
+ templateUrl: 'views/new.html',
+ controller: 'NewLinkCtrl',
+ resolve: {
+ tab: function($q, delicious) {
+ return delicious.getTab();
+ }
}
- }
- });
- $routeProvider.when('/bookmarks', {
- templateUrl: 'views/bookmarks.html',
- controller: 'BookmarksCtrl'
- });
- $routeProvider.when('/options', {
- templateUrl: 'views/options.html',
- controller: 'OptionsCtrl'
- });
- $routeProvider.otherwise({
- redirectTo: '/login'
- });
- }]);
+ });
+ $routeProvider.when('/bookmarks', {
+ templateUrl: 'views/bookmarks.html',
+ controller: 'BookmarksCtrl'
+ });
+ $routeProvider.when('/options', {
+ templateUrl: 'views/options.html',
+ controller: 'OptionsCtrl'
+ });
+ $routeProvider.otherwise({
+ redirectTo: '/login'
+ });
+ }
+ ]);
app.config(function($compileProvider) {
$compileProvider.urlSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|chrome-extension):/);
@@ -74,11 +76,13 @@
// Filters
var filters = angular.module('yum.filters', []);
- filters.filter('list', [function() {
- return function(arr) {
- return arr.join(', ');
- };
- }]);
+ filters.filter('list', [
+ function() {
+ return function(arr) {
+ return arr.join(', ');
+ };
+ }
+ ]);
filters.filter('filterByWord', function() {
return function(links, query) {
@@ -91,12 +95,8 @@
return links.filter(function(link) {
// Combine link properties to search into string
var search = [
- (localStorage.getItem('chrome-ext-delicious-filter-description')) === 'true' ? link['description'] : '',
- (localStorage.getItem('chrome-ext-delicious-filter-extended')) === 'true' ? link['extended'] : '',
- (localStorage.getItem('chrome-ext-delicious-filter-url')) === 'true' ? link['href'] : '',
- ((link['shared'] === 'no') ? 'private' : ''),
- (localStorage.getItem('chrome-ext-delicious-filter-tags')) === 'true' ? link['tags'].join(' ') : '',
- (localStorage.getItem('chrome-ext-delicious-filter-time')) === 'true' ? link['time'] : ''].join(' ').toLowerCase();
+ (localStorage.getItem('chrome-ext-delicious-filter-description')) === 'true' ? link['description'] : '', (localStorage.getItem('chrome-ext-delicious-filter-extended')) === 'true' ? link['extended'] : '', (localStorage.getItem('chrome-ext-delicious-filter-url')) === 'true' ? link['href'] : '', ((link['shared'] === 'no') ? 'private' : ''), (localStorage.getItem('chrome-ext-delicious-filter-tags')) === 'true' ? link['tags'].join(' ') : '', (localStorage.getItem('chrome-ext-delicious-filter-time')) === 'true' ? link['time'] : ''
+ ].join(' ').toLowerCase();
// all of the words
return words.every(function(word) {
@@ -188,7 +188,10 @@
var defer = $q.defer();
if (chrome.tabs) {
- chrome.tabs.query({windowId: chrome.windows.WINDOW_ID_CURRENT, active: true}, function(tab) {
+ chrome.tabs.query({
+ windowId: chrome.windows.WINDOW_ID_CURRENT,
+ active: true
+ }, function(tab) {
$rootScope.$apply(function() {
defer.resolve(tab[0]);
});
@@ -241,7 +244,7 @@
return link;
}
- if ( ! json.posts) {
+ if (!json.posts) {
return [];
} else if (angular.isArray(json.posts.post)) {
return json.posts.post.map(_parseLink);
@@ -273,25 +276,25 @@
};
}());
- Delicious.getDeliciousLinkDataByUrl = (function () {
- return function getDeliciousLinkDataByUrl(url) {
- var defer = $q.defer(),
- hash = localStorage.getItem('chrome-ext-delicious'),
- options = {
- method: 'GET',
- url: 'https://api.del.icio.us/v1/posts/get?url=' + url,
- headers: {
- 'Authorization': 'Basic ' + hash
- },
- transformResponse: Delicious.parseLinks
- };
+ Delicious.getDeliciousLinkDataByUrl = (function() {
+ return function getDeliciousLinkDataByUrl(url) {
+ var defer = $q.defer(),
+ hash = localStorage.getItem('chrome-ext-delicious'),
+ options = {
+ method: 'GET',
+ url: 'https://api.del.icio.us/v1/posts/get?url=' + url,
+ headers: {
+ 'Authorization': 'Basic ' + hash
+ },
+ transformResponse: Delicious.parseLinks
+ };
- $http(options).then(function(resp) {
- defer.resolve(resp.data);
- });
+ $http(options).then(function(resp) {
+ defer.resolve(resp.data);
+ });
- return defer.promise;
- };
+ return defer.promise;
+ };
}());
Delicious.getUpdate = (function() {
@@ -405,7 +408,7 @@
return tag.tag;
}
- if ( ! json.tags) {
+ if (!json.tags) {
return [];
} else if (angular.isArray(json.tags.tag)) {
return json.tags.tag.map(_parseTag);
@@ -459,7 +462,7 @@
// Clear storage before fetching new links, this will keep it up to date if the fetch fails for any reason
delete localStorage['chrome-ext-delicious-last-update'];
delete localStorage['chrome-ext-delicious-links'];
- Delicious.fetchLinks().then(function () {
+ Delicious.fetchLinks().then(function() {
localStorage.setItem('chrome-ext-delicious-last-update', update.time);
});
}
@@ -514,15 +517,15 @@
delicious.authenticate($scope.username, $scope.password)
.success(function(data) {
- localStorage.setItem('chrome-ext-delicious-username', $scope.username);
- $rootScope.loggedIn = true;
- $location.path('/new');
- })
+ localStorage.setItem('chrome-ext-delicious-username', $scope.username);
+ $rootScope.loggedIn = true;
+ $location.path('/new');
+ })
.error(function(data) {
- localStorage.removeItem('chrome-ext-delicious-username', $scope.username);
- $rootScope.loginFailed = true;
- $location.path('/new');
- });
+ localStorage.removeItem('chrome-ext-delicious-username', $scope.username);
+ $rootScope.loginFailed = true;
+ $location.path('/new');
+ });
};
});
@@ -566,7 +569,7 @@
$scope.suggestedTags.splice(index, 1);
};
- delicious.getDeliciousLinkDataByUrl($scope.url).then(function (data) {
+ delicious.getDeliciousLinkDataByUrl($scope.url).then(function(data) {
var link = data[0];
if (link) {
@@ -661,7 +664,9 @@
});
} else {
// Send message to background to open!
- chrome.runtime.sendMessage({url: $scope.urlListToOpen[i].href});
+ chrome.runtime.sendMessage({
+ url: $scope.urlListToOpen[i].href
+ });
}
}
@@ -747,7 +752,7 @@
var count = 8;
if ($scope.limit < $scope.links.length) {
$scope.limit += count;
- analytics.push(['_trackEvent', 'link-pages-loaded', ($scope.limit/count).toString()]);
+ analytics.push(['_trackEvent', 'link-pages-loaded', ($scope.limit / count).toString()]);
}
};
@@ -827,80 +832,88 @@
// Directives
var directives = angular.module('yum.directives', []);
- directives.directive('appVersion', ['version', function(version) {
- return function(scope, elm, attrs) {
- elm.text(version);
- };
- }]);
+ directives.directive('appVersion', ['version',
+ function(version) {
+ return function(scope, elm, attrs) {
+ elm.text(version);
+ };
+ }
+ ]);
// TODO: Make select-two-show optional
- directives.directive('selectTwo', [function() {
- function link(scope, element, attrs, a) {
- var select = angular.element(element);
-
- scope.$watch('show', function() {
- if(scope.tags.length > 0) {
- initSelectTwo();
- }
- });
- scope.$watch('tags', function() {
- if(scope.tags.length > 0) {
- initSelectTwo();
- }
- });
- scope.$watch('val', function(newVal) {
- select.select2('val', newVal);
- });
-
- select.bind('change', function(e) {
- scope.$apply(function() {
- scope.val = e.val;
+ directives.directive('selectTwo', [
+ function() {
+ function link(scope, element, attrs, a) {
+ var select = angular.element(element);
+
+ scope.$watch('show', function() {
+ if (scope.tags.length > 0) {
+ initSelectTwo();
+ }
});
- });
- function initSelectTwo() {
- if (!scope.show) return;
- select.select2({
- tags: scope.tags,
- tokenSeparators: [',']
+ scope.$watch('tags', function() {
+ if (scope.tags.length > 0) {
+ initSelectTwo();
+ }
});
- select.select2('val', scope.val);
+ scope.$watch('val', function(newVal) {
+ select.select2('val', newVal);
+ });
+
+ select.bind('change', function(e) {
+ scope.$apply(function() {
+ scope.val = e.val;
+ });
+ });
+
+ function initSelectTwo() {
+ if (!scope.show) return;
+ select.select2({
+ tags: scope.tags,
+ tokenSeparators: [',']
+ });
+ select.select2('val', scope.val);
+ }
}
+
+ return {
+ restrict: 'A',
+ scope: {
+ val: '=ngModel',
+ tags: '=selectTwo',
+ show: '=selectTwoShow'
+ },
+ link: link
+ };
}
+ ]);
- return {
- restrict: 'A',
- scope: {
- val: '=ngModel',
- tags: '=selectTwo',
- show: '=selectTwoShow'
- },
- link: link
- };
- }]);
+ directives.directive('customCheckbox', [
+ function() {
+ function link(scope, element, attrs) {
+ var className = attrs['customCheckbox'],
+ $wrapper;
- directives.directive('customCheckbox', [function() {
- function link(scope, element, attrs) {
- var className = attrs['customCheckbox'], $wrapper;
+ element.wrap('');
+ $wrapper = element.parent();
- element.wrap('');
- $wrapper = element.parent();
+ $wrapper.on('click', function(e) {
+ scope.$apply(function() {
+ scope[attrs['ngModel']] = !scope[attrs['ngModel']];
+ });
+ });
- $wrapper.on('click', function(e) {
- scope.$apply(function() {
- scope[attrs['ngModel']] = !scope[attrs['ngModel']];
+ scope.$watch(attrs['ngModel'], function(value) {
+ $wrapper.toggleClass(className + '-checked', value);
});
- });
+ }
- scope.$watch(attrs['ngModel'], function(value) {
- $wrapper.toggleClass(className + '-checked', value);
- });
+ return {
+ restrict: 'A',
+ link: link
+ };
}
-
- return {
- restrict: 'A',
- link: link
- };
- }]);
+ ]);
directives.directive('whenScrolled', function() {
return function(scope, elm, attr) {
diff --git a/assets/javascripts/tab.js b/assets/javascripts/tab.js
index f049a29..9afdb62 100644
--- a/assets/javascripts/tab.js
+++ b/assets/javascripts/tab.js
@@ -1,16 +1,16 @@
-$(function () {
+$(function() {
var closeModal = function() {
$('#chrome-ext-delicious-frame').remove();
};
- var loadModal = function (view) {
+ var loadModal = function(view) {
var html = [
'',
- '
',
- '
',
- '
',
+ '
',
+ '
',
+ '
',
'
'
].join('\n');
@@ -20,7 +20,7 @@ $(function () {
//Events
- $(document).keydown(function (e) {
+ $(document).keydown(function(e) {
if (e.altKey && e.shiftKey && e.keyCode === 68) {
// shift-alt-d
@@ -32,7 +32,7 @@ $(function () {
});
- $(document).on('click', '#chrome-ext-delicious-frame button.close_frame', function () {
+ $(document).on('click', '#chrome-ext-delicious-frame button.close_frame', function() {
closeModal();
});
@@ -43,4 +43,4 @@ $(function () {
}
});
-});
\ No newline at end of file
+});
diff --git a/manifest.json b/manifest.json
index aa496c9..0bf31db 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,6 +1,6 @@
{
- "background": {
+ "background": {
"scripts": [
"/assets/javascripts/background.js"
]
@@ -18,27 +18,25 @@
}
}
},
- "content_scripts": [
- {
+ "content_scripts": [{
"matches": ["http://*/*", "https://*/*"],
"js": [
"/vendor/javascripts/jquery-2.0.0.min.js",
"/assets/javascripts/tab.js"
],
- "css": [ "/assets/stylesheets/tab.css" ]
- }
- ],
+ "css": ["/assets/stylesheets/tab.css"]
+ }],
"content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'",
"description": "Feature rich extension with the ability to add, edit, filter, and remove bookmarks from your Delicious account.",
"incognito": "spanning",
"icons": {
"16": "/assets/images/icon-16.png",
- "128":"/assets/images/icon-128.png"
+ "128": "/assets/images/icon-128.png"
},
"manifest_version": 2,
"name": "@Delicious",
"omnibox": {
- "keyword" : "@del"
+ "keyword": "@del"
},
"permissions": [
"contextMenus",
@@ -47,7 +45,7 @@
"https://api.del.icio.us/",
"tabs"
],
- "version": "2.9.6",
- "web_accessible_resources": [ "/popup.html" ]
+ "version": "2.9.7",
+ "web_accessible_resources": ["/popup.html"]
}