Index: http/javascripts/mod_savewmc.php =================================================================== --- http/javascripts/mod_savewmc.php (revision 1752) +++ http/javascripts/mod_savewmc.php (working copy) @@ -26,7 +26,12 @@ echo "mod_savewmc_target = '".$e_target."';"; ?> function setOnUnload() { - document.getElementsByTagName('body')[0].setAttribute("onUnload", "mod_savewmc('session');"); + if (ie) { + document.getElementsByTagName('body')[0].onunload = function() {var x = new Function ("", "mod_savewmc_session()"); x(); }; + } + else { + document.getElementsByTagName('body')[0].setAttribute("onUnload", "mod_savewmc_session();"); + } } try {if (saveInSession) {}}catch(e) {saveInSession = 0;} @@ -31,7 +36,7 @@ try {if (saveInSession) {}}catch(e) {saveInSession = 0;} -if (saveInSession == '1') { +if (saveInSession == 1) { mb_registerInitFunctions('setOnUnload()'); } @@ -38,22 +43,26 @@ var mod_savewmc_img = new Image(); mod_savewmc_img.src = ""; //var mod_savewmc_img_over = new Image(); mod_savewmc_img_over.src = ""; +function mod_savewmc_session(){ + sendMapDataToServer("session", function(result, status) {}); +} function mod_savewmc(title){ + var generalTitle = title ? title : prompt("Save WMC as..."); + if (generalTitle != "" && generalTitle != null) { + sendMapDataToServer(generalTitle, function(result, status) {alert(status + ": " + result);}); + } +} + +function sendMapDataToServer(generalTitle, callbackFunction) { + var user = ""; + var ind = getMapObjIndexByName(mod_savewmc_target); - var ind = getMapObjIndexByName(mod_savewmc_target); - var session = 0; - var generalTitle = title; + var extensionDataString = ""; + if (currentWmcExtensionData != null) { + extensionDataString = currentWmcExtensionData.toJSONString(); + } - if (generalTitle) { - if (generalTitle == 'session') { - session = 1; - } - } - else { - generalTitle = prompt("Save WMC as..."); - } - mb_ajax_post("../php/mod_insertWmcIntoDb.php", {"saveInSession":session, "generalTitle":generalTitle, "mapObject":mb_mapObj[ind].toJSONString()}, function (result, status) { - alert(result); - }); + window.frames['ajax'].$.ajaxSetup({async:false}); //TODO: find out why async doesn't work onunload + window.frames['ajax'].$.post("../php/mod_insertWmcIntoDb.php", {"saveInSession":saveInSession, "generalTitle":generalTitle, "extensionData":extensionDataString, "mapObject":mb_mapObj[ind].toJSONString()}, callbackFunction); } \ No newline at end of file