-
Notifications
You must be signed in to change notification settings - Fork 284
Download json file of saved positions #1237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 28 commits
87f5076
f6225c3
4976617
c71fc06
8db3a8e
1dca9e3
7cbcb80
24df784
47f1aa2
07c7e94
773c2fe
13c6402
67b2862
8407d0f
4a1339a
a03c45c
e409e69
415f0da
44d3a4b
f9e8212
eb09b9e
57613e6
5f3e111
a798be5
8e680cb
e3b8b1f
385ea0d
b9147e1
c3946d8
3d8a625
55c57e1
3c21e05
b898437
d1d3478
fd381b2
54f35af
3d6ea86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -218,11 +218,35 @@ L.DistortableCollection = L.FeatureGroup.extend({ | |||||
|
||||||
json.images = json.images.reverse(); | ||||||
json.avg_cm_per_pixel = this._getAvgCmPerPixel(json.images); | ||||||
|
||||||
var jsonImages = json.images; | ||||||
savetoLocalStorage(jsonImages); | ||||||
return json; | ||||||
}, | ||||||
}); | ||||||
|
||||||
L.distortableCollection = function(id, options) { | ||||||
return new L.DistortableCollection(id, options); | ||||||
}; | ||||||
|
||||||
function savetoLocalStorage(jsonImages) { | ||||||
var result = jsonImages.map(img => ({value: img.nodes})); | ||||||
var getImages = localStorage.setItem('locations', JSON.stringify(result)); | ||||||
downloadFromLocalStorage(getImages); | ||||||
} | ||||||
|
||||||
function downloadFromLocalStorage(getImages) { | ||||||
var obj = localStorage.getItem('locations'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per our conversation, after
Suggested change
|
||||||
var data = 'text/json;charset=utf-8,' + encodeURIComponent(JSON.stringify(obj, prettyJson)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From here down is what you want. Let's just connect it to a button! And we can probably skip the prettyJson below - could do it later with a library! |
||||||
var a = document.createElement('a'); | ||||||
a.href = 'data:' + data; | ||||||
a.download = 'mapknitter.json'; | ||||||
// a.innerHTML = 'download JSON'; | ||||||
// console.log(a); | ||||||
a.click(); | ||||||
} | ||||||
|
||||||
function prettyJson(key, value) { | ||||||
// return value.replace(/[^\w\s]/gi, '\n'); | ||||||
// (/\n/g, "\r\n") | ||||||
return value.replace(/\n/g, '\\\\n').replace(/\r/g, '\\\\r').replace(/\t/g, '\\\\t'); | ||||||
} |
Uh oh!
There was an error while loading. Please reload this page.