// objektverwaltung scripts // word / pdf uploader var t_objectField = ""; var t_uploadType = ""; function ShowObjectUploader(objectField, uploadType) { t_objectField = objectField; t_uploadType = uploadType; $("#dialog_ImageUploader").dialog("open"); } function _ShowObjectUploader() { $("#dialog_ImageUploaderAlert").delay(0).fadeOut(100); ShowOverlay(); try { var data = new FormData(); } catch (ex) { HideOverlay(); ShowMainAlert("Dieser Browser unterstützt leider keine Uploads. Verwenden Sie zurzeit Chrome oder Firefox als Option."); } jQuery.each($('#dialog_ImageUploaderUpload')[0].files, function (i, file) { data.append('file-' + i, file); }); $.ajax({ url: "../ajax/rest.aspx?action=uploadObjectDatas&objectType=" + t_uploadType, data: data, cache: false, contentType: false, processData: false, type: 'POST', success: function (restObj) { if (restObj.indexOf("Fehler") == -1) { $("#dialog_ImageUploader").dialog("close"); // set filename delegate $("#iFrameObjEdit")[0].contentWindow.SetUploadFilename(t_objectField, restObj, t_uploadType); HideOverlay(); } else { HideOverlay(); $("#dialog_ImageUploaderAlert").delay(0).fadeIn(100); $("#dialog_ImageUploaderAlertConent").html(restObj); } } }); } // new object function NewObject() { ShowOverlay(); tempEditID = CreateNewTempID(); $.get("../ajax/rest.aspx?action=editObject&woid=" + tempEditID, function (restObj) { ShowPage("objektEdit.aspx", false); }); } function GetTempEditID() { return tempEditID; } // edit object function EditObject(woid) { ShowOverlay(); tempEditID = woid; $.get("../ajax/rest.aspx?action=editObject&changeArchivState=false&woid=" + tempEditID, function (restObj) { ShowPage("objektEdit.aspx", false); }); } // copy object function copyWObject(woid) { ShowOverlay(); tempEditID = woid; copyNewWOID = CreateNewTempID(); $.get("../ajax/rest.aspx?action=copyWObject&woid=" + tempEditID + "©NewWOID=" + copyNewWOID, function (restObj) { tempEditID = restObj; ShowPage("objektEdit.aspx", false); }); } // archivieren function changeObjArchivState(woid) { ShowOverlay(); tempEditID = woid; $.get("../ajax/rest.aspx?action=editObject&changeArchivState=true&woid=" + tempEditID, function (restObj) { refreshDatas('objekt'); }); } // sammelinserat hinzufügen function addToSammelinserat(woid) { $.get("../ajax/rest.aspx?action=addObject2Sammelinserat&woid=" + woid, function (restObj) { ReloadSammelInserate(); }); } // sammelinserat mappe aktualisieren var t_sortingInProgress = false; function ReloadSammelInserate() { $.get("../ajax/json.aspx?action=GetCurrentSammelInserateObjects", function (jsonObj) { jsonObj = CreateJSONObject(jsonObj); if (jsonObj.aaData.length >= 1) { // load draggable sammelinserate panel $("#DV_Sammelinserat_Objects_Draggable").load("../ajax/htmlgenerator.aspx?action=GetCurrentSammelInserateObjects", _ReloadSammelInserate); } else { $("#DV_Sammelinserat_Objects").fadeOut(500); } }); } function _ReloadSammelInserate() { $("#UL_List_SammelObjects").sortable({ placeholder: "SammelInseratPlaceholderClass", cursor: "pointer", stop: function (event, ui) { UpdateSammelInseratOrder(ui); }, update: function (event, ui) { t_sortingInProgress = true; }, start: function (event, ui) { t_sortingInProgress = true } }); $("#UL_List_SammelObjects").disableSelection(); // finally fadein $("#DV_Sammelinserat_Objects").fadeIn(500); } function UpdateSammelInseratOrder(ui) { $.get("../ajax/rest.aspx?action=UpdateSammelInseratOrder", { woid: ui.item.attr('id'), newPosition: ui.item.index() }, function (restObj) { }); } function EditSammelinseratObject(woid) { if (!t_sortingInProgress) { } } function DeleteObjFromSammel(woid) { $.get("../ajax/rest.aspx?action=DeleteSammelObject&woid=" + woid, function (restObj) { ReloadSammelInserate(); }); } // sammelinserate alle objekte löschen function DeleteAllCurrentSammelObjects() { $.get("../ajax/rest.aspx?action=DeleteAllCurrentSammelObjects", function (restObj) { ReloadSammelInserate(); }); } // sammelinserat image obj selection function OpenSammelImageSelection(woid, SammelInseratGroupID) { $.get("../ajax/json.aspx?action=getObjImages&woid=" + woid, function (jsonObj) { jsonObj = CreateJSONObject(jsonObj); var html = "Wählen Sie ein Bild aus, mit welchem das Inserat erzeugt werden werden soll:

