summaryrefslogtreecommitdiff
path: root/src/www
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2011-11-01 17:45:57 +0000
committerhallgren <hallgren@chalmers.se>2011-11-01 17:45:57 +0000
commit42af63414fae6cec2ea6d648464f9475501b2b28 (patch)
tree555b36e3237092d19eab5cb7b4bdfb0c44427164 /src/www
parent9ba8db6e0a4ddacb77d0754ff12a36244c041deb (diff)
gfse: grammar sharing: bug fixes and win32 support
win32 support is untested
Diffstat (limited to 'src/www')
-rw-r--r--src/www/gfse/cloud2.js18
-rw-r--r--src/www/gfse/editor.js1
2 files changed, 13 insertions, 6 deletions
diff --git a/src/www/gfse/cloud2.js b/src/www/gfse/cloud2.js
index 71de22387..60e57f9ba 100644
--- a/src/www/gfse/cloud2.js
+++ b/src/www/gfse/cloud2.js
@@ -1,11 +1,19 @@
function with_dir(cont) {
+ function have_dir(dir) {
+ var unique_id=local.get("unique_id")
+ if(!unique_id) {
+ unique_id=dir.substr(10) // skip "/tmp/gfse."
+ local.put("unique_id",unique_id)
+ }
+ cont(dir,unique_id)
+ }
var dir=local.get("dir","");
- if(/^\/tmp\//.test(dir)) cont(dir);
+ if(/^\/tmp\//.test(dir)) have_dir(dir);
else ajax_http_get("/new",
function(dir) {
local.put("dir",dir);
- cont(dir);
+ have_dir(dir);
});
}
@@ -42,7 +50,7 @@ function upload(g) {
// Upload the grammar to store it in the cloud
function upload_json(cont) {
- function upload2(dir) {
+ function upload2(dir,unique_id) {
function upload3(resptext,status) {
local.put("json_uploaded",Date.now());
//debug("Upload complete")
@@ -64,7 +72,6 @@ function upload_json(cont) {
}
}
- var prefix=dir.substr(10)+"-" // skip "/tmp/gfse."
//debug("New form data");
//var form=new FormData(); // !!! Doesn't work on Android 2.2!
var form={dir:dir};
@@ -73,14 +80,13 @@ function upload_json(cont) {
var g=local.get(i,null);
if(g) {
if(!g.unique_name) {
- g.unique_name=prefix+i;
+ g.unique_name=unique_id+"-"+i;
save_grammar(g)
}
//form.append(g.unique_name+".json",JSON.stringify(g));
form[encodeURIComponent(g.unique_name+".json")]=JSON.stringify(g)
}
}
- //debug("Upload to "+prefix);
ajax_http_post("/cloud","command=upload"+encodeArgs(form),upload3,cont)
}
diff --git a/src/www/gfse/editor.js b/src/www/gfse/editor.js
index 859f33a04..95c72d972 100644
--- a/src/www/gfse/editor.js
+++ b/src/www/gfse/editor.js
@@ -1075,6 +1075,7 @@ function download_from_cloud() {
}
function download3() {
//debug("Uploading local grammars to cloud");
+ local.put("dir",newdir);
upload_json(download4)
}
function download4() {