diff --git a/src/editor/simple/editor.js b/src/editor/simple/editor.js index 9954c5f7e..90d85274b 100644 --- a/src/editor/simple/editor.js +++ b/src/editor/simple/editor.js @@ -34,7 +34,7 @@ function initial_view() { function draw_grammar_list() { local.put("current",0); editor.innerHTML=""; - var uploaded=local.get("json_uploaded"); + var uploaded=local.get("dir") && local.get("json_uploaded"); var cloud_upload= a(jsurl("upload_json()"), [node("img",{"class":"cloud", @@ -84,13 +84,22 @@ function new_grammar() { edit_grammar(g); } +function remove_local_grammar(i) { + local.remove(i); + while(local.count>0 && !local.get(local.count-1)) + local.count--; +} + function delete_grammar(i) { var g=local.get(i); var ok=confirm("Do you really want to delete the grammar "+g.basename+"?") if(ok) { - local.remove(i); - while(local.count>0 && !local.get(local.count-1)) - local.count--; + remove_local_grammar(i) + var dir=local.get("dir") + if(dir && g.unique_name) { + var path=dir+"/"+g.unique_name+".json" + ajax_http_get("upload.cgi?rm="+encodeURIComponent(path),debug); + } initial_view(); } } @@ -158,7 +167,7 @@ function draw_plainbutton(g,files) { } function upload_button(g) { - var b=button("Upload",function(){upload(g);}); + var b=button("Compile",function(){upload(g);}); b.title="Upload the grammar to the server to check it in GF and test it in the minibar"; return b; } @@ -889,6 +898,20 @@ function find_langcode(concs,langcode) { return null; } +function cleanup_deleted(files) { + var keep={} + for(var i in files) keep[files[i]]=true; + //debug("cleanup_deleted "+JSON.stringify(files)) + //debug("keep "+JSON.stringify(keep)) + for(var i=0;i