"; $(jsonObj.aaDataObjImages).map(function () { html += "
"; }); $("#dialog_sammelobjimageselectorContent").html(html + "
 
"); $("#dialog_sammelobjimageselector").dialog("option", "width", 210); $("#dialog_sammelobjimageselector").dialog("open"); }); } function SetSammelImageSelection(imgurl, woid, SammelInseratGroupID) { $.get("../ajax/rest.aspx?action=SetImgUrlToSammelObj&woid=" + woid + "&imgUrl=" + imgurl, function (restObj) { ReloadSammelInserate(); $("#dialog_sammelobjimageselector").dialog("close"); }); } // fill up object function FillUpEditObjectForm(JSONData) { // delegate try { setTimeout(function () { $("#iFrameObjEdit")[0].contentWindow.FillUpEditObjectForm(JSONData); HideOverlay(); }, 2500); } catch(e) { setTimeout(function () { $("#iFrameObjEdit")[0].contentWindow.FillUpEditObjectForm(JSONData); HideOverlay(); }, 5000); } } // dialog draft deleter function DeleteObjectEdit(woid) { tempEditID = woid; $("#dialog_delObjectEntwurf").dialog("open"); } function _DeleteObjectEdit() { $("#dialog_delObjectEntwurf").dialog("close"); ShowOverlay(); $.get("../ajax/rest.aspx?action=delEditObject&id=" + tempEditID, function (restObj) { ShowPage("objektverwaltungEntwurf.aspx", false); }); return false; } // dialog object deleter function DeleteObject(woid) { tempEditID = woid; $("#dialog_delObject").dialog("open"); } function _DeleteObject() { $("#dialog_delObject").dialog("close"); ShowOverlay(); $.get("../ajax/rest.aspx?action=delObject&id=" + tempEditID, function (restObj) { refreshDatas("objekt"); }); return false; } // homegate online / offline switcher var t_woid_homegate; var t_currentState; function changeHomegateOnlineState(woid, currentState) { t_woid_homegate = woid; t_currentState = currentState; if (!currentState) { // online dialog ShowOverlay(); // hide complete page $("#AjaxContent").hide(); // now create a fake auftrag for producing preview image t_woid = t_woid_homegate; t_inseratid = CreateNewTempID(); tempEditID = t_inseratid; t_testauftrag = false; t_homegateFakeProgress = true; // the flag for telling that is fake _newInserat("10", "Immobilien"); } else { // offline dialog var htmlState = "Dieses Objekt jetzt offline schalten?"; $("#dialog_homgegateSwitcher").attr('title', 'Objekt auf homegate.ch entfernen'); $("#dialog_homgegateSwitcher_offlineStateHTML").html(htmlState); $("#dialog_homgegateSwitcher_onlineStateHTML").hide(); $("#dialog_homgegateSwitcher_offlineStateHTML").show(); $("#dialog_homgegateSwitcher").dialog("open"); } } function changeHomegateOnlineState_after() { $.get("../ajax/json.aspx?action=GetNormalObjectJSON&id=" + t_woid_homegate, function (jsonObj) { jsonObj = CreateJSONObject(jsonObj); var htmlState = "

