Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved handleOptionChange() stuff to existing 'storage' event handler

  • Loading branch information...
commit 8237e918be26dea5dfecec9acaa2cefd3adbbd77 1 parent 15dca6a
@mhweaver authored
Showing with 12 additions and 21 deletions.
  1. +12 −19 src/background.js
  2. +0 −2  src/options.js
View
31 src/background.js
@@ -476,15 +476,6 @@ function onActionClicked(tab) {
})
}
-function handleOptionChange(id, value) {
- switch (id) {
- case 'allowHttps':
- console.log('Https option changed')
- setAllPageActionIcons()
- break
- }
-}
-
chrome.tabs.onSelectionChanged.addListener(tabStatus.updateTab.bind(tabStatus))
chrome.pageAction.onClicked.addListener(onActionClicked)
@@ -494,9 +485,6 @@ chrome.extension.onRequest.addListener(function(request, sender, callback) {
console.log('Thing clicked', request)
redditInfo.setURL(request.url, request.info)
break
- case 'optionChange':
- handleOptionChange(request.id, request.value)
- break
}
})
@@ -514,7 +502,7 @@ chrome.extension.onConnect.addListener(function(port) {
console.log('Auto-show disabled. Ignoring reddit page', info)
} else if (localStorage['autoShowSelf'] == 'false' && info.is_self) {
console.log('Ignoring self post', info)
- } else if (/^https:\/\/.*/.test(tab.url) && (localStorage['allowHttps'] == 'false')) {
+ } else if (localStorage['allowHttps'] == 'false' && /^https:\/\/.*/.test(tab.url)) {
console.log('Https page. Ignoring', info)
} else if (barStatus.hidden[info.name]) {
console.log('Bar was closed on this page. Ignoring.', info)
@@ -531,12 +519,17 @@ chrome.extension.onConnect.addListener(function(port) {
})
window.addEventListener('storage', function(e) {
- if (e.key == 'checkMail') {
- if (e.newValue == 'true') {
- mailChecker.start()
- } else {
- mailChecker.stop()
- }
+ switch (e.key) {
+ case 'checkMail':
+ if (e.newValue == 'true') {
+ mailChecker.start()
+ } else {
+ mailChecker.stop()
+ }
+ break
+ case 'allowHttps':
+ setAllPageActionIcons()
+ break
}
}, false)
View
2  src/options.js
@@ -19,7 +19,5 @@ $(document).ready(function() {
var value= $(this).is(':checked')
localStorage[this.id] = value
$('#contents').toggleClass(this.id, value)
- chrome.extension.sendRequest({action: 'optionChange', id: this.id,
- value: value})
})
})
Please sign in to comment.
Something went wrong with that request. Please try again.