mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-01-22 15:08:12 -05:00
Simplify the if
structure
remark: Customize a function to avoid "Line exceeds maximum allowed length"
This commit is contained in:
parent
815e162640
commit
93d1d89fb2
@ -25,18 +25,15 @@ class ChromeTabs
|
|||||||
tabs.forEach (tab) =>
|
tabs.forEach (tab) =>
|
||||||
@_dirtyTabs[tab.id] = tab.id
|
@_dirtyTabs[tab.id] = tab.id
|
||||||
@onUpdated tab.id, {}, tab if tab.active
|
@onUpdated tab.id, {}, tab if tab.active
|
||||||
if chrome.action.setPopup?
|
title = if @_canSetPopup() then action.title else action.shortTitle
|
||||||
chrome.action.setTitle({title: action.title})
|
chrome.action.setTitle({title: title})
|
||||||
else
|
|
||||||
chrome.action.setTitle({title: action.shortTitle})
|
|
||||||
@setIcon(action.icon)
|
@setIcon(action.icon)
|
||||||
|
|
||||||
onUpdated: (tabId, changeInfo, tab) ->
|
onUpdated: (tabId, changeInfo, tab) ->
|
||||||
if @_dirtyTabs.hasOwnProperty(tab.id)
|
if @_dirtyTabs.hasOwnProperty(tab.id)
|
||||||
delete @_dirtyTabs[tab.id]
|
delete @_dirtyTabs[tab.id]
|
||||||
else if not changeInfo.url?
|
else if not changeInfo.url? and changeInfo.status == "complete"
|
||||||
if changeInfo.status? and changeInfo.status != 'loading'
|
return
|
||||||
return
|
|
||||||
@processTab(tab, changeInfo)
|
@processTab(tab, changeInfo)
|
||||||
|
|
||||||
processTab: (tab, changeInfo) ->
|
processTab: (tab, changeInfo) ->
|
||||||
@ -58,10 +55,8 @@ class ChromeTabs
|
|||||||
@clearIcon tab.id
|
@clearIcon tab.id
|
||||||
return
|
return
|
||||||
@setIcon(action.icon, tab.id)
|
@setIcon(action.icon, tab.id)
|
||||||
if chrome.action.setPopup?
|
title = if @_canSetPopup() then action.title else action.shortTitle
|
||||||
chrome.action.setTitle({title: action.title, tabId: tab.id})
|
return chrome.action.setTitle({title: title, tabId: tab.id})
|
||||||
else
|
|
||||||
chrome.action.setTitle({title: action.shortTitle, tabId: tab.id})
|
|
||||||
).catch((e) ->
|
).catch((e) ->
|
||||||
console.log('error:', e)
|
console.log('error:', e)
|
||||||
)
|
)
|
||||||
@ -77,17 +72,15 @@ class ChromeTabs
|
|||||||
|
|
||||||
setIcon: (icon, tabId) ->
|
setIcon: (icon, tabId) ->
|
||||||
return unless icon?
|
return unless icon?
|
||||||
if tabId?
|
params = {
|
||||||
params = {
|
imageData: icon
|
||||||
imageData: icon
|
}
|
||||||
tabId: tabId
|
params.tabId = tabId if tabId?
|
||||||
}
|
|
||||||
else
|
|
||||||
params = {
|
|
||||||
imageData: icon
|
|
||||||
}
|
|
||||||
@_chromeSetIcon(params)
|
@_chromeSetIcon(params)
|
||||||
|
|
||||||
|
_canSetPopup: ->
|
||||||
|
chrome.action.setPopup?
|
||||||
|
|
||||||
_chromeSetIcon: (params) ->
|
_chromeSetIcon: (params) ->
|
||||||
try
|
try
|
||||||
chrome.action.setIcon?(params, @ignoreError)
|
chrome.action.setIcon?(params, @ignoreError)
|
||||||
|
Loading…
Reference in New Issue
Block a user