summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-03-31 17:58:21 +0200
committerJules Laplace <julescarbon@gmail.com>2018-03-31 17:58:21 +0200
commit5605ce481f6c5f67bce69ff31ffe0117485efc39 (patch)
tree03b70be80c4f7f504f9bd9fbab1236d282f96391 /js
parentd9f1628cbc3e96c584279b8d58e2e2c2a0d75b56 (diff)
upload ascii when saving
Diffstat (limited to 'js')
-rw-r--r--js/app.js10
-rw-r--r--js/clipboard.js2
-rw-r--r--js/ui/controls.js14
-rw-r--r--js/upload.js3
4 files changed, 19 insertions, 10 deletions
diff --git a/js/app.js b/js/app.js
index 0d91c84..5898f5c 100644
--- a/js/app.js
+++ b/js/app.js
@@ -82,7 +82,15 @@ function bind () {
})
window.onbeforeunload = function() {
- if (changed) return "You have edited this drawing."
+ if (changed && !in_iframe()) return "You have edited this drawing."
+ }
+
+ function in_iframe () {
+ try {
+ return window.self !== window.top;
+ } catch (e) {
+ return true;
+ }
}
}
diff --git a/js/clipboard.js b/js/clipboard.js
index ecb200b..107f634 100644
--- a/js/clipboard.js
+++ b/js/clipboard.js
@@ -236,7 +236,7 @@ var clipboard = (function () {
var blob = PNG.canvas_to_blob_with_colorcode(canvas_out, canvas.mirc())
var filename = clipboard.filename()
var tag = 'ascii'
- upload(blob, filename, tag)
+ upload(blob, filename, tag, canvas_out)
}
clipboard.export_canvas(upload_fn)
}
diff --git a/js/ui/controls.js b/js/ui/controls.js
index 8ffdc64..8da4994 100644
--- a/js/ui/controls.js
+++ b/js/ui/controls.js
@@ -262,13 +262,13 @@ var controls = (function(){
// this.update(canvas.rotated)
// }
- controls.pixels = new BlurredCheckbox (pixels_checkbox)
- controls.pixels.memorable = true
- controls.pixels.use = function(state){
- canvas.pixels = typeof state == "boolean" ? state : ! canvas.pixels
- document.body.classList.toggle("pixels", canvas.pixels)
- this.update(canvas.pixels)
- }
+ // controls.pixels = new BlurredCheckbox (pixels_checkbox)
+ // controls.pixels.memorable = true
+ // controls.pixels.use = function(state){
+ // canvas.pixels = typeof state == "boolean" ? state : ! canvas.pixels
+ // document.body.classList.toggle("pixels", canvas.pixels)
+ // this.update(canvas.pixels)
+ // }
controls.mirror_x = new BlurredCheckbox (mirror_x_checkbox)
controls.mirror_x.use = function(state){
diff --git a/js/upload.js b/js/upload.js
index c1ef7f7..0fa567c 100644
--- a/js/upload.js
+++ b/js/upload.js
@@ -3,7 +3,7 @@ var upload = (function(){
var button = document.getElementById("upload_button")
var uploading = false
- function upload(blob, filename, tag){
+ function upload(blob, filename, tag, ascii){
if (uploading) return
filename = filename || get_filename()
tag = tag || "shader"
@@ -15,6 +15,7 @@ var upload = (function(){
uploadImage({
blob: blob,
+ ascii: ascii,
filename: filename,
username: user.username,
tag: tag,