" + jsonObj.Titel + "
Objekt ID: " + jsonObj.Woid + "


Dieses Objekt jetzt online schalten?
"; ShowOverlay(); // get more inserat datas $.get("../ajax/json.aspx?action=GetPreviewImageFromHomegate&id=" + t_inseratid, function (jsonObj) { jsonObj = CreateJSONObject(jsonObj); htmlState+="
"; $("#dialog_homgegateSwitcher").attr('title', 'Objekt auf homegate.ch aufschalten'); $("#dialog_homgegateSwitcher_onlineStateHTML").html(htmlState); $("#dialog_homgegateSwitcher_onlineStateHTML").show(); $("#dialog_homgegateSwitcher_offlineStateHTML").hide(); HideOverlay(); $("#dialog_homgegateSwitcher").dialog("open"); $("#dialog_homgegateSwitcher").dialog("option", "closeOnEscape", false); $("#dialog_homgegateSwitcher").dialog({ beforeClose: function( event, ui ) { // check if full page is hide if (!$("#AjaxContent").is(":visible")) { $("#AjaxContent").show(); refreshDatas("objekt"); } } }); }); }); } function _changeHomegateOnlineState() { $("#dialog_homgegateSwitcher").dialog("close"); ShowOverlay(); $.get("../ajax/rest.aspx?action=changeHomegateState&id=" + t_woid_homegate, function (restObj) { if (!t_currentState) { // generate now order and show page back $.post("../ajax/json.aspx?action=createInseratOrder&homegateOrder=true&id=" + t_inseratid, null, function (jsonObj) { // show full page $("#AjaxContent").show(); refreshDatas("objekt"); }); } else { refreshDatas("objekt"); } // now start hidden ftp (stateless) StartHomegateExport(false); }); return false; } // dialog saver function SaveObjectEdit() { $("#iFrameObjEdit")[0].contentWindow.AutoSaveEditObject(); $("#iFrameObjEdit")[0].contentWindow.ShowSaveDialog = true; $("#iFrameObjEdit")[0].contentWindow.MakeFullValidation(); $("#DV_Alert_Object").delay(100).fadeOut(); } function SaveObjectEditOK() { $("#dialog_saveObjectinDB").dialog("open"); } function _SaveObjectEdit() { // save object in amasys / db $("#dialog_saveObjectinDB").dialog("close"); ShowOverlay(); $.get("../ajax/rest.aspx?action=saveEditObject&id=" + tempEditID, function (restObj) { if (restObj == "OK") { refreshDatas('objekt'); // and show objektverwaltung page StartHomegateExport(true); // and show homegate export } else { HideOverlay(); $("#DV_Alert_Object").delay(100).fadeIn(); $("#DV_Alert_Object_Message").html(restObj); } }); return false; } function SetObjArchivFlag() { t_archiv = false; if ($('#objVerwaltungArchivCheckbox').is(":checked")) { t_archiv = true; } refreshDatas('objekt'); } var homegateTimout; function StartHomegateExport(silent) { // clear timeout clearTimeout(homegateTimout); // start export with delay 30 seconds homegateTimout = setTimeout(function () { if (!silent) { $().toastmessage('showToast', { text: 'Homegate Export wird jetzt im Hintergrund ausgeführt. Sie können weiter arbeiten.', sticky: false, stayTime: 3000, position: 'middle-right', type: 'notice' // notice, warning, error, success }); } $.get("../ajax/stateless.aspx?action=startHomegateExport", null, function (restObj) { if (restObj.indexOf("true") == 0) { if (!silent) { $().toastmessage('showToast', { text: 'Homegate Export abgeschlossen.', sticky: true, stayTime: 0, position: 'middle-right', type: 'success' // notice, warning, error, success }); } } else { if (!silent) { $().toastmessage('showToast', { text: 'Fehler beim Export: ' + restObj, sticky: true, stayTime: 0, position: 'middle-right', type: 'error' // notice, warning, error, success }); } } }); }, 90000); }