Simplify export settings code.
Firefox does let us download links now.
This commit is contained in:
parent
8a3af6f69f
commit
0b39d6d3f5
@ -193,7 +193,7 @@ Header =
|
|||||||
$.off window, 'scroll', Header.hideBarOnScroll
|
$.off window, 'scroll', Header.hideBarOnScroll
|
||||||
$.rmClass Header.bar, 'scroll'
|
$.rmClass Header.bar, 'scroll'
|
||||||
$.rmClass Header.bar, 'autohide' unless Conf['Header auto-hide']
|
$.rmClass Header.bar, 'autohide' unless Conf['Header auto-hide']
|
||||||
toggleHideBarOnScroll: (e) ->
|
toggleHideBarOnScroll: ->
|
||||||
$.cb.checked.call @
|
$.cb.checked.call @
|
||||||
Header.setHideBarOnScroll @checked
|
Header.setHideBarOnScroll @checked
|
||||||
hideBarOnScroll: ->
|
hideBarOnScroll: ->
|
||||||
|
|||||||
@ -137,35 +137,22 @@ Settings =
|
|||||||
localStorage.removeItem "4chan-hide-t-#{boardID}"
|
localStorage.removeItem "4chan-hide-t-#{boardID}"
|
||||||
$.delete ['hiddenThreads', 'hiddenPosts']
|
$.delete ['hiddenThreads', 'hiddenPosts']
|
||||||
$.after $('input[name="Stubs"]', section).parentNode.parentNode, div
|
$.after $('input[name="Stubs"]', section).parentNode.parentNode, div
|
||||||
export: (now, data) ->
|
export: ->
|
||||||
unless typeof now is 'number'
|
# Make sure to export the most recent data.
|
||||||
now = Date.now()
|
$.get Conf, (Conf) ->
|
||||||
data =
|
# XXX don't export archives.
|
||||||
version: g.VERSION
|
delete Conf['archives']
|
||||||
date: now
|
Settings.downloadExport {version: g.VERSION, date: Date.now(), Conf}
|
||||||
for db in DataBoard.keys
|
downloadExport: (data) ->
|
||||||
Conf[db] = boards: {}
|
|
||||||
# Make sure to export the most recent data.
|
|
||||||
$.get Conf, (Conf) ->
|
|
||||||
# XXX don't export archives.
|
|
||||||
delete Conf['archives']
|
|
||||||
data.Conf = Conf
|
|
||||||
Settings.export now, data
|
|
||||||
return
|
|
||||||
a = $.el 'a',
|
a = $.el 'a',
|
||||||
className: 'warning'
|
download: "<%= meta.name %> v#{g.VERSION}-#{data.date}.json"
|
||||||
textContent: 'Save me!'
|
|
||||||
download: "<%= meta.name %> v#{g.VERSION}-#{now}.json"
|
|
||||||
href: "data:application/json;base64,#{btoa unescape encodeURIComponent JSON.stringify data, null, 2}"
|
href: "data:application/json;base64,#{btoa unescape encodeURIComponent JSON.stringify data, null, 2}"
|
||||||
target: '_blank'
|
|
||||||
<% if (type === 'userscript') { %>
|
<% if (type === 'userscript') { %>
|
||||||
# XXX Firefox won't let us download automatically.
|
|
||||||
p = $ '.imp-exp-result', Settings.dialog
|
p = $ '.imp-exp-result', Settings.dialog
|
||||||
$.rmAll p
|
$.rmAll p
|
||||||
$.add p, a
|
$.add p, a
|
||||||
<% } else { %>
|
|
||||||
a.click()
|
|
||||||
<% } %>
|
<% } %>
|
||||||
|
a.click()
|
||||||
import: ->
|
import: ->
|
||||||
@nextElementSibling.click()
|
@nextElementSibling.click()
|
||||||
onImport: ->
|
onImport: ->
|
||||||
@ -177,8 +164,7 @@ Settings =
|
|||||||
reader = new FileReader()
|
reader = new FileReader()
|
||||||
reader.onload = (e) ->
|
reader.onload = (e) ->
|
||||||
try
|
try
|
||||||
data = JSON.parse e.target.result
|
Settings.loadSettings JSON.parse e.target.result
|
||||||
Settings.loadSettings data
|
|
||||||
if confirm 'Import successful. Reload now?'
|
if confirm 'Import successful. Reload now?'
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
catch err
|
catch err
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user