Browse Source

add prefix to exported json

main
Mikey Oz 3 years ago
parent
commit
86d68fb7aa
  1. 2
      app/client.imba
  2. 4
      app/utils/download.imba
  3. 2
      package.json
  4. 2
      sw.imba

2
app/client.imba

@ -135,7 +135,7 @@ tag app
loading_import = no loading_import = no
def handle_click_export def handle_click_export
download_json_file JSON.stringify(state.links) download_json_file JSON.stringify(state.links), "fuzzyhome_"
def handle_paste e def handle_paste e
return if state.query.length > 0 return if state.query.length > 0

4
app/utils/download.imba

@ -4,10 +4,10 @@ def get_datetime_string
let time = obj[4].split(":").join("-") let time = obj[4].split(":").join("-")
"{date}_{time}" "{date}_{time}"
export default def download_json_file data export default def download_json_file data, prefix=""
let element = document.createElement 'a' let element = document.createElement 'a'
element.setAttribute 'href', 'data:text/plain;charset=utf-8,' + window.encodeURIComponent(data) element.setAttribute 'href', 'data:text/plain;charset=utf-8,' + window.encodeURIComponent(data)
element.setAttribute 'download', "{get_datetime_string!}.json" element.setAttribute 'download', "{prefix}{get_datetime_string!}.json"
element.style.display = 'none' element.style.display = 'none'
document.body.appendChild element document.body.appendChild element
element.click! element.click!

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "fuzzyhome", "name": "fuzzyhome",
"version": "0.0.19", "version": "0.0.20",
"scripts": { "scripts": {
"start": "imba run -SMH --baseurl . -w server.imba", "start": "imba run -SMH --baseurl . -w server.imba",
"build-app": "imba build -SMH --baseurl . server.imba", "build-app": "imba build -SMH --baseurl . server.imba",

2
sw.imba

@ -1,7 +1,7 @@
let p = console.log let p = console.log
const app_prefix = "fuzzyhome_cache" const app_prefix = "fuzzyhome_cache"
const version = "0.0.19" const version = "0.0.20"
const cache_name = "{app_prefix}-{version}" const cache_name = "{app_prefix}-{version}"

Loading…
Cancel
Save