Skip to content

Commit

Permalink
Update JS to make jslint happy, my apologies
Browse files Browse the repository at this point in the history
  • Loading branch information
mitechie committed Sep 6, 2012
1 parent b2fc79e commit 728733d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 31 deletions.
25 changes: 12 additions & 13 deletions bookie/static/js/bookie/api.js
Expand Up @@ -6,7 +6,6 @@
* @module api * @module api
* *
*/ */

YUI.add('bookie-api', function (Y) { YUI.add('bookie-api', function (Y) {


ns = Y.namespace('bookie'); ns = Y.namespace('bookie');
Expand Down Expand Up @@ -48,8 +47,6 @@ YUI.add('bookie-api', function (Y) {


if (args.callbacks.complete !== undefined) { if (args.callbacks.complete !== undefined) {
args.callbacks.complete(data, response, args); args.callbacks.complete(data, response, args);
} else {

} }
}, },
default_success = function (id, response, args) { default_success = function (id, response, args) {
Expand All @@ -59,8 +56,6 @@ YUI.add('bookie-api', function (Y) {
// data we need to decode and pass to the callback // data we need to decode and pass to the callback
if (args.callbacks.success !== undefined) { if (args.callbacks.success !== undefined) {
args.callbacks.success(data, response, args); args.callbacks.success(data, response, args);
} else {

} }
}, },
default_failure = function (id, response, args) { default_failure = function (id, response, args) {
Expand All @@ -75,8 +70,6 @@ YUI.add('bookie-api', function (Y) {
response, response,
args args
); );
} else {

} }
}; };


Expand Down Expand Up @@ -459,20 +452,22 @@ YUI.add('bookie-api', function (Y) {
url_element: { url_element: {
value: '/{resource}/bmarks', value: '/{resource}/bmarks',
getter: function () { getter: function () {
var ret;
// if there is no resource, use the username as the // if there is no resource, use the username as the
// resource // resource
if (!this.get('resource')) { if (!this.get('resource')) {
this.set('resource', this.get('username')); this.set('resource', this.get('username'));
} }


if (this.get('tags')) { if (this.get('tags')) {
return [ ret = [
'/{resource}/bmarks', '/{resource}/bmarks',
this.get('tags').join('/') this.get('tags').join('/')
].join('/'); ].join('/');
} else { } else {
return '/{resource}/bmarks'; ret = '/{resource}/bmarks';
} }
return ret;
} }
}, },


Expand Down Expand Up @@ -966,14 +961,16 @@ YUI.add('bookie-api', function (Y) {
url_element: { url_element: {
value: '/bmarks/search', value: '/bmarks/search',
getter: function () { getter: function () {
var ret;
if (this.get('phrase').length) { if (this.get('phrase').length) {
return [ ret = [
'/bmarks/search', '/bmarks/search',
this.get('phrase').join('/') this.get('phrase').join('/')
].join('/'); ].join('/');
} else { } else {
return '/bmarks/search'; ret = '/bmarks/search';
} }
return ret;
} }
} }
} }
Expand Down Expand Up @@ -1032,14 +1029,16 @@ YUI.add('bookie-api', function (Y) {
url_element: { url_element: {
value: '/{username}/bmarks/search', value: '/{username}/bmarks/search',
getter: function () { getter: function () {
var ret;
if (this.get('phrase').length) { if (this.get('phrase').length) {
return [ ret = [
'/{username}/bmarks/search', '/{username}/bmarks/search',
this.get('phrase').join('/') this.get('phrase').join('/')
].join('/'); ].join('/');
} else { } else {
return '/{username}/bmarks/search'; ret = '/{username}/bmarks/search';
} }
return ret;
} }
} }
} }
Expand Down
2 changes: 1 addition & 1 deletion bookie/static/js/bookie/history.js
Expand Up @@ -88,7 +88,7 @@ YUI.add('bookie-history-module', function (Y) {
}); });


var updated_url = rtrim(this.get('route'), '/') + '/' + terms + '?' + qs; var updated_url = rtrim(this.get('route'), '/') + '/' + terms + '?' + qs;
return '/' + ltrim(updated_url, '/') return '/' + ltrim(updated_url, '/');
}, },


/** /**
Expand Down
30 changes: 18 additions & 12 deletions bookie/static/js/bookie/model.js
Expand Up @@ -252,9 +252,9 @@ YUI.add('bookie-model', function (Y) {
'domain': { 'domain': {
getter: function () { getter: function () {
var url = this.get('url'); var url = this.get('url');
var domain = url.replace('http://','').replace('https://','').split(/[/?#]/)[0] var domain = url.replace('http://','').replace('https://','').split(/[/?#]/)[0];
var spl = domain.split('.') var spl = domain.split('.');
return [spl[spl.length-2], spl[spl.length-1]].join('.') return [spl[spl.length-2], spl[spl.length-1]].join('.');
} }
}, },


Expand Down Expand Up @@ -404,12 +404,14 @@ YUI.add('bookie-model', function (Y) {
'dateinfo': { 'dateinfo': {
// we want to return a formatted version of stored // we want to return a formatted version of stored
getter: function (val) { getter: function (val) {
var stored = this.get('stored'); var ret,
stored = this.get('stored');
if (stored) { if (stored) {
return (stored.getMonth() + 1) + "/" + stored.getDate(); ret = (stored.getMonth() + 1) + "/" + stored.getDate();
} else { } else {
return stored; ret = stored;
} }
return ret;
} }
}, },


Expand All @@ -424,18 +426,20 @@ YUI.add('bookie-model', function (Y) {
'prettystored': { 'prettystored': {
// we want to return a formatted version of stored // we want to return a formatted version of stored
getter: function (val) { getter: function (val) {
var stored = this.get('stored'); var ret,
stored = this.get('stored');
if (stored) { if (stored) {
return _("{month}/{date}/{year} {hours}:{minutes}", { ret = _("{month}/{date}/{year} {hours}:{minutes}", {
'month': stored.getMonth() + 1, 'month': stored.getMonth() + 1,
'date': stored.getDate(), 'date': stored.getDate(),
'year': stored.getFullYear(), 'year': stored.getFullYear(),
'hours': stored.getHours(), 'hours': stored.getHours(),
'minutes': stored.getMinutes() 'minutes': stored.getMinutes()
}); });
} else { } else {
return stored; ret = stored;
} }
return ret;
} }
} }
} }
Expand Down Expand Up @@ -610,12 +614,14 @@ YUI.add('bookie-model', function (Y) {
* *
*/ */
_get_data: function (key, def) { _get_data: function (key, def) {
var found = localStorage.getItem(key); var ret,
found = localStorage.getItem(key);
if (found === null) { if (found === null) {
return def; ret = def;
} else { } else {
return found; ret = found;
} }
return ret;
}, },


get_apicfg: function () { get_apicfg: function () {
Expand Down
11 changes: 6 additions & 5 deletions extensions/chrome_ext/chrome.js
Expand Up @@ -26,7 +26,7 @@ YUI().add('bookie-chrome', function (Y) {
* *
*/ */
_bind_site_link: function () { _bind_site_link: function () {
var url = this.api_cfg.url var url = this.api_cfg.url;
url = url.replace(/api\/v1\/?/, ''); url = url.replace(/api\/v1\/?/, '');
url = url + this.api_cfg.username; url = url + this.api_cfg.username;
Y.one('#bookie_site').set('href', url); Y.one('#bookie_site').set('href', url);
Expand Down Expand Up @@ -75,7 +75,6 @@ YUI().add('bookie-chrome', function (Y) {
e.preventDefault(); e.preventDefault();
this.indicator.show(); this.indicator.show();
var model = this.get('model'); var model = this.get('model');
debugger;


// we need to make sure the tag control is up to date so that we // we need to make sure the tag control is up to date so that we
// don't miss any tags. If the user starts typing a tag, and then // don't miss any tags. If the user starts typing a tag, and then
Expand Down Expand Up @@ -195,6 +194,7 @@ YUI().add('bookie-chrome', function (Y) {


_validate_settings: function () { _validate_settings: function () {
var errors = [], var errors = [],
ret,
settings = this.get('settings'), settings = this.get('settings'),
required = [ required = [
'api_url', 'api_url',
Expand All @@ -210,11 +210,12 @@ YUI().add('bookie-chrome', function (Y) {


// display errors if we have them // display errors if we have them
if (errors.length) { if (errors.length) {
return false; ret = false;
} else { } else {
return true; ret = true;
} }


return ret;
}, },


events: { events: {
Expand Down Expand Up @@ -539,7 +540,7 @@ YUI().add('bookie-chrome', function (Y) {
if (request.url) { if (request.url) {
chrome.tabs.getSelected(null, function(tab_obj) { chrome.tabs.getSelected(null, function(tab_obj) {
var encoded_url = window.btoa(tab_obj.url), var encoded_url = window.btoa(tab_obj.url),
encoded_title = window.btoa(tab_obj.title) encoded_title = window.btoa(tab_obj.title),
hash = [encoded_url, encoded_title].join('|'); hash = [encoded_url, encoded_title].join('|');


chrome.tabs.create({url: "popup.html#" + hash}); chrome.tabs.create({url: "popup.html#" + hash});
Expand Down

0 comments on commit 728733d

Please sign in to comment.