callServer("open",processor,"file=" + escape(thefile));
}
-function showLibrary()
+function showLibrary(title,callback)
{
var req = null;
// pause();
if(stat == 200)
{
debug(req.responseText);
- showDialog("<H2>Library</H2>",req.responseText);
+ showDialog("<H2>" + title + "</H2>",req.responseText, callback);
}
}
};
}
-function saveFile()
+function openDialog()
+{
+ callback = function (fname) { retrieveFile(fname); };
+ showLibrary("Open file", callback);
+}
+
+function saveDialog()
+{
+ callback = function (fname) { saveFile(fname,false); };
+ showLibrary("Save file as", callback);
+}
+
+function saveFile(fname,force)
{
+ if (!is_defined(fname) {
+ fname = current_fname;
+ }
processor = function(xml) {
if (is_defined(xml)) {
+ if (xml.childNodes[0].textContent != "ok") {
+ if (confirm("File already exists. Do you want to proceed anyway?")) {
+ saveFile(fname,true);
+ } else {
+ saveDialog();
+ }
+ } else
debug("file saved!");
} else {
debug("save file failed");
}
resume();
};
- if (is_defined(current_fname)) {
+ if (is_defined(fname)) {
pause();
- callServer("save",processor,"file=" + escape(current_fname) +
+ callServer("save",processor,"file=" + escape(fname) +
"&locked=" + (locked.innerHTML.html_to_matita()).sescape() +
- "&unlocked=" + (unlocked.innerHTML.html_to_matita()).sescape());
+ "&unlocked=" + (unlocked.innerHTML.html_to_matita()).sescape() +
+ "&force=" + force);
}
else { debug("no file selected"); }
}
workarea.appendChild(goalcell);
}
-function showDialog(title,content) {
+function showDialog(title,content,callback) {
dialogTitle.innerHTML = title;
dialogContent.innerHTML = content;
dialogBox.style.display = "block";
+ dialogBox.callback = callback;
}
function removeElement(id) {