reimplementing persistence managers

This commit is contained in:
Ezequiel Bergamaschi 2014-03-16 16:56:44 -03:00
parent da9f861333
commit 42d22ffcb4
2 changed files with 6 additions and 12 deletions

View File

@ -35,25 +35,21 @@ mindplot.LocalStorageManager = new Class({
loadMapDom:function (mapId) {
var xml = localStorage.getItem(mapId + "-xml");
if (xml == null || this.forceLoad) {
var xmlRequest = new Request({
$.ajax({
url:this.documentUrl.replace("{id}", mapId),
headers:{"Content-Type":"text/plain","Accept":"application/xml"},
method:'get',
async:false,
onSuccess:function (responseText) {
success:function (responseText) {
xml = responseText;
}
});
xmlRequest.send();
// If I could not load it from a file, hard code one.
if (xml == null) {
throw new Error("Map could not be loaded");
}
}
var parser = new DOMParser();
return parser.parseFromString(xml, "text/xml");
return xml;
},
unlockMap:function (mindmap) {

View File

@ -165,24 +165,22 @@ mindplot.RESTPersistenceManager = new Class({
loadMapDom:function (mapId) {
// Let's try to open one from the local directory ...
var xml;
var xmlRequest = new Request({
$.ajax({
url:this.documentUrl.replace("{id}", mapId) + "/xml",
method:'get',
async:false,
headers:{"Content-Type":"text/plain","Accept":"application/xml"},
onSuccess:function (responseText) {
success:function (responseText) {
xml = responseText;
}
});
xmlRequest.send();
// If I could not load it from a file, hard code one.
if (xml == null) {
throw new Error("Map could not be loaded");
}
var parser = new DOMParser();
return parser.parseFromString(xml, "text/xml");
return xml;
}
}
);