Skip to content

Commit

Permalink
Ran closure linter on almost the entire source
Browse files Browse the repository at this point in the history
  • Loading branch information
ankit committed Jun 8, 2011
1 parent 0faa9c4 commit 2e20302
Show file tree
Hide file tree
Showing 19 changed files with 523 additions and 512 deletions.
14 changes: 7 additions & 7 deletions stylebot/js/apply-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ var stylebotTempRules;
var stylebotGlobalRules;

// send request to background.html to get stylebot global rules
chrome.extension.sendRequest({ name: "getGlobalRules" }, function(response) {
chrome.extension.sendRequest({ name: 'getGlobalRules' }, function(response) {
if (response) {
stylebotGlobalRules = response;
var css = CSSUtils.crunchCSS(response, true);
if (css != "")
if (css != '')
{
CSSUtils.injectCSS(css, "stylebot-global-css");
CSSUtils.injectCSS(css, 'stylebot-global-css');
}
}
});

// send request to background.html to get stylebot rules for page
chrome.extension.sendRequest({ name: "getRulesForPage", url: window.location.href }, function(response) {
chrome.extension.sendRequest({ name: 'getRulesForPage', url: window.location.href }, function(response) {
stylebotTempUrl = response.url;
stylebotTempRules = response.rules;
var css = CSSUtils.crunchCSS(response.rules, true);
if (css != "")
if (css != '')
{
CSSUtils.injectCSS(css, "stylebot-css");
CSSUtils.injectCSS(css, 'stylebot-css');
}
});
});
10 changes: 5 additions & 5 deletions stylebot/js/bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ function createBookmark(name, url, parentId, callback) {
parentId: id,
title: name
};

if (url)
properties.url = url;

chrome.bookmarks.create(properties, callback);
}

Expand All @@ -34,9 +34,9 @@ function loadBookmark(id, title, callback) {
chrome.bookmarks.get(id, callback);
return;
}

if (title) {
chrome.bookmarks.search("stylebot", function(bookmarks) {
chrome.bookmarks.search('stylebot', function(bookmarks) {
callback(bookmarks);
});
}
Expand All @@ -58,4 +58,4 @@ function getRootBookmark(callback) {
chrome.bookmarks.getTree(function(bookmarks) {
callback(bookmarks[0].children[1]);
});
}
}
46 changes: 23 additions & 23 deletions stylebot/js/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,75 +7,75 @@
stylebot.chrome = {
setIcon: function(value) {
if (value)
chrome.extension.sendRequest({ name: "enablePageAction" }, function(){});
chrome.extension.sendRequest({ name: 'enablePageAction' }, function() {});
else
chrome.extension.sendRequest({ name: "disablePageAction" }, function(){});
chrome.extension.sendRequest({ name: 'disablePageAction' }, function() {});
},

// send request to background.html to copy text
copyToClipboard: function(text) {
chrome.extension.sendRequest({ name: "copyToClipboard", text: text }, function(){});
chrome.extension.sendRequest({ name: 'copyToClipboard', text: text }, function() {});
},

// save all rules for a page
save: function(url, rules, data) {
chrome.extension.sendRequest({ name: "save", rules: rules, url: url , data: data }, function(){});
chrome.extension.sendRequest({ name: 'save', rules: rules, url: url, data: data }, function() {});
},

doesStyleExist: function(url, callback) {
chrome.extension.sendRequest({ name: "doesStyleExist", url:url }, callback);
chrome.extension.sendRequest({ name: 'doesStyleExist', url: url }, callback);
},

install: function(url, rules, id) {
chrome.extension.sendRequest({ name: "install", rules: rules, url: url, id: id }, function(){});
chrome.extension.sendRequest({ name: 'install', rules: rules, url: url, id: id }, function() {});
},

// transfer all rules for src url to dest url
transfer: function(src, dest) {
chrome.extension.sendRequest({name: "transfer", source: src, destination: dest }, function(){});
chrome.extension.sendRequest({name: 'transfer', source: src, destination: dest }, function() {});
},

// send request to fetch options from datastore
fetchOptions: function() {
chrome.extension.sendRequest({ name: "fetchOptions" }, function(response) {
chrome.extension.sendRequest({ name: 'fetchOptions' }, function(response) {
initialize(response);
});
},

saveAccordionState: function(enabledAccordions) {
chrome.extension.sendRequest({ name: "saveAccordionState", enabledAccordions: enabledAccordions }, function(){});
chrome.extension.sendRequest({ name: 'saveAccordionState', enabledAccordions: enabledAccordions }, function() {});
},

savePreference: function(name, value) {
chrome.extension.sendRequest({ name: "savePreference", preference: { name: name, value: value } }, function(){});
chrome.extension.sendRequest({ name: 'savePreference', preference: { name: name, value: value } }, function() {});
},

getPreference: function(name, callback) {
chrome.extension.sendRequest({ name: "getPreference", preferenceName: name }, function(response) {
chrome.extension.sendRequest({ name: 'getPreference', preferenceName: name }, function(response) {
callback(response.value);
});
},

pushStyles: function() {
chrome.extension.sendRequest({ name: "pushStyles" }, function(){});
chrome.extension.sendRequest({ name: 'pushStyles' }, function() {});
},

openOptionsPage: function() {
window.open(chrome.extension.getURL("options.html"));
window.open(chrome.extension.getURL('options.html'));
}
}
};

// Listen to requests from background.html
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {

if (request.name === "status") {
if (request.name === 'status') {
if (window != window.top)
return;
sendResponse({ status: stylebot.status });
}

else if (request.name === "toggle")
else if (request.name === 'toggle')
{
if (window != window.top)
return;
Expand All @@ -84,42 +84,42 @@ chrome.extension.onRequest.addListener(
sendResponse({ status: stylebot.status });
}

else if (request.name === "setOptions")
else if (request.name === 'setOptions')
{
stylebot.setOptions(request.options);
sendResponse({});
}

else if (request.name === "openWidget")
else if (request.name === 'openWidget')
{
stylebot.contextmenu.openWidget();
sendResponse({});
}

else if (request.name === "searchSocial") {
else if (request.name === 'searchSocial') {
if (!window.top)
return;
stylebot.contextmenu.searchSocial();
}

else if (request.name === "shareStyleOnSocial") {
else if (request.name === 'shareStyleOnSocial') {
if (!window.top)
return;
stylebot.contextmenu.shareStyleOnSocial();
}

else if (request.name === "toggleStyle") {
else if (request.name === 'toggleStyle') {
if (!window.top)
return;
stylebot.style.toggle();

sendResponse({ status: stylebot.style.status });
}

else if (request.name === "styleStatus") {
else if (request.name === 'styleStatus') {
if (!window.top)
return;
sendResponse({ status: stylebot.style.status });
}
}
);
);
18 changes: 9 additions & 9 deletions stylebot/js/contextmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ stylebot.contextmenu = {
cache: {
el: null
},

initialize: function() {
this.attachListeners();
},

attachListeners: function() {
$(document.body).bind('contextmenu', function(e) {
stylebot.contextmenu.cache.el = e.target;
});
},

openWidget: function() {
if (stylebot.contextmenu.cache.el && stylebot.contextmenu.cache.el.nodeType == 1)
{
Expand All @@ -24,23 +24,23 @@ stylebot.contextmenu = {
},

searchSocial: function() {
window.open("http://stylebot.me/search?q=" + document.domain);
window.open('http://stylebot.me/search?q=' + document.domain);
},

shareStyleOnSocial: function() {
// check if the current page has any styles
if (stylebot.style.rules) {

var css = CSSUtils.crunchFormattedCSS(stylebot.style.rules, false);
var url = "http://stylebot.me/post";
var url = 'http://stylebot.me/post';

// create a form and submit data
var temp_form = $('<form>', {
'method': 'post',
'action': url,
'target': '_self'
});

// site
$('<input>', {
type: 'hidden',
Expand All @@ -62,4 +62,4 @@ stylebot.contextmenu = {
temp_form.remove();
}
}
}
};
10 changes: 5 additions & 5 deletions stylebot/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@ function attachListeners() {
}
}
// Handle Esc key to escape editing mode
else if ( e.keyCode == 27 && stylebot.shouldClose(e.target) )
else if (e.keyCode == 27 && stylebot.shouldClose(e.target))
{
e.target.blur();
stylebot.close();
}

return true;
}, true);
}

function isInputField(el) {
var tagName = el.tagName.toLowerCase();
var inputTypes = ['input', 'textarea', 'div', 'object'];

if ($.inArray(tagName, inputTypes) != -1 ||
el.id === "stylebot"
el.id === 'stylebot'
)
return true;
else
return false;
}
}
Loading

4 comments on commit 2e20302

@ankit
Copy link
Owner Author

@ankit ankit commented on 2e20302 Jun 8, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we should run the linter fixer on the modified files as a pre-commit hook.

@rduenasf
Copy link
Contributor

@rduenasf rduenasf commented on 2e20302 Jun 8, 2011 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ankit
Copy link
Owner Author

@ankit ankit commented on 2e20302 Jun 8, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I think it only gives a warning for the 80 char line limit, it doesn't try to fix it.

@rduenasf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool then!

Please sign in to comment.