diff --git a/assets/javascripts/popup.js b/assets/javascripts/popup.js index c4d2db5..1e40297 100644 --- a/assets/javascripts/popup.js +++ b/assets/javascripts/popup.js @@ -217,28 +217,8 @@ return defer.promise; }; - Delicious.fetchLinks = (function() { - return function fetchLinks() { - var defer = $q.defer(), - hash = localStorage.getItem('chrome-ext-delicious'), - options = { - method: 'GET', - url: 'https://api.del.icio.us/v1/posts/all?results=10000', - headers: { - 'Authorization': 'Basic ' + hash - }, - transformResponse: _parseLinksResponse - }; - - $http(options).then(function(resp) { - localStorage.setItem('chrome-ext-delicious-links', JSON.stringify(resp.data)); - defer.resolve(resp.data); - }); - - return defer.promise; - }; - - function _parseLinksResponse(data) { + Delicious.parseLinks = (function() { + return function parseLinksResponse(data) { var json = xml.xmlToJSON(data); function _parseLink(rawLink) { @@ -254,7 +234,8 @@ link['domain'] = link['href'].replace(/^(.*\/\/[^\/?#]*).*$/, '$1'); link['private'] = (link.shared === 'no') ? true : false; - link.tags = link.tag.split(' '); + var split = (localStorage.getItem('chrome-ext-delicious-parse-single-space')) === 'true' ? / [ ]?/ : " "; + link.tags = link.tag.split(split); delete link.tag; return link; @@ -270,6 +251,28 @@ } }()); + Delicious.fetchLinks = (function() { + return function fetchLinks() { + var defer = $q.defer(), + hash = localStorage.getItem('chrome-ext-delicious'), + options = { + method: 'GET', + url: 'https://api.del.icio.us/v1/posts/all?results=10000', + headers: { + 'Authorization': 'Basic ' + hash + }, + transformResponse: Delicious.parseLinks + }; + + $http(options).then(function(resp) { + localStorage.setItem('chrome-ext-delicious-links', JSON.stringify(resp.data)); + defer.resolve(resp.data); + }); + + return defer.promise; + }; + }()); + Delicious.getDeliciousLinkDataByUrl = (function () { return function getDeliciousLinkDataByUrl(url) { var defer = $q.defer(), @@ -280,7 +283,7 @@ headers: { 'Authorization': 'Basic ' + hash }, - transformResponse: _parseLinksResponse + transformResponse: Delicious.parseLinks }; $http(options).then(function(resp) { @@ -289,37 +292,6 @@ return defer.promise; }; - - function _parseLinksResponse(data) { - var json = xml.xmlToJSON(data); - - function _parseLink(rawLink) { - var link = {}; - - // Remove '@' symbols from keys - for (var key in rawLink) { - var k = key.split('@')[1]; - link[k] = rawLink[key]; - } - - // domain root - link['domain'] = link['href'].replace(/^(.*\/\/[^\/?#]*).*$/, '$1'); - link['private'] = (link.shared === 'no') ? true : false; - - link.tags = link.tag.split(' '); - delete link.tag; - - return link; - } - - if ( ! json.posts) { - return []; - } else if (angular.isArray(json.posts.post)) { - return json.posts.post.map(_parseLink); - } else { - return [_parseLink(json.posts.post)]; - } - } }()); Delicious.getUpdate = (function() { @@ -834,6 +806,15 @@ $scope.$watch('filterTime', function(value) { localStorage.setItem('chrome-ext-delicious-filter-time', value); }); + + // api options + $scope.parseSingleSpace = (localStorage.getItem('chrome-ext-delicious-parse-single-space')) === 'true' ? true : false; + + $scope.$watch('parseSingleSpace', function(value) { + localStorage.setItem('chrome-ext-delicious-parse-single-space', value); + // need to reload links when this setting is changed + localStorage.removeItem('chrome-ext-delicious-links'); + }); }); diff --git a/updated.html b/updated.html index b36cf30..d4a49d1 100644 --- a/updated.html +++ b/updated.html @@ -11,7 +11,7 @@

@Delicious 2.9.5

-

Note: When using Delicious.com and this extension, multiple tags could return as one tag. This is due to how the API returns these tags. Sometimes they're returned as double-spaced delimited, sometimes tags are single space delimited. This extension uses double-spaced delimiting for the ability to have multi-word tags. So as long as you save tags through this extension it will work in both locations. -Zach

+

Note: When using Delicious.com and this extension, multiple tags could return as one tag. This is due to how the API returns these tags. Sometimes they're returned as double-spaced delimited, sometimes tags are single space delimited. This extension uses double-spaced delimiting for the ability to have multi-word tags. So as long as you save tags through this extension it will work in both locations. If none of your delicious tags contain any spaces, then you can check the "My tags have no spaces" option, and all tags will be delimited correctly. -Zach

Get New Feature updates on Twitter - @DeliciousExt

@@ -22,6 +22,9 @@

Note: When using Delicious.com and this extension, multiple t

New Features