Add a Reset Settings button.
This commit is contained in:
parent
0b39d6d3f5
commit
c7c8ea9ec5
@ -1,3 +1,5 @@
|
|||||||
|
- Added a `Reset Settings` button in the settings.
|
||||||
|
|
||||||
### 3.15.2 - *2014-01-22*
|
### 3.15.2 - *2014-01-22*
|
||||||
|
|
||||||
- More stability update.
|
- More stability update.
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<div class="imp-exp">
|
<div class="imp-exp">
|
||||||
<button class="export">Export Settings</button>
|
<button class="export">Export Settings</button>
|
||||||
<button class="import">Import Settings</button>
|
<button class="import">Import Settings</button>
|
||||||
<input type="file" style="visibility: hidden;">
|
<button class="reset">Reset Settings</button>
|
||||||
|
<input type="file" hidden>
|
||||||
</div>
|
</div>
|
||||||
<p class="imp-exp-result"></p>
|
<p class="imp-exp-result"></p>
|
||||||
|
|||||||
12
lib/$.coffee
12
lib/$.coffee
@ -300,6 +300,15 @@ $.set = do ->
|
|||||||
else
|
else
|
||||||
$.extend items.sync, key
|
$.extend items.sync, key
|
||||||
setAll()
|
setAll()
|
||||||
|
$.clear = (cb) ->
|
||||||
|
count = 2
|
||||||
|
done = ->
|
||||||
|
if chrome.runtime.lastError
|
||||||
|
c.error chrome.runtime.lastError.message
|
||||||
|
return
|
||||||
|
cb?() unless --count
|
||||||
|
chrome.storage.local.clear done
|
||||||
|
chrome.storage.sync.clear done
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
# http://wiki.greasespot.net/Main_Page
|
# http://wiki.greasespot.net/Main_Page
|
||||||
$.sync = do ->
|
$.sync = do ->
|
||||||
@ -341,4 +350,7 @@ $.set = do ->
|
|||||||
for key, val of keys
|
for key, val of keys
|
||||||
set key, val
|
set key, val
|
||||||
return
|
return
|
||||||
|
$.clear = (cb) ->
|
||||||
|
$.delete GM_listValues().map (key) -> key.replace g.NAMESPACE, ''
|
||||||
|
cb?()
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|||||||
@ -96,6 +96,7 @@ Settings =
|
|||||||
section.innerHTML = <%= importHTML('General/Settings-section-Main') %>
|
section.innerHTML = <%= importHTML('General/Settings-section-Main') %>
|
||||||
$.on $('.export', section), 'click', Settings.export
|
$.on $('.export', section), 'click', Settings.export
|
||||||
$.on $('.import', section), 'click', Settings.import
|
$.on $('.import', section), 'click', Settings.import
|
||||||
|
$.on $('.reset', section), 'click', Settings.reset
|
||||||
$.on $('input', section), 'change', Settings.onImport
|
$.on $('input', section), 'change', Settings.onImport
|
||||||
|
|
||||||
items = {}
|
items = {}
|
||||||
@ -154,7 +155,7 @@ Settings =
|
|||||||
<% } %>
|
<% } %>
|
||||||
a.click()
|
a.click()
|
||||||
import: ->
|
import: ->
|
||||||
@nextElementSibling.click()
|
$('input', @parentNode).click()
|
||||||
onImport: ->
|
onImport: ->
|
||||||
return unless file = @files[0]
|
return unless file = @files[0]
|
||||||
output = @parentNode.nextElementSibling
|
output = @parentNode.nextElementSibling
|
||||||
@ -174,6 +175,11 @@ Settings =
|
|||||||
loadSettings: (data) ->
|
loadSettings: (data) ->
|
||||||
version = data.version.split '.'
|
version = data.version.split '.'
|
||||||
if version[0] is '2'
|
if version[0] is '2'
|
||||||
|
convertSettings = (data, map) ->
|
||||||
|
for prevKey, newKey of map
|
||||||
|
data.Conf[newKey] = data.Conf[prevKey] if newKey
|
||||||
|
delete data.Conf[prevKey]
|
||||||
|
data
|
||||||
data = Settings.convertSettings data,
|
data = Settings.convertSettings data,
|
||||||
# General confs
|
# General confs
|
||||||
'Disable 4chan\'s extension': ''
|
'Disable 4chan\'s extension': ''
|
||||||
@ -243,11 +249,9 @@ Settings =
|
|||||||
data.Conf['watchedThreads'] = boards: ThreadWatcher.convert data.Conf['WatchedThreads']
|
data.Conf['watchedThreads'] = boards: ThreadWatcher.convert data.Conf['WatchedThreads']
|
||||||
delete data.Conf['WatchedThreads']
|
delete data.Conf['WatchedThreads']
|
||||||
$.set data.Conf
|
$.set data.Conf
|
||||||
convertSettings: (data, map) ->
|
reset: ->
|
||||||
for prevKey, newKey of map
|
if confirm 'Your current settings will be entirely wiped, are you sure?'
|
||||||
data.Conf[newKey] = data.Conf[prevKey] if newKey
|
$.clear -> window.location.reload() if confirm 'Reset successful. Reload now?'
|
||||||
delete data.Conf[prevKey]
|
|
||||||
data
|
|
||||||
|
|
||||||
filter: (section) ->
|
filter: (section) ->
|
||||||
section.innerHTML = <%= importHTML('General/Settings-section-Filter') %>
|
section.innerHTML = <%= importHTML('General/Settings-section-Filter') %>
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
// @grant GM_getValue
|
// @grant GM_getValue
|
||||||
// @grant GM_setValue
|
// @grant GM_setValue
|
||||||
// @grant GM_deleteValue
|
// @grant GM_deleteValue
|
||||||
|
// @grant GM_listValues
|
||||||
// @grant GM_openInTab
|
// @grant GM_openInTab
|
||||||
// @run-at document-start
|
// @run-at document-start
|
||||||
// @updateURL <%= meta.page %><%= meta.buildsPath %><%= name %>.meta.js
|
// @updateURL <%= meta.page %><%= meta.buildsPath %><%= name %>.meta.js
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user