function openNavStep1() { $("body").addClass("commonModal-is-open"); $("#commonModal").modal("hide"); openNav(); } function selected_listing_trigger_click(locationType) { console.log("locationType:", locationType); } /* function openNav() { document.getElementById("mySidenav").classList.add("open"); } function closeNav() { if ($("body").hasClass("commonModal-is-open")) { $("#commonModal").modal("show"); $("body").removeClass("commonModal-is-open"); } document.getElementById("mySidenav").classList.remove("open"); } document.addEventListener("DOMContentLoaded", function () { document.addEventListener("click", function (event) { const toggleBtn = document.getElementById("openSideNav"); const sidenav = document.getElementById("mySidenav"); if (!toggleBtn || !sidenav) return; if (!toggleBtn.contains(event.target) && !sidenav.contains(event.target)) { closeNav(); } }); }); */ /*********************/ function openNav() { console.log("mySidenav open.."); $("#mySidenav").addClass("open"); $("body").css("overflow", "hidden"); } function closeNav() { console.log("closeNav"); $("#mySidenav").removeClass("open"); $("body").css("overflow", ""); if ($("body").hasClass("commonModal-is-open")) { $("#commonModal").modal("show"); $("body").removeClass("commonModal-is-open"); } } $(document).on("click", ".open-side-nav, #openSideNav, #openSideNav-my-account", function (e) { e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); console.log("Open side nav triggered"); openNav(); }); $(document).on("click", function (e) { const $sidenav = $("#mySidenav"); if (!$sidenav.hasClass("open")) return; const clickedTrigger = $(e.target).closest(".open-side-nav, #openSideNav, #openSideNav-my-account").length > 0; const clickedInside = $sidenav.is(e.target) || $sidenav.has(e.target).length > 0; if (!clickedInside && !clickedTrigger) { closeNav(); } }); /*********************/ $(document).ready(function () { $(document).one("keyup", ".geo-address", function () { $("#googleidsearch").val(this.id); initMap4(); }); $(document).one("keyup", ".geo-address2", function () { $("#googleidsearch").val(this.id); initMap4(); }); $(document).one("keyup", ".geo-address-3", function () { $("#googleidsearch").val(this.id); initMap5(); }); $(document).on("focus", ".global-geo-address-lat-log", function () { var focusTxt = $(this).val(); $(this).attr("focusTxt", focusTxt); }); $(document).on("blur", ".global-geo-address-lat-log", function () { var focusTxt = $(this).attr("focusTxt"); var valTxt = $(this).val(); if (focusTxt != valTxt) { $("#lat_address").val(""); $("#lng_address").val(""); } }); $(document).one("keyup", ".global-geo-address-lat-log", function () { $("#googleidsearch").val(this.id); setTimeout(function () { globalinitMap6(); }, 100); }); $(document).one("keyup", ".global-geo-address", function () { $("#googleidsearch").val(this.id); globalinitMap4(); }); $(document).one("keyup", ".global-geo-address2", function () { $("#googleidsearch").val(this.id); globalinitMap5(); }); $(document).on("click", ".cust_address_global", function () { if ($(".cust_address_global2").is(":checked")) { $("#tr_to_address").val(""); $("#tr_to_address_administrative_area_level_1").val(""); $(".cust_address_global2").prop("checked", false); } $("#tr_from_address").val(""); $("#tr_from_address_administrative_area_level_1").val(""); setTimeout(function () { initMap4(); initMap5(); }, 600); $(document).one("keyup", ".global-geo-address", function () { globalinitMap4(); }); $(document).one("keyup", ".global-geo-address2", function () { globalinitMap5(); }); }); $(document).on("click", ".cust_address_global2", function () { if ($(".cust_address_global").is(":checked")) { $("#tr_from_address").val(""); $("#tr_from_address_administrative_area_level_1").val(""); $(".cust_address_global").prop("checked", false); } $("#tr_to_address").val(""); $("#tr_to_address_administrative_area_level_1").val(""); setTimeout(function () { initMap4(); initMap5(); }, 600); $(document).one("keyup", ".global-geo-address", function () { globalinitMap4(); }); $(document).one("keyup", ".global-geo-address2", function () { globalinitMap5(); }); }); setTimeout(function () { $(".mobile-selected-listing").trigger("click"); }, 1000); }); var map, places, infoWindow; var markers = []; var autocomplete; var countryRestrict = { country: "no", }; var MARKER_PATH = "https://developers.google.com/maps/documentation/javascript/images/marker_green"; var hostnameRegexp = new RegExp("^https?://.+?/"); var countries = { no: { center: { lat: 60.472, lng: 8.4689, }, zoom: 3, }, }; function globalinitMap4() { var countryRestrictOpt = 1; var idsearch = "tr_from_address"; document.getElementById("googleidsearch").value = "tr_from_address"; var checkboxval = $("input[class='cust_address_global']:checked").val(); if (checkboxval == "from") { countryRestrictOpt = 0; } if (countryRestrictOpt == 1) { autocomplete = new google.maps.places.Autocomplete( document.getElementById("" + idsearch + ""), { componentRestrictions: countryRestrict, } ); } else { autocomplete = new google.maps.places.Autocomplete( document.getElementById("" + idsearch + ""), {} ); } autocomplete.addListener("place_changed", fillInAddress4); custom_msg_autocomplete(); } function globalinitMap5() { var countryRestrictOpt = 1; var idsearch = "tr_to_address"; document.getElementById("googleidsearch").value = "tr_to_address"; var checkboxval = $("input[class='cust_address_global2']:checked").val(); if (checkboxval == "to") { countryRestrictOpt = 0; } if (countryRestrictOpt == 1) { autocomplete = new google.maps.places.Autocomplete( document.getElementById("" + idsearch + ""), { componentRestrictions: countryRestrict, } ); } else { autocomplete = new google.maps.places.Autocomplete( document.getElementById("" + idsearch + ""), {} ); } autocomplete.addListener("place_changed", fillInAddress5); custom_msg_autocomplete(); } function globalinitMap6() { var idsearch = document.getElementById("googleidsearch").value; autocomplete = new google.maps.places.Autocomplete( document.getElementById("" + idsearch + ""), { componentRestrictions: countryRestrict, } ); autocomplete.addListener("place_changed", fillInAddress6); custom_msg_autocomplete(); } function initMap4() { var idsearch = document.getElementById("googleidsearch").value; autocomplete = new google.maps.places.Autocomplete( document.getElementById("" + idsearch + ""), { componentRestrictions: countryRestrict, } ); autocomplete.addListener("place_changed", fillInAddress); custom_msg_autocomplete(); } function initMap5() { var idsearch = document.getElementById("googleidsearch").value; autocomplete = new google.maps.places.Autocomplete( document.getElementById("" + idsearch + ""), { componentRestrictions: countryRestrict, } ); } var componentForm = { administrative_area_level_1: "short_name", long_name: "short_name", postal_code: "short_name", }; function initMap6() {} function fillInAddress2() { var place = autocomplete.getPlace(); var idsearch = document.getElementById("googleidsearch").value; if (idsearch == "tr_to_address") { $("#to_lat").val(place.geometry.location.lat()); $("#to_lng").val(place.geometry.location.lng()); } else { $("#lat").val(place.geometry.location.lat()); $("#lng").val(place.geometry.location.lng()); } if ( place.address_components !== undefined && place.address_components.length > 0 ) { for (var i = 0; i < place.address_components.length; i++) { var addressType = place.address_components[i].types[0]; var val = place.address_components[i][componentForm[addressType]]; if (addressType == "postal_code") { if (typeof val !== "undefined" && val != "") { $("#zipcode").val(val); } } if (addressType == "administrative_area_level_1") { var val = place.address_components[i][componentForm[addressType]]; if (typeof val !== "undefined" && val != "") { $("#location_" + val + "").prop("checked", true); } } } } } function fillInAddress() { var place = autocomplete.getPlace(); var idsearch = document.getElementById("googleidsearch").value; if (idsearch == "tr_to_address") { $("#to_lat").val(place.geometry.location.lat()); $("#to_lng").val(place.geometry.location.lng()); } else { $("#lat").val(place.geometry.location.lat()); $("#lng").val(place.geometry.location.lng()); } if ( place.address_components !== undefined && place.address_components.length > 0 ) { for (var i = 0; i < place.address_components.length; i++) { var addressType = place.address_components[i].types[0]; if (componentForm[addressType]) { var val = place.address_components[i][componentForm[addressType]]; if (addressType == "postal_code") { var idds = $("#" + idsearch + "").attr("data-id"); $("#" + idds + "").val(val); if (idds == "where_zipcode") { $("#" + idds + "_label").hide(); $("input[name='" + idds + "']").attr("type", "hidden"); } } else if (addressType == "administrative_area_level_1") { var idd = idsearch + "_" + addressType; document.getElementById(idd).value = val; } else { var idd = idsearch + "_administrative_area_level_1"; if (document.getElementById(idd).value == "") { document.getElementById(idd).value = val; } } } } } check_locationNotFound(idsearch); } function fillInAddress4() { var place = autocomplete.getPlace(); var idsearch = "tr_from_address"; if (idsearch == "tr_to_address") { $("#to_lat").val(place.geometry.location.lat()); $("#to_lng").val(place.geometry.location.lng()); } else { $("#lat").val(place.geometry.location.lat()); $("#lng").val(place.geometry.location.lng()); } if ( place.address_components !== undefined && place.address_components.length > 0 ) { for (var i = 0; i < place.address_components.length; i++) { var addressType = place.address_components[i].types[0]; if (componentForm[addressType]) { var val = place.address_components[i][componentForm[addressType]]; if (addressType == "postal_code") { var idds = $("#" + idsearch + "").attr("data-id"); $("#" + idds + "").val(val); } else if (addressType == "administrative_area_level_1") { var idd = idsearch + "_" + addressType; document.getElementById(idd).value = val; } else { var idd = idsearch + "_administrative_area_level_1"; if (document.getElementById(idd).value == "") { document.getElementById(idd).value = val; } } } } } } function fillInAddress6() { var place = autocomplete.getPlace(); var idsearch = "address"; setTimeout(function () { $("#lat_address").val(place.geometry.location.lat()); $("#lng_address").val(place.geometry.location.lng()); }, 1000); } function fillInAddress5() { var place = autocomplete.getPlace(); var idsearch = "tr_to_address"; if ( place.address_components !== undefined && place.address_components.length > 0 ) { for (var i = 0; i < place.address_components.length; i++) { var addressType = place.address_components[i].types[0]; if (componentForm[addressType]) { var val = place.address_components[i][componentForm[addressType]]; if (addressType == "postal_code") { var idds = $("#" + idsearch + "").attr("data-id"); $("#" + idds + "").val(val); } else if (addressType == "administrative_area_level_1") { var idd = idsearch + "_" + addressType; document.getElementById(idd).value = val; } else { var idd = idsearch + "_administrative_area_level_1"; if (document.getElementById(idd).value == "") { document.getElementById(idd).value = val; } } } } } } $(document).on( "change", '.notificaationsopr input[name="jobtype[]"]', function () { var numberOfChecked = parseInt( $('.notificaationsopr input[name="jobtype[]"]:checkbox:checked').length ); if (numberOfChecked > 0) { $("#invalidCheck3").prop("checked", true); } else { $("#invalidCheck3").prop("checked", false); } } ); $(document).on("change", ".zipcode-get-state", function () { var $this = $(this); var val = $this.val(); var length = val.length; if (length == 4) { var url = "/ajax/getstate"; $.ajax({ url: url, method: "POST", data: { search: val, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#location_" + data["state"] + "").prop("checked", true); $("#zipcode_location").val(data["place"]); } }, }); } }); $(document).on("change", ".zipcode-get-state2", function () { var $this = $(this); var val = $this.val(); var length = val.length; if (length == 4) { var url = "/ajax/getstate"; $.ajax({ url: url, method: "POST", data: { search: val, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { document.getElementById("state").value = data["place"]; } }, }); } }); function search() { var search = { bounds: map.getBounds(), types: ["lodging"], }; places.nearbySearch(search, function (results, status) { if (status === google.maps.places.PlacesServiceStatus.OK) { clearResults(); clearMarkers(); for (var i = 0; i < results.length; i++) { var markerLetter = String.fromCharCode("A".charCodeAt(0) + (i % 26)); var markerIcon = MARKER_PATH + markerLetter + ".png"; markers[i] = new google.maps.Marker({ position: results[i].geometry.location, animation: google.maps.Animation.DROP, icon: markerIcon, }); markers[i].placeResult = results[i]; google.maps.event.addListener(markers[i], "click", showInfoWindow); setTimeout(dropMarker(i), i * 100); addResult(results[i], i); } } }); } let assignment_fee = 0; $(document).on("click", ".action-proposals-wanted", function () { var job_id = $(this).attr("data-id"); var url = "/browse/proposalswanted"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { assignment_fee = data["assignment_fee"]; $("#payment-option-modal").html(data["main_content"]); $("#payment-option-modal").modal(); } else if (data["success"] == "notify") { $("#suggestions-msg").html( "
" + data["message"] + "
" ); } else { window.location.href = "/" + data["redirect"]; } }, }); }); $(document).on("click", ".action-offer-price-suggestions", function () { var job_id = $(this).attr("data-id"); var price_suggestions = $("#price_suggestions").val(); var url = "/browse/offerhelpsuggestions"; $(".modal").modal("hide"); $.ajax({ url: url, method: "POST", data: { job_id: job_id, price_suggestions: price_suggestions, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#payment-option-modal").html(data["main_content"]); $("#payment-option-modal").modal(); } else if (data["success"] == "notify") { $("#suggestions-msg").html( "
" + data["message"] + "
" ); } else { window.location.href = "/" + data["redirect"]; } }, }); }); $(document).on("click", ".action-estimate-the-job-form", function () { var job_id = $(this).attr("data-id"); var offertype = $(this).attr("data-offertype"); var price_suggestions = $("#price_suggestions").val(); var url = "/browse/offerhelpsuggestionsform"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, price_suggestions: price_suggestions, offertype: offertype, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#payment-option-modal").html(data["main_content"]); $("#payment-option-modal").modal(); } else if (data["success"] == "notify") { $("#suggestions-msg").html( "
" + data["message"] + "
" ); } else { window.location.href = "/" + data["redirect"]; } }, }); }); $(document).on("click", ".btn-offer-funds-option-1", function () { $("#payment_msg").html(""); var offerinfo = $("#offer-info-popup").serializeArray(); var url = "/payment/addtilbud_option"; $(".btn-offer-funds-option-1").html("Vent.."); $.ajax({ url: url, method: "POST", data: { offerinfo: offerinfo, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".btn-offer-funds-option-1").html("Send tilbud"); if (data["success"] == "true") { $("#payment-option-modal").html(data["main_content"]); $("#payment-option-modal").modal(); } else { $("#funds_option_msg").html( "
" + data["message"] + "
" ); } setTimeout(function () { $("#funds_option_msg").html(""); }, 12000); }, }); }); /* $(document).on("click", ".action-offer-funds-option-1-confirm", function () { $("#funds_option_msg").html(""); var offerinfo = $("#offer-info-popup").serializeArray(); var url = "/payment/addtilbud_option_confirm"; $(".action-offer-funds-option-1-confirm").html("Vent.."); $.ajax({ url: url, method: "POST", data: { offerinfo: offerinfo, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".action-offer-funds-option-1-confirm").html('Neste '); if (data["success"] == "true") { $("#payment-option-modal").html(data["main_content"]); $("#payment-option-modal").modal(); } else { $("#funds_option_msg").html( "
" + data["message"] + "
" ); } setTimeout(function () { $("#funds_option_msg").html(""); }, 12000); }, }); }); */ $(document).on("click", ".action-offer-funds-option-eng", function () { $("#payment_msg").html(""); var offerinfo = $("#offer-info-popup").serializeArray(); var url = "/payment/addtilbud_option"; $(".btn-offer-funds-option-1").html("Vent.."); $.ajax({ url: url, method: "POST", data: { offerinfo: offerinfo, lang: "eng", }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".btn-offer-funds-option-1").html("Send tilbud"); if (data["success"] == "true") { $("#payment-option-modal").html(data["main_content"]); $("#payment-option-modal").modal(); } else { $("#funds_option_msg").html( "
" + data["message"] + "
" ); } setTimeout(function () { $("#funds_option_msg").html(""); }, 12000); }, }); }); $(document).on("click", ".action-send-estimate", function () { $("#payment_msg").html(""); var offerinfo = $("#ispection-info-popup").serialize(); var url = "/payment/addtilbud_option_estimate"; $(".action-send-estimate").html("Vent.."); $.ajax({ url: url, method: "POST", data: { offerinfo: offerinfo, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".action-send-estimate").html("Be om befaring"); if (data["success"] == "true") { $("#payment-option-modal").html(data["main_content"]); $("#payment-option-modal").modal(); } else { $("#funds_option_msg").html( "
" + data["message"] + "
" ); } setTimeout(function () { $("#funds_option_msg").html(""); }, 12000); }, }); }); $(document).on("click", ".btn-offer-funds-option-2", function () { $("#payment_msg_strex").html(""); var payment_option_type = $( 'input[name="payment_option_type"]:checked' ).val(); if (payment_option_type == "vipps") { var offerinfo = $("#offer-info-popup").serializeArray(); var url = "/payment/addtilbud_option2"; $(".btn-offer-funds-option-2").html("Vent.."); $.ajax({ url: url, method: "POST", data: { offerinfo: offerinfo, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".btn-offer-funds-option-2").html( 'Neste ' ); if (data["success"] == "true") { $("#add-funds-suggestions #payment_msg_strex").html(""); $("#add-funds-suggestions").html(data["main_content"]); } else { $("#add-funds-suggestions #payment_msg_strex").html( "
" + data["message"] + "
" ); } setTimeout(function () { $("#add-funds-suggestions #payment_msg_strex").html(""); }, 12000); }, }); } if (payment_option_type == "strex") { var offerinfo = $("#offer-info-popup").serializeArray(); var url = "/payment/offerhelp_stex2"; $(".btn-offer-funds-option-2").html("Vent.."); if ($(".btn-offer-funds-option-2").is("[disabled=disabled]") == false) { $(".btn-offer-funds-option-2").attr("disabled", "disabled"); $.ajax({ url: url, method: "POST", data: { offerinfo: offerinfo, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".btn-offer-funds-option-2").html( 'Neste ' ); if (data["success"] == "true") { var job_id = $("#job_id").val(); window.location.href = "/messages?chat_id=" + data["user_id"] + "&job_id=" + job_id + ""; } else if (data["success"] == "popupstrex") { $("#payment-option-modal").html(data["main_content"]); $(".btn-funds-option-2").removeAttr("disabled"); } else if (data["success"] == "popup") { $("#payment-option-modal").html(data["main_content"]); $(".btn-funds-option-2").removeAttr("disabled"); } else { if (data["redirect"] != "" && data["message"] == "") { window.location.href = "/" + data["redirect"]; } else if (data["message"] == "") { data["message"] = "Noe gikk galt. Prøv igjen senere."; } $("#offer-info-popup #payment_msg_strex").html( "
" + data["message"] + "
" ); $(".btn-offer-funds-option-2").removeAttr("disabled"); } }, }); } } }); $(document).on("click", ".btn-add-payment-offer", function () { $("#payment_msg").html(""); var offerinfo = $("#payment-info-offer").serializeArray(); var url = "/payment/addpaymentoffer"; $(".btn-add-payment-offer").html("Vent.."); $.ajax({ url: url, method: "POST", data: { paymentInfo: offerinfo, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".btn-add-payment-offer").html("Reserver"); if (data["success"] == "true") { window.location.href = data["url"]; } else { $("#payment_msg_offer").html( "
" + data["message"] + "
" ); } setTimeout(function () { $("#payment_msg_offer").html(""); }, 12000); }, }); }); $(document).on("click", ".btn-cancel-counter", function () { $(".btn-cancel-counter").html("Vent.."); var data_type = $(this).attr("data-type"); var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var orderId = $(".selected-listing").attr("data-orderId"); var help_id = $(".selected-listing").attr("data-help_id"); var url = "/messages/check_cancel_counter"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, orderId: orderId, help_id: help_id, }, dataType: "text", success: function (script_response) { $(".btn-cancel-counter").html( ' Trekk tilbake' ); var data = $.parseJSON(script_response); if (data["success"] == "true") { /*$(".selected-listing").trigger("click");*/ selected_listing_trigger_click(1001); console.log("Send chat_message_refresh_2 - 14"); socket.emit("chat_message_refresh_2", { job_id: job_id, help_id: help_id, timestamp: new Date().toISOString(), }); setTimeout(function () { $(".btn-bannotpossible").trigger("click"); }, 500); } else { if (data_type == 2) { $("#div-cancel-request .wrapme h2").html( "Er du sikker på at du vil trekke tilbake forespørselen om befaring?" ); $("#div-cancel-request .wrapme p").html( "Oppdragsgiver vil bli fjernet fra kontaktlisten din og vil få beskjed om at du ikke lenger er aktuell for befaring." ); } $("#div-cancel-request").modal("show"); } }, }); }); $(document).on("click", ".btn-deny-request", function () { var type = $(this).attr("data-type"); if (type == "espection") { $("#div-deny-request h2").html("Avvis befaring"); $("#div-deny-request p").html( "Er du sikker på at du ikke ønsker denne hjelperen på befaring? Hjelperen vil bli fjernet fra kontaktlisten din." ); } else { $("#div-deny-request h2").html("Avvis tilbud"); /* $("#div-deny-request p").html( "Er du sikker på at du vil avvise tilbudet? Hjelperen vil bli fjernet fra kontaktlisten din " ); */ $("#div-deny-request p").html( "Er du sikker på at du vil avvise prisforslaget? Hjelperen vil bli fjernet fra kontaktlisten din " ); } $("#div-deny-request").modal("show"); }); $(document).on("click", "#btn-reject-offer-cansle", function () { $("#div-deny-request").modal("hide"); }); $(document).on("click", "#btn-accept-request-confirm", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); window.location.href = "/messages?chat_id=" + user_id + "&job_id=" + job_id + ""; }); $(document).on("click", ".btn-cancel-confirm-counter", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var orderId = $(".selected-listing").attr("data-orderId"); var help_id = $(".selected-listing").attr("data-help_id"); $(".btn-cancel-confirm-counter").html("Vent.."); var url = "/messages/counter_offer_cancel"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, orderId: orderId, help_id: help_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".btn-cancel-confirm-counter").html("Angre"); if (data["success"] == "true") { window.location.href = "/messages"; } else { } }, }); }); $(document).on("click", ".btn-remove-contact", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var orderId = $(".selected-listing").attr("data-orderId"); $(".btn-remove-contact").html("Vent.."); var url = "/messages/offer_remove_contact"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, orderId: orderId, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $("#btn-reject-offer-reject").html("Reject"); if (data["success"] == "true") { location.reload(); } else { } }, }); }); $(document).on("click", ".btn-remove-contact-invitation", function () { var invite_id = $("#invite_id").val(); var user_id = $("#user_id").val(); var job_id = $("#job_id").val(); var helper = $("#helper").val(); var helper_user_id = $("#helper_user_id").val(); $(".btn-remove-contact-invitation").html("Vent.."); var url = "/messages/offer_remove_contact_invitation"; $.ajax({ url: url, method: "POST", data: { invite_id: invite_id, user_id: user_id, job_id: job_id, helper: helper, helper_user_id: helper_user_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $("#btn-reject-offer-reject").html("Reject"); if (data["success"] == "true") { location.reload(); } else { } }, }); }); $(document).on("click", "#btn-reject-offer-reject", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var orderId = $(".selected-listing").attr("data-orderId"); $("#btn-reject-offer-reject").html("Vent.."); var url = "/messages/offer_reject"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, orderId: orderId, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $("#btn-reject-offer-reject").html("Avviss"); if (data["success"] == "true") { location.reload(); } else { } }, }); }); $(document).on("click", ".btn-accept-request", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var orderId = $(".selected-listing").attr("data-orderId"); var type = $(this).attr("data-type"); $(".btn-accept-request").html("Vent.."); var url = "/messages/offer_accept"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, orderId: orderId, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".btn-accept-request").html( ' Diskuter' ); if (data["success"] == "true") { /* $("#div-accept-request-confirm").modal({ backdrop: "static", keyboard: false, }); $("#div-accept-request-confirm").modal("show"); */ $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } else { } }, }); }); $(document).on("click", ".action-confirm-offer", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var orderId = $(".selected-listing").attr("data-orderId"); var first_message = $("#first_message").val(); var type = $(this).attr("data-type"); $(".action-confirm-offer").html("Vent.."); var url = "/messages/offer_accept_confirm"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, orderId: orderId, first_message: first_message, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".action-confirm-offer").html( 'Send melding ' ); if (data["success"] == "true") { $("#commonModal").modal("hide"); $("#div-accept-request-confirm").modal({ backdrop: "static", keyboard: false, }); $("#div-accept-request-confirm").modal("show"); } else { $("#popup_msg").html( "" ); setTimeout(function () { $("#popup_msg").html(""); }, 4000); } }, }); }); $(document).on("click", ".btn-map-info-popup", function () { var job_id = $(this).attr("data-id"); var pathname = window.location.pathname; /* alert(JSON.stringify( window.location )); alert(JSON.stringify( window.location.href )); alert(JSON.stringify( window.location.pathname )); */ var url = "/ajax/popup_map"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, pathname: pathname, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { if (data["location_type"] == 2) { $("#commonModal").html(data["map"]); $("#commonModal").modal(); show_map_address(data); } else { $("#commonModal").html(data["map"]); $("#commonModal").modal(); } } else { window.location.href = "/innlogging"; } }, }); }); $(document).on("click", ".action-map-info-popup", function () { var map_type = $(this).attr("data-map"); var user_id = $(this).attr("data-user_id"); var pathname = window.location.pathname; var url = "/ajax/popup_map_geo"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, map_type: map_type, pathname: pathname, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["map"]); $("#commonModal").modal(); } else { window.location.href = "/innlogging"; } }, }); }); /*address map*/ function show_map_address(data) { let tr_to_address = data["tr_to_address"]; let tr_from_address = data["tr_from_address"]; var directionsService = new google.maps.DirectionsService(); var directionsRenderer = new google.maps.DirectionsRenderer(); var map = new google.maps.Map(document.getElementById("map-popup")); directionsRenderer.setMap(map); calculateAndDisplayRoute( tr_to_address, tr_from_address, directionsService, directionsRenderer, map ); // Pass 'map' to the function } function calculateAndDisplayRoute( tr_to_address, tr_from_address, directionsService, directionsRenderer, map ) { // Accept 'map' as a parameter directionsService.route( { origin: tr_from_address, destination: tr_to_address, travelMode: "DRIVING", }, function (response, status) { if (status === "OK") { directionsRenderer.setDirections(response); fitBoundsToRoute(response.routes[0], map); } else { window.alert("Directions request failed due to " + status); } } ); } function fitBoundsToRoute(route, map) { var bounds = new google.maps.LatLngBounds(); route.legs.forEach(function (leg) { leg.steps.forEach(function (step) { step.path.forEach(function (point) { bounds.extend(point); }); }); }); map.fitBounds(bounds); var listener = google.maps.event.addListenerOnce(map, "idle", function () { var zoom = Math.min(map.getZoom(), 15); map.setZoom(zoom); }); } /*address map*/ $(document).on("click", ".btn-dont-cancel-counter", function () { $(".modal").modal("hide"); }); $(document).on( "click", ".close-bannotpossible,.btn-dont-cancel-offer", function () { $("#commonModal").modal("hide"); $("#bannotpossible").modal("hide"); $("#bannotpossible-content").html(""); } ); $(document).on("click", ".action-triggeraction-1", function () { if ($(".btn-bannotpossible")[0] || $(".action-hire-emp-pannel-k")[0]) { $(".btn-bannotpossible").trigger("click"); } else if ($(".action-fire-emp-pannel-k")[0]) { /********* - not found now*/ var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var help_id = $(".selected-listing").attr("data-help_id"); var orderid = $(".selected-listing").attr("data-orderid"); var url = "/messages/removehelper_modal_popup"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, help_id: help_id, orderid: orderid, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); /**********/ } }); /* $(document).on("click", ".btn-bannotpossible", function () { console.log("wait...."); var user_id = $("#user_id").val(); var job_id = $("#job_id").val(); var helper = $("#helper").val(); var Send_melding = "N"; if ($("#chat_popup_info_helper").hasClass("col-Send-melding")) { $("#chat_popup_info_helper").removeClass("col-Send-melding"); var Send_melding = "Y"; } var url = "/messages/offerpullback"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, Send_melding: Send_melding, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $("#commonModal").modal("hide"); $("#bannotpossible").modal("show"); $("#bannotpossible-content").html(data["popup_content"]); }, }); }); */ $(document).on("click", ".btn-bannotpossible", function () { console.log("wait...."); var user_id = $("#user_id").val(); var job_id = $("#job_id").val(); var helper = $("#helper").val(); var Send_melding = "N"; if ($("#chat_popup_info_helper").hasClass("col-Send-melding")) { $("#chat_popup_info_helper").removeClass("col-Send-melding"); var Send_melding = "Y"; } var url = "/messages/offerpullback"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, Send_melding: Send_melding, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); /* $("#commonModal").modal("hide"); $("#bannotpossible").modal("show"); $("#bannotpossible-content").html(data["popup_content"]); */ $("#commonModal").html(data["main_content"]); $("#commonModal").modal("show"); }, }); }); $(document).on("click", ".btn-cancel-offer-byjobowner", function () { var user_id = $("#user_id").val(); var job_id = $("#job_id").val(); var helper = $("#helper").val(); var Send_melding = "N"; if ($("#chat_popup_info_helper").hasClass("col-Send-melding")) { $("#chat_popup_info_helper").removeClass("col-Send-melding"); var Send_melding = "Y"; } $(".btn-cancel-offer-byjobowner").html("Vent.."); var url = "/messages/pullbackaction"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, Send_melding: Send_melding, by_jobowner: "Y", }, dataType: "text", success: function (script_response) { $(".btn-cancel-offer-byjobowner").html("Slett kontakt"); var data = $.parseJSON(script_response); if (data["success"] == "true") { if (data["main_content"] == "") { window.location.href = "/messages"; } $("#bannotpossible").html(data["main_content"]); /*not found now*/ $("#bannotpossible-1").html(data["main_content"]); /**/ $("#commonModal").html(data["main_content"]); } else { if (data["main_content"] != "") { $("#commonModal").html(data["main_content"]); } } }, }); }); $(document).on("click", ".btn-cancel-offer", function () { var user_id = $("#user_id").val(); var job_id = $("#job_id").val(); var helper = $("#helper").val(); var Send_melding = "N"; if ($("#chat_popup_info_helper").hasClass("col-Send-melding")) { $("#chat_popup_info_helper").removeClass("col-Send-melding"); var Send_melding = "Y"; } $(".btn-cancel-offer").html("Vent.."); var url = "/messages/pullbackaction"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, Send_melding: Send_melding, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { if (data["main_content"] == "") { location.reload(); } $("#bannotpossible").html(data["main_content"]); $("#commonModal").html(data["main_content"]); } else { if (data["main_content"] != "") { $("#commonModal").html(data["main_content"]); } } }, }); }); $(document).on("click", ".action-send-business-cancel-offer", function () { var user_id = $("#user_id").val(); var job_id = $("#job_id").val(); var helper = $("#helper").val(); var Send_melding = "N"; if ($("#chat_popup_info_helper").hasClass("col-Send-melding")) { $("#chat_popup_info_helper").removeClass("col-Send-melding"); var Send_melding = "Y"; } $(".action-send-business-cancel-offer").html("Vent.."); var url = "/messages/pullbackactionwithbusiness"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, Send_melding: Send_melding, only_return: "Y", }, dataType: "text", success: function (script_response) { $(".action-send-business-cancel-offer").html("Avslutt med visittkort"); var data = $.parseJSON(script_response); console.log(JSON.stringify(data)); if (data["success"] == "true") { if (data["main_content"] == "") { location.reload(); } $("#bannotpossible").html(data["main_content"]); $("#commonModal").html(data["main_content"]); } if (data["success"] == "false" && data["main_content"] != "") { $("#commonModal").html(data["main_content"]); } }, }); }); $(document).on("click", ".action-btn-reload", function () { window.location.href = "/messages"; }); $(document).on("click", ".action-confirm-pullback", function () { var user_id = $("#user_id").val(); var job_id = $("#job_id").val(); var helper = $("#helper").val(); $(".action-confirm-pullback").html("Vent.."); var url = "/messages/confirmpullbackaction"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { location.reload(); } else { } }, }); }); $(document).on("click", ".action-cancel-hire-status-confirm", function () { var user_id = $("#user_id").val(); var job_id = $("#job_id").val(); var helper = $("#helper").val(); $(".action-cancel-hire-status-confirm").html("Vent.."); var url = "/messages/confirmcancelhire"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { window.location.href = "/messages"; } else { } }, }); }); $(document).on( "click", ".sm-edit-transport-job input[name='to_or_from_norway'],.sm-edit-transport-job input[name='offshore_address'] ", function () { $("#tr_from_address").removeClass( "map-offshore-address-norway map-offshore-address-global" ); $("#tr_to_address").removeClass( "map-offshore-address-norway2 map-offshore-address-global2" ); $("#tr_from_address").val(""); $("#tr_to_address").val(""); var to_or_from_norway = $("input[name='to_or_from_norway']:checked").val(); if (to_or_from_norway == "Yes") { var offshore_address = $("input[name='offshore_address']:checked").val(); if (offshore_address == "To") { $("#tr_from_address").addClass("map-offshore-address-norway"); $("#tr_to_address").addClass("map-offshore-address-global2"); } else { $("#tr_to_address").addClass("map-offshore-address-norway2"); $("#tr_from_address").addClass("map-offshore-address-global"); } } else { $("#tr_from_address").addClass("map-offshore-address-norway"); $("#tr_to_address").addClass("map-offshore-address-norway2"); } $(document).one("keyup", ".map-offshore-address-norway", function () { $("#googleidsearch").val(this.id); globalinitMap_norway(); }); $(document).one("keyup", ".map-offshore-address-norway2", function () { $("#googleidsearch").val(this.id); globalinitMap_norway(); }); $(document).one("keyup", ".map-offshore-address-global", function () { $("#googleidsearch").val(this.id); globalinitMap_global(); }); $(document).one("keyup", ".map-offshore-address-global2", function () { $("#googleidsearch").val(this.id); globalinitMap_global(); }); } ); $(document).on( "click", "#to_or_from_norway_Yes,#to_or_from_norway_No", function () { var to_or_from_norway = $("input[name='to_or_from_norway']:checked").val(); if (to_or_from_norway == "Yes") { $(".sm_offshore_address").show(); } else { $(".sm_offshore_address").hide(); } desk_show_hide_location_1(); } ); function desk_show_hide_location_1() { var to_or_from_norway = $("input[name='to_or_from_norway']:checked").val(); if (to_or_from_norway == "Yes") { $("input[id='location_status_1']").prop("checked", true); $(".location_status_yes").hide(); $("input[id='location_status_1']").trigger("change"); } else { $(".location_status_yes").show(); } } $(document).on( "keypress", ".map-offshore-address-norway,.map-offshore-address-norway2", function () { var idsearch = this.id; var idds = $("#" + idsearch + "").attr("data-id"); $("#" + idds + "").val(""); var idd = idsearch + "_administrative_area_level_1"; document.getElementById(idd).value = ""; } ); $(document).on("keypress", ".geo-address", function () { var idsearch = this.id; var idds = $("#" + idsearch + "").attr("data-id"); $("#" + idds + "").val(""); var idd = idsearch + "_administrative_area_level_1"; console.log("idd", idd); document.getElementById(idd).value = ""; }); $(document).on("click", ".action-close-publish-popup", function () { $("#publish-job").modal("hide"); }); $(document).on( "blur", ".map-offshore-address-norway,.map-offshore-address-norway2,.map-offshore-address-global,.map-offshore-address-global2,.geo-address,.geo-address2", function () { var idsearch = this.id; setTimeout(function () { check_locationNotFound(idsearch); }, 1500); } ); $(document).on("hide.bs.modal", "#locationNotFound", function () { setTimeout(function () { var postal_code_input = $(".action-zipcode-submit").attr( "postal_code_input" ); var postal_code_idsearch = $(".action-zipcode-submit").attr( "postal_code_idsearch" ); var postal_code = $("#" + postal_code_input + "").val(); if (postal_code == "") { var postal_code_idsearch_val = $("#" + postal_code_idsearch + "").val(); $("#" + postal_code_idsearch + "").val(""); } }, 200); }); $(document).on("click", ".action-zipcode-submit", function () { var postal_code_input = $(".action-zipcode-submit").attr("postal_code_input"); var get_zipcode = $("#get_zipcode").val(); $("#" + postal_code_input + "").val(get_zipcode); $("#locationNotFound").modal("hide"); $("#get_zipcode").val(""); }); function check_locationNotFound(idsearch) { console.log("check_locationNotFound:", idsearch); var idds = $("#" + idsearch + "").attr("data-id"); var postal_code = $("#" + idds + "").val(); var valLocation = $("#" + idsearch + "").val(); var DeviceType = $("body").attr("data-DeviceType"); if (DeviceType == "mobile") { var location_status = $('input[name = "location_status"]').val(); } else { var location_status = $('input[name = "location_status"]:checked').val(); } if (typeof location_status == "undefined") { location_status = ""; } console.log("postal_code:", postal_code); console.log("valLocation:", valLocation); if (postal_code == "" && valLocation != "") { $(".action-zipcode-submit").attr("postal_code_idsearch", idsearch); $(".action-zipcode-submit").attr("postal_code_input", idds); $("#locationNotFound").modal(); } } $(document).one("keyup", ".map-offshore-address-norway", function () { $("#googleidsearch").val(this.id); globalinitMap_norway(); }); $(document).one("keyup", ".map-offshore-address-norway2", function () { $("#googleidsearch").val(this.id); globalinitMap_norway(); }); $(document).one("keyup", ".map-offshore-address-global", function () { $("#googleidsearch").val(this.id); globalinitMap_global(); }); $(document).one("keyup", ".map-offshore-address-global2", function () { $("#googleidsearch").val(this.id); globalinitMap_global(); }); function globalinitMap_norway() { var idsearch = document.getElementById("googleidsearch").value; autocomplete = new google.maps.places.Autocomplete( document.getElementById("" + idsearch + ""), { componentRestrictions: countryRestrict, } ); autocomplete.addListener("place_changed", fillInAddress_offshore_norway); custom_msg_autocomplete(); } function globalinitMap_global() { var idsearch = document.getElementById("googleidsearch").value; autocomplete = new google.maps.places.Autocomplete( document.getElementById("" + idsearch + ""), {} ); autocomplete.addListener("place_changed", fillInAddress_offshore_global); custom_msg_autocomplete(); } function fillInAddress_offshore_norway() { var idsearch = document.getElementById("googleidsearch").value; var idds = $("#" + idsearch + "").attr("data-id"); $("#" + idds + "").val(""); var idd = idsearch + "_administrative_area_level_1"; document.getElementById(idd).value = ""; var place = autocomplete.getPlace(); if (idsearch == "tr_to_address") { $("#to_lat").val(place.geometry.location.lat()); $("#to_lng").val(place.geometry.location.lng()); } else { $("#lat").val(place.geometry.location.lat()); $("#lng").val(place.geometry.location.lng()); } if ( place.address_components !== undefined && place.address_components.length > 0 ) { for (var i = 0; i < place.address_components.length; i++) { var addressType = place.address_components[i].types[0]; if (componentForm[addressType]) { var val = place.address_components[i][componentForm[addressType]]; if (addressType == "postal_code") { var idds = $("#" + idsearch + "").attr("data-id"); $("#" + idds + "").val(val); $("#" + idds + "_label").hide(); $("input[name='" + idds + "']").attr("type", "hidden"); } else if (addressType == "administrative_area_level_1") { var idd = idsearch + "_" + addressType; document.getElementById(idd).value = val; if (val != "") { var idds = $("#" + idsearch + "").attr("data-id"); $("#" + idds + "_label").hide(); $("input[name='" + idds + "']").attr("type", "hidden"); } } else { var idd = idsearch + "_administrative_area_level_1"; if (document.getElementById(idd).value == "") { document.getElementById(idd).value = val; } } } } } check_locationNotFound(idsearch); } $(document).on("click", ".btn-service-deny-request", function () { $("#div-service-deny-request").modal("show"); }); $(document).on("click", "#btn-service-avbryt", function () { $("#div-service-deny-request").modal("hide"); }); $(document).on("click", "#btn-service-invitasjon", function () { $("#btn-service-invitasjon").html("Vent.."); var invite_id = $("#invite_id").val(); var user_id = $("#user_id").val(); var job_id = $("#job_id").val(); var helper = $("#helper").val(); var helper_user_id = $("#helper_user_id").val(); var url = "/services/service_invitasjon"; $.ajax({ url: url, method: "POST", data: { invite_id: invite_id, user_id: user_id, helper_user_id: helper_user_id, job_id: job_id, helper: helper, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { location.reload(); } else { alert("Feil: Noe gikk galt. Prøv igjen."); } }, }); }); function fillInAddress_offshore_global() { var idsearch = document.getElementById("googleidsearch").value; var idds = $("#" + idsearch + "").attr("data-id"); $("#" + idds + "").val(""); var idd = idsearch + "_administrative_area_level_1"; document.getElementById(idd).value = ""; var place = autocomplete.getPlace(); if (idsearch == "tr_to_address") { $("#to_lat").val(place.geometry.location.lat()); $("#to_lng").val(place.geometry.location.lng()); } else { $("#lat").val(place.geometry.location.lat()); $("#lng").val(place.geometry.location.lng()); } if ( place.address_components !== undefined && place.address_components.length > 0 ) { for (var i = 0; i < place.address_components.length; i++) { var addressType = place.address_components[i].types[0]; if (componentForm[addressType]) { var val = place.address_components[i][componentForm[addressType]]; if (addressType == "postal_code") { var idds = $("#" + idsearch + "").attr("data-id"); $("#" + idds + "").val(val); } else if (addressType == "administrative_area_level_1") { var idd = idsearch + "_" + addressType; document.getElementById(idd).value = val; } else { var idd = idsearch + "_administrative_area_level_1"; if (document.getElementById(idd).value == "") { document.getElementById(idd).value = val; } } } } } check_locationNotFound(idsearch); } $(document).on("click", "#contact_me_directly", function () { var contact_me_directly = $("#contact_me_directly:checked").val(); if (contact_me_directly == "Y") { $(".contact_me_directly_div").show(); } else { $(".contact_me_directly_div").hide(); } }); $(document).on("change", 'input[name="payment_job_type"]', function () { var val = $(this).val(); if (val == "inspection") { $(".show-if-ispe").show(); $(".hide-if-ispe").hide(); } else { $(".show-if-ispe").hide(); $(".hide-if-ispe").show(); } }); var geocoder; var map; function map_page_initMap() { var map = new google.maps.Map(document.getElementById("map"), { zoom: 6, center: { lat: 60.472, lng: 8.4689, }, }); geocoder = new google.maps.Geocoder(); map_page_codeAddress(geocoder, map); } function map_page_codeAddress(geocoder, map) { setTimeout(function () { var address = document.getElementById("map_page_geo_address").value; geocoder.geocode( { address: address, }, function (results, status) { if (status === "OK") { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location, draggable: false, }); } else { } } ); }, 500); } $(document).one("keyup", ".map-page-geo-address", function () { map_page_initMap4(); }); function map_page_initMap4() { autocomplete = new google.maps.places.Autocomplete( document.getElementById("map_page_geo_address"), { componentRestrictions: countryRestrict, types: ["establishment"], } ); autocomplete.addListener("place_changed", map_page_fillInAddress); custom_msg_autocomplete(); } function map_page_fillInAddress() { var place = autocomplete.getPlace(); var idsearch = "map_page_geo_address"; map_page_initMap(); $("#lat").val(place.geometry.location.lat()); $("#lng").val(place.geometry.location.lng()); if ( place.address_components !== undefined && place.address_components.length > 0 ) { for (var i = 0; i < place.address_components.length; i++) { var addressType = place.address_components[i].types[0]; if (componentForm[addressType]) { var val = place.address_components[i][componentForm[addressType]]; if (addressType == "postal_code") { $("#map_page_geo_zipcode").val(val); } } } } } $(document).on("click", ".set-map", function () { var map_address = $("#map_page_geo_address").val(); var map_zipcode = $("#map_page_geo_zipcode").val(); var lat = $("#lat").val(); var lng = $("#lng").val(); var url = "/browse/setMap"; $(".set-map").html("Vent.."); $.ajax({ url: url, method: "POST", data: { map_address: map_address, map_zipcode: map_zipcode, lat: lat, lng: lng, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".set-map").html("Lagre adresse"); if (data["success"] == "true") { window.location.href = "/finn"; } else { alert(data["message"]); } }, }); }); $(document).on("click", ".set-setting", function () { var distance = $("#myRange").val(); var filter_jobtype_id = []; $("input:checkbox[name='jobtype_id']:checked").each(function () { var vals = $(this).val(); filter_jobtype_id.push(vals); }); $("#search-title-mobile").val(""); var url = "/browse/setSetting"; $.ajax({ url: url, method: "POST", data: { distance: distance, filter_jobtype_id: filter_jobtype_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $(".applyfilter").trigger("click"); } else { alert(data["message"]); } }, }); }); $(document).on("click", ".close-btn-filter", function () { $(".search-holder,.new-filters").slideUp(); }); $(document).on("click", ".close-filter-search-all", function () { $("#search-title-mobile").val(""); currentpage = 1; $("#currentpage").val(currentpage); $("input:checkbox[name='jobtype_id']").prop("checked", false); var distance = 0; var filter_jobtype_id = []; $("#search-title-mobile").val(""); var url = "/browse/setSetting"; $.ajax({ url: url, method: "POST", data: { distance: distance, filter_jobtype_id: filter_jobtype_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $(".applyfilter").trigger("click"); } else { alert(data["message"]); } }, }); setTimeout(function () { filterMobile(); }, 500); }); $("#search-title-mobile").keydown(function (e) { if (e.keyCode == 13) { currentpage = 1; $("#currentpage").val(currentpage); $(".applyfilter").trigger("click"); } }); $(".search-btn").click(function () { $("#search-title-mobile").val(""); $("#search-title-mobile-service").val(""); $(".search-holder,.new-filters").slideUp(); }); $("#search-title").keydown(function (e) { if (e.keyCode == 13) { currentpage = 1; $("#currentpage").val(currentpage); $(".action-search-data-filter").trigger("click"); } }); function filterMobile() { var DeviceType = $("body").attr("data-DeviceType"); if (DeviceType == "mobile") { var data_login = $("body").attr("data-login"); var search_title = $("#search-title").val(); var myRange = (distance = $("#myRange").val()); if (myRange === undefined || myRange === null) { myRange = distance = 50; } var map_address = $("#map_page_geo_address_desk").val(); var map_zipcode = $("#map_page_geo_zipcode").val(); var lat = $("#lat").val(); var lng = $("#lng").val(); var statusProfessional = $( "input:checkbox[name='statusProfessional']:checked" ).val(); var statusSmallJob = $( "input:checkbox[name='statusSmallJob']:checked" ).val(); if ( statusProfessional === undefined || statusProfessional === null || statusProfessional == "" ) { statusProfessional = ""; } if ( statusSmallJob === undefined || statusSmallJob === null || statusSmallJob == "" ) { statusSmallJob = ""; } var orderby = $(".action-sortby-filter.active").attr("data-orderby"); var filter_jobtype = []; $("input:checkbox[name='jobtype']:checked").each(function () { var vals = $(this).val(); filter_jobtype.push(vals); }); var map_address = $("#map_page_geo_address_desk").val(); var currentpage = $("#currentpage").val(); if ( currentpage === undefined || currentpage === null || currentpage == "" ) { currentpage = 1; } $("#currentpage").val(currentpage); manage_url(currentpage); if (statusProfessional != "" && statusSmallJob != "") { $(".filter-information-Prof").html("PRO & Småjobber"); } else if (statusProfessional != "") { $(".filter-information-Prof").html("Kun PRO"); } else if (statusSmallJob != "") { $(".filter-information-Prof").html("Kun Småjobber"); } else { $(".filter-information-Prof").html(""); } /*searchjobfilter*/ if (map_address == "") { if (data_login == "login-yes") { var login_data = "

Vi ser ikke hvor du er

Tast inn stedet du befinner
deg for å se avstand.

"; } else { /* /innlogging */ var login_data = '

Vi ser ikke hvor du er

Logg inn eller skriv adressen i feltet nedenfor

'; } var state_list = ""; $("#searchjobfilter").html( '
' + login_data + '
' + state_list + "
" ); } else { $("#searchjobfilter").html( '

Juster avstand for søket

' + myRange + ' km luftlinje fra ' + map_address + '

' ); } /*searchjobfilter*/ /*job_filter_content*/ var html_job_filter_content = ""; var search_input = 0; if (distance != "" && map_address != "") { /* search_input = 1; html_job_filter_content += '
'; */ } if (search_title != "") { search_input = 1; html_job_filter_content += '
'; } $(".action-count-jobtype").each(function () { var vals = $(this).html(); if (parseInt(vals) > 0) { search_input = 1; var icon = $(this).attr("data-icon"); var jobtype_id = $(this).attr("data-jobtype_id"); html_job_filter_content += '
'; } }); if (search_input == 0) { html_job_filter_content += '
Alle oppdrag
'; } $("#job_filter_content").html(html_job_filter_content); /*job_filter_content*/ /* if (map_address != "") { $(".sortby-filter-4").css("display", ""); } else { $(".sortby-filter-4").css("display", "none"); } */ if (parseInt(filter_jobtype.length) > 0) { $("#action-typeJobModal").html( '' + filter_jobtype.length + "" ); $("#action-typeJobModal").addClass("active"); } else { $("#action-typeJobModal").removeClass("active"); $("#action-typeJobModal").html(""); } if (orderby != "") { $("#action-sorteringModal").addClass("active"); } else { $("#action-sorteringModal").removeClass("active"); } if (search_title != "") { $("#action-searchModal").addClass("active"); } else { $("#action-searchModal").removeClass("active"); } /*if(statusProfessional=="1" || statusSmallJob=="1"){*/ if (statusProfessional == "1") { $("#action-jobTypeModal").addClass("active"); } else { $("#action-jobTypeModal").removeClass("active"); } var url = "/browse/filter_mobile"; $.ajax({ url: url, method: "POST", data: { search_title: search_title, filter_jobtype: filter_jobtype, myRange: myRange, map_address: map_address, map_zipcode: map_zipcode, lat: lat, lng: lng, statusProfessional: statusProfessional, statusSmallJob: statusSmallJob, orderby: orderby, currentpage: currentpage, DeviceType: DeviceType, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#job_results").html(data["main_content"]); $(document).one("keyup", ".map-page-geo-address-desk", function () { $("#googleidsearch").val(this.id); globalinitMap_browse(); }); heightImage(); if (localStorage.getItem("mobile-job-quote-scroll") != null) { setTimeout(function () { $("html, body").animate( { scrollTop: localStorage.getItem("mobile-job-quote-scroll") }, 800 ); }, 500); } } }, }); } } $(document).on("click", ".pagination-2 a,.pagination-2 button", function () { $("html, body").animate({ scrollTop: 0 }, 800); localStorage.removeItem("mobile-job-quote-scroll"); var currentpage = $(this).attr("currentpage"); if (currentpage === undefined || currentpage === null) { return false; } $("#currentpage").val(currentpage); filterMobile(); }); function heightImage() { var cw = $(".image-holder").width(); $(".image-holder").css({ height: cw + "px", }); } heightImage(); $(document).on("click", ".btn-close-block", function () { $(".modal").modal("hide"); var stex_popupstrex = $("#stex_popupstrex").attr("pre_id"); $("#" + stex_popupstrex + "").modal("show"); }); $(document).on("click", ".action-deny-job-content", function () { $(".btn-type-action").removeClass("active"); $(this).addClass("active"); var type = $(this).attr("data-type"); var content = $(this).attr("data-content"); $("#type").val(type); $("#message").val(content); $("#un_message_show").show(); $("#un_price_show").hide(); }); $(document).on("click", ".action-change-password", function () { $("#un_job_description_show").hide(); $("#un_message_show").hide(); $("#un_price_show").show(); }); $(document).on("click", ".action-change-job-text", function () { $("#un_message_show").hide(); $("#un_price_show").hide(); $("#un_job_description_show").show(); }); $(document).on("click", ".btn-deny-Job", function () { $(".btn-type-action").removeClass("active"); $(this).addClass("active"); var type = $(this).attr("data-type"); $("#type").val(type); $("#message").val( "Annonser for småjobber er reservert oppdrag som ønskes utført men du kan opprette en søkbar hjelperprofil og beskrive tjenester du tilbyr der. - Oppdragsgivere kan da søke deg opp og kontakte deg med oppdrag. Vi beklager det ekstra bryderiet." ); }); $(document).on("click", ".btn-price-message", function () { $(".btn-type-action").removeClass("active"); $(this).addClass("active"); var type = $(this).attr("data-type"); $("#type").val(type); $("#message").val( "Prisen må gjenspeile det hjelperen kan forvente å tjene på oppdraget. Vi må derfor be deg endre prisen til det du mener er rett for jobben eller en sum du forventer å måtte betale. Vi beklager det ekstra bryderiet." ); }); $(document).on("click", ".btn-info-message", function () { $(".btn-type-action").removeClass("active"); $(this).addClass("active"); var type = $(this).attr("data-type"); $("#type").val(type); $("#message").val( "Vi må be deg ta bort kontaktinfo i annonsen. Du vil bli varslet på SMS og e-post når hjelpere tar kontakt. Vi beklager det ekstra bryderiet." ); }); $(document).on("click", ".action-make-pro", function () { $(".btn-type-action").removeClass("active"); $(this).addClass("active"); var type = $(this).attr("data-type"); $("#type").val(type); $("#message").val( "Vi har vurdert dette oppdraget som et PRO-oppdrag og har endret oppføringen slik at kun bedrifter kan søke. Kontakt kundeservice om du er uenig i avgjørelsen." ); }); $(document).on("click", ".btn-self_approve-message", function () { $("#message").val( "Selvbetjent godkjenning er deaktivert etter at du tidligere har godkjent jobbannonser som ikke oppfylte våre krav. Kontakt kundeservice om spørsmål." ); }); /* $(document).on("click", ".action-chat-appointment", function () { var helper = $(".selected-listing").attr("data-helper"); if (helper == "Y") { var devicetype = $("body").attr("data-devicetype"); if (devicetype == "mobile") { $("#job-details-info").show(); $("#chatdata").hide(); } var pannel_111 = $("#fire-emp-pannel_111").html(); if (pannel_111 != "" && typeof pannel_111 !== "undefined") { $("#commonModal").html(pannel_111); $("#commonModal").modal("show"); } content_type = ""; } }); */ $(document).on("click", ".action-request-rating", function () { var job_id = $(".selected-listing").attr("data-job_id"); window.location.href = "/rating/" + job_id; }); $(document).on("click", ".action-chat-appointment-fist-option", function () { var devicetype = $("body").attr("data-devicetype"); if (devicetype == "mobile") { console.log("devicetype=", devicetype); if ($("#job-details-info").length) { $("#job-details-info").show(); $("#chatdata").hide(); } } console.log("get popup up hire - 1"); var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var first_name = $(".selected-listing").attr("data-first_name"); var help_id = $(".selected-listing").attr("data-help_id"); var type = $(".selected-listing").attr("data-type"); var url = "/messages/actionHireHelperGetPopupFirst"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, first_name: first_name, help_id: help_id, type: type, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { /*$(".selected-listing").trigger("click");*/ selected_listing_trigger_click(1002); $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); console.log("Send chat_message_refresh_2 - 14"); socket.emit("chat_message_refresh_2", { job_id: job_id, help_id: help_id, timestamp: new Date().toISOString(), }); } }, }); if (!$(".action-hire-emp-pannel-k")[0]) { var job_id = $(".selected-listing").attr("data-job_id"); var help_id = $(".selected-listing").attr("data-help_id"); var url = "/messages/found_another_pending_agreement"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, help_id: help_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal("show"); } else if (data["popup_trigger"] == "true") { $(".action-cancel-hire-approval").trigger("click"); } }, }); } }); $(document).on("click", ".action-hire-emp-step-0-back", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var first_name = $(".selected-listing").attr("data-first_name"); var help_id = $(".selected-listing").attr("data-help_id"); var type = $(".selected-listing").attr("data-type"); var url = "/messages/actionHireHelperGetPopupFirst"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, first_name: first_name, help_id: help_id, type: type, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { /*$(".selected-listing").trigger("click");*/ selected_listing_trigger_click(1003); $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); }); $(document).on("click", ".action-hire-helper-0", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var first_name = $(".selected-listing").attr("data-first_name"); var help_id = $(".selected-listing").attr("data-help_id"); var type = $(".selected-listing").attr("data-type"); var agreement_type_first = $( "input[name='agreement_type_first']:checked" ).val(); console.log("agreement_type_first : ", agreement_type_first); console.log("helper : ", helper); if (agreement_type_first == 1) { $(".action-inspection-chat").trigger("click"); } else if (agreement_type_first == 2) { if (helper == "Y") { $(".action-chat-appointment").trigger("click"); } else { $(".action-hire-help-pannel-k").trigger("click"); } } /* var url = "/messages/actionHireHelperGetPopupSecond"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, first_name: first_name, help_id: help_id, type: type, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $(".selected-listing").trigger("click"); $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); */ }); $(document).on("click", ".action-chat-appointment", function () { var helper = $(".selected-listing").attr("data-helper"); if (helper == "Y") { var devicetype = $("body").attr("data-devicetype"); if (devicetype == "mobile") { console.log("devicetype=", devicetype); if ($("#job-details-info").length) { $("#job-details-info").show(); $("#chatdata").hide(); } } $(".action-hire-emp-pannel-k").trigger("click"); /**/ if (!$(".action-hire-emp-pannel-k")[0]) { var job_id = $(".selected-listing").attr("data-job_id"); var help_id = $(".selected-listing").attr("data-help_id"); var url = "/messages/found_another_pending_agreement"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, help_id: help_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal("show"); } else if (data["popup_trigger"] == "true") { $(".action-cancel-hire-approval").trigger("click"); } }, }); } /**/ } }); /**/ $(document).on("click", ".action-hire-emp-pannel-k-next", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var first_name = $(".selected-listing").attr("data-first_name"); var help_id = $(".selected-listing").attr("data-help_id"); var type = $(".selected-listing").attr("data-type"); var url = "/messages/found_another_pending_agreement_confirm"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, first_name: first_name, help_id: help_id, type: type, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { /*$(".selected-listing").trigger("click");*/ selected_listing_trigger_click(1004); setTimeout(function () { $(".action-hire-emp-pannel-k").trigger("click"); }, 1000); console.log("Send chat_message_refresh_2 - 15"); socket.emit("chat_message_refresh_2", { job_id: job_id, help_id: help_id, timestamp: new Date().toISOString(), }); /* $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); */ } }, }); }); /**/ $(document).on("click", ".action-request-agreement", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var help_id = $(".selected-listing").attr("data-help_id"); var url = "/messages/get_request_agreement_1"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, help_id: help_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["chat_content"]); $("#commonModal").modal("show"); } }, }); }); $(document).on("click", ".action-req-agr-confirm", function () { $(".action-req-agr-confirm").html("Vent.."); var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var help_id = $(".selected-listing").attr("data-help_id"); var url = "/messages/get_request_agreement_2"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, help_id: help_id, }, dataType: "text", success: function (script_response) { $(".action-req-agr-confirm").html( ' Send' ); var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").modal("hide"); /*$(".selected-listing").trigger("click");*/ selected_listing_trigger_click(1005); } else if (data["message"] != "") { $("#commonModal .popup-response-msg").html( "
" + data["message"] + "
" ); setTimeout(function () { $("#commonModal .response-msg").html(""); }, 6000); } }, }); }); /* get popup content normaly */ $(document).on("click", ".btn_readContract", function () { var content_type = $(this).attr("data-contentpopup"); if (content_type != "") { var url = "/messages/getcontractcontent"; $.ajax({ url: url, method: "POST", data: { content_type: content_type, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#readContract").html(data["chat_content"]); $("#readContract").modal("show"); } }, }); } }); $(document).on("click", ".btn_upload_attachment", function () { console.log("trigger uploaded"); $(".upload_attachment").trigger("click"); }); $(document).on("change", ".upload_attachment", function () { $("#loadingImage .progress-bar").css("width", "0"); $("#loadingImage .action-btn-close-upload").hide(); $("#img_job_error").html(""); var file_data = $("#upload_attachment").prop("files")[0]; if (file_data != "") { $("#loadingImage").modal("show"); $("#loadingImage .progress-bar").css("width", "0"); var job_id = $(".selected-listing").attr("data-job_id"); var form_data = new FormData(); form_data.append("file", file_data); form_data.append("type", "file"); form_data.append("job_id", job_id); $.ajax({ url: "/ajax/upload_attachment", data: form_data, processData: false, contentType: false, type: "POST", xhr: function () { var xhr = new window.XMLHttpRequest(); xhr.upload.addEventListener( "progress", function (evt) { if (evt.lengthComputable) { var percentComplete = evt.loaded / evt.total; percentComplete = parseInt(percentComplete * 100); $("#loadingImage .progress-bar").text(percentComplete + "%"); $("#loadingImage .progress-bar").css( "width", percentComplete + "%" ); } }, false ); return xhr; }, success: function (php_script_response) { /*response*/ var data = jQuery.parseJSON(php_script_response); if (php_script_response != "") { if (data["success"] == "true") { setTimeout(function () { var message = data["attachment"]; var file_size = data["file_size"]; var user_id = $("#user_id").val(); var job_id = $("#job_id").val(); var helper = $("#helper").val(); var Send_melding = "Y"; var messagetype = "attachment"; var url = "/messages/storechat"; $.ajax({ url: url, method: "POST", data: { message: message, user_id: user_id, job_id: job_id, file_size: file_size, helper: helper, Send_melding: Send_melding, messagetype: messagetype, }, dataType: "text", success: function (script_response) { $("#loadingImage").modal("hide"); $("#loadingImage .progress-bar").css("width", "0"); $(".selected-listing").trigger("click"); console.log("Send chat_message_refresh_2 - 15"); socket.emit("chat_message_refresh_2", { job_id: job_id, help_id: help_id, timestamp: new Date().toISOString(), }); var element = document.getElementById("chat-content-data"); element.scrollTop = element.scrollHeight; }, }); }, 500); /******************/ } else { $("#img_job_error").html( '
' + data["msg"] + "
" ); setTimeout(function () { $("#loadingImage .action-btn-close-upload").show(); //$("#loadingImage").modal("hide"); //$("#loadingImage .progress-bar").css("width", "0"); }, 500); } } }, }); } }); if ($(".applyfilter").length) { setTimeout(function () { $(".search-holder,.new-filters").slideUp(); filterMobile(); }, 100); } function playMsgSound() { var media = document.getElementById("messagesound"); const playPromise = media.play(); if (playPromise !== null) { playPromise.catch(() => { media.play(); }); } } $(".btntest").click(function () { playMsgSound(); }); $("#footer-menu-dropdown").on("click", function () { $(this).toggleClass("opened"); if ($("#footer-dropdown").hasClass("show")) { $(this).removeClass("opened"); } }); $("#footer-dropdown button").on("click", function () { $("#footer-menu-dropdown").removeClass("opened"); }); $(document).mouseup(function (e) { if ($("#footer-dropdown").hasClass("show")) { $("#footer-menu-dropdown").removeClass("opened"); } }); /*.modal .close,*/ $(document).on("click", ".action-popup-close", function () { console.log("close.."); $(".modal").modal("hide"); $("#commonModal").modal("hide"); var qqq = $(this).closest(".modal"); }); $(document).on("click", ".btn-service-accept-request", function () { var job_id = $(".selected-listing").attr("data-job_id"); var invite_id = $(".selected-listing").attr("data-invite_id"); $(".job_id").val(job_id); $(".invite_id").val(invite_id); var url = "/messages/invite_offerhelp"; /* var job_id = $(this).attr('data-id'); */ /* var invite_id = $("#invite_id").val(); */ var url = "/browse/fundoption"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, invite_id: invite_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#payment-option-modal").html(data["main_content"]); $("#payment-option-modal").modal(); } else { window.location.href = "/innlogging"; } }, }); }); $("#faqAccordion .card-header .btn").mouseover(function () { $(this).click(); }); $(document).on("click", ".close-popup", function () { $("#model-cancel-the-job").modal("hide"); }); /******* cancel job jobowner *******/ $(document).on("click", ".action-cancel-the-job", function () { var job_id = $(this).attr("data-job_id"); var url = "/user/myjobs/cancel_the_job"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { /* $("#model-cancel-the-job").html(data["main_content"]); $("#model-cancel-the-job").modal(); */ $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); }); $(document).on("click", ".action-cancel-the-job-step-2", function () { $(".action-cancel-the-job-step-2").html("Vent.."); var job_id = $(this).attr("data-job_id"); var cansellationReason = $( "input:radio[name='cansellationReason']:checked" ).val(); if (typeof cansellationReason == "undefined") { cansellationReason = ""; } var url = "/user/myjobs/cancel_the_job_step_2"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, cansellationReason: cansellationReason, }, dataType: "text", success: function (script_response) { $(".action-cancel-the-job-step-2").html("Videre"); var data = $.parseJSON(script_response); if (data["success"] == "true") { /* $("#model-cancel-the-job").html(data["main_content"]); */ if (data["reditect"] == "true") { location.reload(); } else { $("#commonModal").html(data["main_content"]); } } else { $("#res_msg").html( '
' + data["message"] + "
" ); setTimeout(function () { $("#res_msg").html(""); }, 2500); } }, }); }); $(document).on("click", ".action-cancel-the-job-step-3", function () { $(".action-cancel-the-job-step-3").html("Vent.."); var job_id = $(this).attr("data-job_id"); var cansellationReason = $("input[name='cansellationReason']").val(); if (typeof cansellationReason == "undefined") { cansellationReason = ""; } var textCansellationReason = $( "textarea[name='textCansellationReason']" ).val(); if (typeof textCansellationReason == "undefined") { textCansellationReason = ""; } var url = "/user/myjobs/cancel_the_job_step_3"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, cansellationReason: cansellationReason, textCansellationReason: textCansellationReason, }, dataType: "text", success: function (script_response) { $(".action-cancel-the-job-step-3").html("Videre"); var data = $.parseJSON(script_response); if (data["success"] == "true") { /* if (data["cansellationReason"] == "Jobowner") { location.reload(); } else { $("#model-cancel-the-job").html(data["main_content"]); } */ /* $("#model-cancel-the-job").html(data["main_content"]); */ $("#commonModal").html(data["main_content"]); } else { $("#res_msg").html( '
' + data["message"] + "
" ); setTimeout(function () { $("#res_msg").html(""); }, 2500); } }, }); }); $(document).on("click", ".action-cancel-the-job-step-4", function () { $(".action-cancel-the-job-step-4").html("Vent.."); var job_id = $(this).attr("data-job_id"); var cansellationReason = $("input[name='cansellationReason']").val(); if (typeof cansellationReason == "undefined") { cansellationReason = ""; } var textCansellationReason = $("input[name='textCansellationReason']").val(); if (typeof textCansellationReason == "undefined") { textCansellationReason = ""; } var url = "/user/myjobs/cancel_the_job_step_4"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, cansellationReason: cansellationReason, textCansellationReason: textCansellationReason, }, dataType: "text", success: function (script_response) { $(".action-cancel-the-job-step-4").html("Avslutt"); var data = $.parseJSON(script_response); if (data["success"] == "true") { location.reload(); } else { $("#res_msg").html( '
' + data["message"] + "
" ); setTimeout(function () { $("#res_msg").html(""); }, 2500); } }, }); }); /******* cancel job jobowner *******/ /******* cancel job helper *******/ $(document).on("click", ".action-helper-cancel-the-job", function () { var job_id = $(this).attr("data-job_id"); var url = "/user/myjobs/helper_cancel_the_job"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); }); $(document).on("click", ".action-helper-cancel-the-job-step-2", function () { $(".action-helper-cancel-the-job-step-2").html("Vent.."); var job_id = $(this).attr("data-job_id"); var cansellationReason = $( "input:radio[name='cansellationReason']:checked" ).val(); if (typeof cansellationReason == "undefined") { cansellationReason = ""; } var url = "/user/myjobs/helper_cancel_the_job_step_2"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, cansellationReason: cansellationReason, }, dataType: "text", success: function (script_response) { $(".action-helper-cancel-the-job-step-2").html("Videre"); var data = $.parseJSON(script_response); if (data["success"] == "true") { if (data["redirect"] == "true") { location.reload(); } else { $("#commonModal").html(data["main_content"]); } } else { $("#res_msg").html( '
' + data["message"] + "
" ); setTimeout(function () { $("#res_msg").html(""); }, 2500); } }, }); }); $(document).on("click", ".action-helper-cancel-the-job-step-3", function () { $(".action-helper-cancel-the-job-step-3").html("Vent.."); var job_id = $(this).attr("data-job_id"); var cansellationReason = $("input[name='cansellationReason']").val(); if (typeof cansellationReason == "undefined") { cansellationReason = ""; } var textCansellationReason = $( "textarea[name='textCansellationReason']" ).val(); if (typeof textCansellationReason == "undefined") { textCansellationReason = ""; } var url = "/user/myjobs/helper_cancel_the_job_step_3"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, cansellationReason: cansellationReason, textCansellationReason: textCansellationReason, }, dataType: "text", success: function (script_response) { $(".action-helper-cancel-the-job-step-3").html("Videre"); var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); } else { $("#res_msg").html( '
' + data["message"] + "
" ); setTimeout(function () { $("#res_msg").html(""); }, 2500); } }, }); }); $(document).on("click", ".action-helper-cancel-the-job-step-4", function () { $(".action-helper-cancel-the-job-step-4").html("Vent.."); var job_id = $(this).attr("data-job_id"); var cansellationReason = $("input[name='cansellationReason']").val(); if (typeof cansellationReason == "undefined") { cansellationReason = ""; } var textCansellationReason = $("input[name='textCansellationReason']").val(); if (typeof textCansellationReason == "undefined") { textCansellationReason = ""; } var url = "/user/myjobs/helper_cancel_the_job_step_4"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, cansellationReason: cansellationReason, textCansellationReason: textCansellationReason, }, dataType: "text", success: function (script_response) { $(".action-helper-cancel-the-job-step-4").html("Ferdig"); var data = $.parseJSON(script_response); if (data["success"] == "true") { location.reload(); } else { $("#res_msg").html( '
' + data["message"] + "
" ); setTimeout(function () { $("#res_msg").html(""); }, 2500); } }, }); }); /******* cancel job helper *******/ /* $(document).on("click", ".action-cancel-the-job-confirm", function () { $(".action-cancel-the-job-confirm").html("Vent.."); var job_id = $(this).attr("data-job_id"); var url = "/user/myjobs/cancel_the_job_confirm"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, }, dataType: "text", success: function (script_response) { $(".action-cancel-the-job-confirm").html("Kanseller"); var data = $.parseJSON(script_response); if (data["success"] == "true") { location.reload(); } }, }); }); */ $(document).on("change", "#jobtypeFrm input", function () { var jobtypeFrm = $("#jobtypeFrm").serialize(); var url = "/user/subscription/update_jobtype"; $.ajax({ url: url, method: "POST", data: { jobtypeFrm: jobtypeFrm, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { if ( data["redirect_url"] != "" && typeof data["redirect_url"] != "undefined" ) { window.location.href = "/" + data["redirect_url"]; } $("#model-cancel-the-job").html(data["main_content"]); $("#model-cancel-the-job").modal(); } }, }); }); $(document).on("click", ".action-subscription", function () { var url = "/user/subscription/subscription_step"; var type = $(this).attr("data-type"); var label = $(this).html(); var idval = $(this).attr("id"); $(this).html("Vent.."); $.ajax({ url: url, method: "POST", data: { type: type, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); $("#" + idval + "").html(label); } else if (data["success"] == "strex_active") { $("#strexPayment").trigger("change"); $("#pwastrexPayment").trigger("click"); setTimeout(function () { $("#" + idval + "").html(label); }, 2000); } else if (data["success"] == "reload") { location.reload(); $("#" + idval + "").html(label); } }, }); }); $(document).on("click", ".action-subscription-angre", function () { var url = "/user/subscription/subscription_step_angre"; var type = $(this).attr("data-type"); var label = $(this).html(); var idval = $(this).attr("id"); $(this).html("Vent.."); $.ajax({ url: url, method: "POST", data: { type: type, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); $("#" + idval + "").html(label); } }, }); }); $(document).on("click", ".action-subscription-angre-confirm", function () { var url = "/user/subscription/subscription_step"; var type = $("action-subscription-angre").attr("data-type"); var label = $("action-subscription-angre").html(); var idval = $("action-subscription-angre").attr("id"); $(this).html("Vent.."); $.ajax({ url: url, method: "POST", data: { type: type, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); $("#" + idval + "").html(label); } else if (data["success"] == "strex_active") { $("#strexPayment").trigger("change"); $("#pwastrexPayment").trigger("click"); setTimeout(function () { $("#" + idval + "").html(label); }, 2000); } else if (data["success"] == "reload") { location.reload(); /*$("#" + idval + "").html(label);*/ } }, }); }); $(document).on("change", "#profile_distance", function () { var url = "/user/subscription/update_range_data"; var profile_distance = $("#profile_distance").val(); $(".range-labels .active").html(profile_distance + " km"); $.ajax({ url: url, method: "POST", data: { profile_distance: profile_distance, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { } }, }); }); /*mobile*/ /*mobile*/ $(document).on("change", "#strexPayment", function () { callStrexPaymentActive(); }); $(document).on("click", "#pwastrexPayment", function () { callStrexPaymentActive(); }); $(document).on("click", ".action-generate-strex-pass", function () { var label = $(".action-generate-strex-pass").html(); $(".action-generate-strex-pass").html("Vent.."); var strexPayment = ""; var url = "/user/subscription/code_gen_strexpayment"; $.ajax({ url: url, method: "POST", data: { strexPayment: strexPayment, }, dataType: "text", success: function (script_response) { $(".action-generate-strex-pass").html(label); var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#transactionId").val(data["transactionId"]); $("#action-generate-strex-pass").html(data["strex_text"]); $("#action-generate-strex-pass").removeClass( "action-generate-strex-pass" ); } if (data["message"] != "") { $("#commonModal .response").html( '

' + data["message"] + "

" ); } }, }); }); function callStrexPaymentActive() { var strexPayment = $("#strexPayment:checked").val(); if (typeof strexPayment == "undefined") { strexPayment = ""; } var url = "/user/subscription/strexpayment"; $.ajax({ url: url, method: "POST", data: { strexPayment: strexPayment, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); if (data["strex_status"] == "1") { $("#strexPayment").prop("checked", true); $(".action-payment-check-status").addClass("checked"); } else { $("#strexPayment").prop("checked", false); $(".action-payment-check-status").removeClass("checked"); } } else if (data["message"] != "") { $("#commonModal .modal-body").html( '

' + data["message"] + '

' ); } }, }); } $(document).on("click", ".action-de-active-strex", function () { var strexPayment = $("#strexPayment:checked").val(); if (typeof strexPayment == "undefined") { strexPayment = ""; } $(".action-de-active-strex").html("Vent.."); var url = "/user/subscription/inactivestrexpayment"; $.ajax({ url: url, method: "POST", data: { strexPayment: strexPayment, }, dataType: "text", success: function (script_response) { $(".action-de-active-strex").html("Slå av Strex"); var data = $.parseJSON(script_response); if (data["success"] == "true") { if (data["strex_status"] == "1") { $("#strexPayment").prop("checked", true); $(".action-payment-check-status").addClass("checked"); } else { $("#strexPayment").prop("checked", false); $(".action-payment-check-status").removeClass("checked"); } $("#commonModal").modal("hide"); } }, }); }); $(document).on("click", ".action_strex_confirm_number", function () { var confirm_number = $("#confirm_number").val(); var transactionId = $("#transactionId").val(); $(".action_strex_confirm_number").html("Vent.."); var url = "/user/subscription/strexconfirm"; $.ajax({ url: url, method: "POST", data: { confirm_number: confirm_number, transactionId: transactionId, }, dataType: "text", success: function (script_response) { $(".action_strex_confirm_number").html("Aktiver Strex"); var data = $.parseJSON(script_response); if (data["success"] == "true") { if (data["subscription_strex_active"] == "Yes") { $("#action-subscription-sms").trigger("click"); } else { location.reload(); } if (data["strex_status"] == "1") { $("#strexPayment").prop("checked", true); $(".action-payment-check-status").addClass("checked"); } else { $("#strexPayment").prop("checked", false); $(".action-payment-check-status").removeClass("checked"); } $("#commonModal").modal("hide"); } else if (data["message"] != "") { $("#commonModal .modal-body").html( '

' + data["message"] + '

' ); } }, }); }); $(document).on("click", ".action-subscription-payment", function () { $(".action-subscription-payment").html("Vent.."); var url = "/user/subscription/strexsubscriptionpayment"; $.ajax({ url: url, method: "POST", data: {}, dataType: "text", success: function (script_response) { $(".action-subscription-payment").html( ' Bekreft bestilling' ); var data = $.parseJSON(script_response); if (data["success"] == "true") { location.reload(); if (data["strex_status"] == "1") { $("#strexPayment").prop("checked", true); $(".action-payment-check-status").addClass("checked"); } else { $("#strexPayment").prop("checked", false); $(".action-payment-check-status").removeClass("checked"); } if (data["sms"] == "1") { $("#subscription-sms").removeClass("inactive"); $("#subscription-professional").addClass("inactive"); /* $(".action-subscription-basic").html('Gjeldende'); */ } else { $("#subscription-sms").addClass("inactive"); } $("#commonModal").modal("hide"); } else if (data["message"] != "") { $("#commonModal .modal-body").html( '

' + data["message"] + '

' ); } }, }); }); $(document).on("click", ".action-subscription-downgrade", function () { $(".action-subscription-downgrade").html("Vent.."); var url = "/user/subscription/subscription_downgrade"; $.ajax({ url: url, method: "POST", data: { type: "", }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { location.reload(); } }, }); }); $(".action-changeImage").on("click", function () { imageTools(); }); $("#cancelProfileImg").on("click", function () { imageTools(); }); function imageTools() { $(".imageTools").toggleClass("active"); $(".section-block.profile").toggleClass("active"); $(".imageToolsBg").toggleClass("active"); } /** image takepicture **/ function detectWebcam(callback) { let md = navigator.mediaDevices; if (!md || !md.enumerateDevices) return callback(false); md.enumerateDevices().then((devices) => { callback(devices.some((device) => "videoinput" === device.kind)); }); } var shutter = new Audio(); shutter.autoplay = false; shutter.src = navigator.userAgent.match(/Firefox/) ? "/assets/frontend/images/shutter.ogg" : "/assets/frontend/images/shutter.mp3"; /* function take_snapshot() { shutter.play(); Webcam.snap( function(data_uri) { $('#my_camera_preview_image').html(''); $('#my_camera_preview').css("display",""); $('#my_camera').css("display","none"); }); Webcam.reset(); } */ function take_snapshot() { shutter.play(); Webcam.snap(function (data_uri) { $image_crop = $("#my_camera_preview_image").croppie({ enableExif: true, viewport: { width: 200, height: 200, type: "square", }, boundary: { width: 720, height: 350, }, }); $image_crop.croppie("bind", { url: data_uri, }); $("#downloadSnap").attr("href", data_uri); $("#my_camera_preview").css("display", ""); $("#my_camera").css("display", "none"); }); Webcam.reset(); } function changeSnap() { $("#my_camera_preview").css("display", "none"); $("#my_camera").css("display", ""); $("#my_camera_preview_image").removeClass("croppie-container").html(""); detectWebcam(function (hasWebcam) { var camStatus = hasWebcam ? "yes" : "no"; if (camStatus == "no") { alert("Feil: Kamera ble ikke funnet."); } else { /***********/ $("#commonModal").modal(); setTimeout(function () { Webcam.set({ width: 420, height: 350, image_format: "jpeg", jpeg_quality: 90, }); Webcam.attach("#my_camera_image"); }, 100); /***********/ } }); } function saveSnap() { var base64image = document.getElementById("imageprev").src; $("#commonModal").modal("hide"); $("#cancelProfileImg").trigger("click"); $image_crop.croppie("bind", { url: base64image, }); $("#uploadimageModal").modal("show"); } function saveNewImg() { $image_crop .croppie("result", { type: "canvas", size: "viewport", }) .then(function (response) { var file_name = $(".personal-info .number").html(); $("#image_upload_101").val(""); $.ajax({ url: "/ajax/upload_profile_img", type: "POST", data: { image: response, file_name: file_name, }, success: function (php_script_response) { $("#commonModal").modal("hide"); var data = jQuery.parseJSON(php_script_response); if (php_script_response != "") { if (data["success"] == "true") { $("#picture-holder").attr( "style", 'background-image:url("/' + data["imgurl"] + '");' ); $("#img_job_error").html(""); $(".action-remove-profile-image").show(); } else { $("#img_job_error").html(data["msg"]); } } }, }); }); } $(document).on("click", ".action-get-calculatorModal", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var help_id = $(".selected-listing").attr("data-help_id"); var orderid = $(".selected-listing").attr("data-orderid"); var url = "/messages/get_calculatormodal"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, help_id: help_id, orderid: orderid, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); }); $(document).on("click", ".action-job-calculator", function () { if ($("#expense").val() <= 0) { $("#expense").val(0); } var expense = parseInt($("#expense").val()); if ($("#hourlyPayment").val() <= 0) { $("#hourlyPayment").val(0); } var hourlyPayment = parseInt($("#hourlyPayment").val()); if ($("#estimatedHours").val() <= 0) { $("#estimatedHours").val(0); } var estimatedHours = parseInt($("#estimatedHours").val()); if ($("#jobFee").val() <= 0) { $("#jobFee").val(0); } var jobFee = parseInt($("#jobFee").val()); if (hourlyPayment != "" && estimatedHours != "" && jobFee != "") { /**/ var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var url = "/messages/update_job_calculator"; $.ajax({ url: url, method: "POST", data: { expense: expense, hourlyPayment: hourlyPayment, estimatedHours: estimatedHours, jobFee: jobFee, user_id: user_id, job_id: job_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "false") { $.each(data["message"], function (key, value) { /* alert( key + ": " + value ); */ $(".error-response." + key + "").html(value); }); setTimeout(function () { $(".error-response").html(""); }, 6000); } else { if (hourlyPayment < 150) { $(".action-underestimate-2").addClass("underestimate"); $(".action-low-earning").show(); } else { $(".action-underestimate-2").removeClass("underestimate"); $(".action-low-earning").hide(); } var total_price = expense + hourlyPayment * estimatedHours + jobFee; total_price = total_price + ".- kr"; $(".action-correct-price").html(total_price); $(".action-cal-gree-text").html( "Oppdragsgebyret er inkludert i utregningen." ); } }, }); /**/ } }); $(document).on("change", "#JobCalculator input", function () { JobCalculator(); }); $(document).on("keyup", "#JobCalculator input", function () { JobCalculator(); }); function JobCalculator() { var expense = parseInt($("#expense").val()); var hourlyPayment = parseInt($("#hourlyPayment").val()); var estimatedHours = parseInt($("#estimatedHours").val()); var jobFee = parseInt($("#jobFee").val()); if ($("#expense").val().length > 6) { $(".action-underestimate-expense").addClass("underestimate"); } else { $(".action-underestimate-expense").removeClass("underestimate"); } if (hourlyPayment < 150) { $(".action-underestimate-1").addClass("underestimate"); } else if ($("#hourlyPayment").val().length > 4) { $(".action-underestimate-1").addClass("underestimate"); } else { $(".action-underestimate-1").removeClass("underestimate"); } } $(document).on("click", ".quantity-up", function () { var oldValue = parseInt($("#estimatedHours").val()); var newValue = oldValue + 1; $("#estimatedHours").val(newValue); }); $(document).on("click", ".quantity-down", function () { var oldValue = parseInt($("#estimatedHours").val()); var newValue = oldValue - 1; if (newValue < 1) { newValue = 1; } $("#estimatedHours").val(newValue); }); $(document).on("click", ".action-takepicture", function () { var url = "/user/profile/popup_takepicture"; $.ajax({ url: url, method: "POST", data: {}, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); setTimeout(function () { detectWebcam(function (hasWebcam) { var camStatus = hasWebcam ? "yes" : "no"; if (camStatus == "no") { alert("Feil: Kamera ble ikke funnet."); } else { /***********/ $("#commonModal").modal(); setTimeout(function () { Webcam.set({ width: 420, height: 350, image_format: "jpeg", jpeg_quality: 90, }); Webcam.attach("#my_camera_image"); }, 100); /***********/ } }); }, 200); } }, }); }); /** image takepicture **/ $(document).on("click", ".action-camera-close", function () { Webcam.set({ width: 420, height: 350, image_format: "jpeg", jpeg_quality: 90, }); Webcam.reset(); }); $(document).on("click", ".action-content-page", function () { var url = "/pages/get_page_content"; $.ajax({ url: url, method: "POST", data: {}, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#div-tjenesteavtalen").html(data["main_content"]); $("#div-tjenesteavtalen").modal(); } }, }); }); $(document).on("click", ".modal-content .close", function () { /* $('.modal').modal('hide'); $("#div-tjenesteavtalen").modal('hide'); */ var qqq = $(this).closest(".modal"); $(qqq).modal("hide"); }); /*report user*/ $(document).on("click", ".action-report-user", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var help_id = $(".selected-listing").attr("data-help_id"); var url = "/messages/report_user_step1"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, help_id: help_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); }); $(document).on("click", ".action-report-user-confirm", function () { $(".action-report-user-confirm").html("Vent.."); var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var help_id = $(".selected-listing").attr("data-help_id"); var report_option = $("#report-options").val(); if (user_id === undefined || user_id === null) { user_id = $(this).attr("data-user_id"); } if (job_id === undefined || job_id === null) { job_id = $(this).attr("data-job_id"); } if (helper === undefined || helper === null) { helper = $(this).attr("data-helper"); } if (help_id === undefined || help_id === null) { help_id = $(this).attr("data-help_id"); } var url = "/messages/report_user_step2"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, help_id: help_id, report_option: report_option, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".action-report-user-confirm").html("Rapporter"); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } else if (data["message"] != "") { $("#commonModal .response-msg").html( "
" + data["message"] + "
" ); setTimeout(function () { $("#commonModal .response-msg").html(""); }, 6000); } }, }); }); /*report user*/ /*action-inspection-chat*/ $(document).on("click", ".action-inspection-chat", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var help_id = $(".selected-listing").attr("data-help_id"); var url = "/messages/popup_inspection"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, help_id: help_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); setTimeout(function () { $(document).on("keyup", ".geo-address-popup-inspection", function () { $("#googleidsearch").val(this.id); }); $(document).one( "keyup", ".geo-address-popup-inspection", function () { initMap_norway_inspection(); } ); $("#inspection_date").datepicker({ minDate: 0, dateFormat: "dd.mm.yy", }); }, 100); } }, }); }); /*action-inspection-chat*/ /*action-send-inspection-req*/ $(document).on("click", ".action-send-inspection-req", function () { $(".action-send-inspection-req").html("Vent.."); $("#common_error").html(""); var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var help_id = $(".selected-listing").attr("data-help_id"); var popupFrm = $("#popupForm").serialize(); var url = "/messages/inspection_reqsend"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, help_id: help_id, popupFrm: popupFrm, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { /* location.reload(); */ $(".selected-listing").trigger("click"); console.log("Send chat_message_refresh_2 - 16"); socket.emit("chat_message_refresh_2", { job_id: job_id, help_id: help_id, timestamp: new Date().toISOString(), }); setTimeout(function () { $(".action-send-inspection-req").html("Send for bekreftelse"); $("#commonModal").modal("hide"); setTimeout(function () { /* $("#chat-content-data").animate({ scrollTop: 0 }, 500); */ }, 500); }, 3000); } else { $(".action-send-inspection-req").html("Send for bekreftelse"); $("#common_error").html( "
" + data["message"] + "
" ); } }, }); }); $(document).on("click", ".action-update-inspection-req", function () { $(".action-update-inspection-req").html("Vent.."); $("#common_error").html(""); var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var help_id = $(".selected-listing").attr("data-help_id"); var popupFrm = $("#popupForm").serialize(); var url = "/messages/inspection_requpdate"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, help_id: help_id, popupFrm: popupFrm, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { /*$(".selected-listing").trigger("click");*/ selected_listing_trigger_click(1021); console.log("Send chat_message_refresh_2 - 11"); socket.emit("chat_message_refresh_2", { job_id: job_id, help_id: help_id, timestamp: new Date().toISOString(), }); setTimeout(function () { $(".action-update-inspection-req").html("Send for bekreftelse"); $("#commonModal").modal("hide"); setTimeout(function () { /* $("#chat-content-data").animate({ scrollTop: 0 }, 500); */ }, 500); }, 3000); } else { $(".action-update-inspection-req").html("Send for bekreftelse"); $("#common_error").html( "
" + data["message"] + "
" ); } }, }); }); /*action-send-inspection-req*/ /*action-change-inspection-chat*/ $(document).on("click", ".action-change-inspection-chat", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var help_id = $(".selected-listing").attr("data-help_id"); var url = "/messages/popup_inspection_change"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, help_id: help_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); setTimeout(function () { console.log("geo..."); $(document).on("keyup", ".geo-address-popup-inspection", function () { $("#googleidsearch").val(this.id); }); $(document).one( "keyup", ".geo-address-popup-inspection", function () { initMap_norway_inspection(); } ); $("#inspection_date").datepicker({ minDate: 0, dateFormat: "dd.mm.yy", }); }, 100); } }, }); }); /*action-change-inspection-chat*/ /*action-accept-inspection-contract*/ $(document).on("click", ".action-accept-inspection-contract", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var help_id = $(".selected-listing").attr("data-help_id"); var url = "/messages/popup_inspection_accept"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, help_id: help_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); }); /*action-accept-inspection-contract*/ /*action-confirm-inspection-contract*/ $(document).on("click", ".action-confirm-inspection-contract", function () { $(".action-confirm-inspection-contract").html("Vent.."); var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var help_id = $(".selected-listing").attr("data-help_id"); var popupFrm = $("#popupForm").serialize(); var url = "/messages/popup_inspection_accept_confirm"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, help_id: help_id, popupFrm: popupFrm, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $(".selected-listing").trigger("click"); console.log("Send chat_message_refresh_2 - 12"); socket.emit("chat_message_refresh_2", { job_id: job_id, help_id: help_id, timestamp: new Date().toISOString(), }); setTimeout(function () { $(".action-confirm-inspection-contract").html("Bekreft avtale"); $("#commonModal").modal("hide"); }, 500); setTimeout(function () { $(".action-confirm-inspection-contract").html("Bekreft avtale"); $("#commonModal").modal("hide"); setTimeout(function () { /* $("#chat-content-data").animate({ scrollTop: 0 }, 500); */ }, 500); }, 3000); } else { $(".action-confirm-inspection-contract").html("Bekreft avtale"); $("#common_error").html( "
" + data["message"] + "
" ); } }, }); }); /*action-confirm-inspection-contract*/ $(document).on("click", ".action-chat_rules", function () { /* $("#chat-content-data .btn_readContract").trigger('click'); */ var helper = $(".selected-listing").attr("data-helper"); var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var url = "/messages/get_chat_rules"; $.ajax({ url: url, method: "POST", data: { helper: helper, user_id: user_id, job_id: job_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); }); $(document).on("click", ".action-inspection-another", function () { $(".action-inspection-another").html("Vent.."); $(".action-change-inspection-chat").trigger("click"); }); /**********/ $(document).on("click", ".action-See-Invited-Helpers", function () { var job_id = $(this).attr("data-job_id"); var url = "/user/myjobs/SeeInvitedHelpers"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); }); $(document).on("click", ".action-job-full", function () { var job_id = $(this).attr("data-job_id"); var url = "/user/myjobs/jobfullinfo"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); } }, }); }); /* $(document).on("click", ".action-re-publish-job", function () { var job_id = $(this).attr("data-job_id"); var url = "/user/myjobs/republishjob"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); setTimeout(function () { getTimeOpt(); $("#datepicker").datepicker({ minDate: 0, dateFormat: "dd-mm-yy", }); }, 100); } }, }); }); */ /* $(document).on("click", ".action-republish-job-confirm", function () { var job_id = $(this).attr("data-job_id"); var time = $("#time").val(); var datepicker = $("#datepicker").val(); $(".action-republish-job-confirm").html( ' Vent..' ); var url = "/newjob/republishjobconfirm"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, time: time, date: datepicker, }, dataType: "text", success: function (script_response) { $(".action-republish-job-confirm").html( ' Legg ut jobben' ); $("#commonModal").hide(); var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#publish-job").removeClass("publish-job-modal"); $("#publish-job").html(data["main_content"]); $(".justify-content-end").remove(); $(".job-btn-publish").remove(); $("#publish-job").modal({ backdrop: "static", keyboard: false, }); } else { $("#common_error").html( "
" + data["message"] + "
" ); setTimeout(function () { $("#common_error").html(""); }, 3000); } }, }); }); */ $(document).on("click", ".action-contact-helpers", function () { var job_id = $(this).attr("data-job_id"); var url = "/user/myjobs/contact_helpers"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); }); $(document).on("click", ".action-delete-job", function () { var job_id = $(this).attr("data-job_id"); var help_id = $(this).attr("data-help_id"); var type = $(this).attr("data-type"); var url = "/user/myjobs/deletejob"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, help_id: help_id, type: type, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); }); $(document).on("click", ".action-confirm-delete-job", function () { $(".action-confirm-delete-job").html("Vent.."); var job_id = $(this).attr("data-job_id"); var help_id = $(this).attr("data-help_id"); var type = $(this).attr("data-type"); var url = "/user/myjobs/deletejob_confirm"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, help_id: help_id, type: type, }, dataType: "text", success: function (script_response) { $(".action-confirm-delete-job").html( ' Slett ' ); var data = $.parseJSON(script_response); if (data["success"] == "true") { if (data["new_count_expire"] == "0") { $("#pills-profile .display-results").html( '
Du har ingen småjobber.
' ); } $("#pills-profile-tab .unreadedmessages-alert").html( data["new_count_expire"] ); $("#expire_job_info_" + data["job_id"] + "").remove(); $("#commonModal").html(""); $("#commonModal").modal("hide"); location.reload(); } }, }); }); $(document).on("click", ".action-confirm-delete-lost-job", function () { $(".action-confirm-delete-lost-job").html("Vent.."); var job_id = $(this).attr("data-job_id"); var help_id = $(this).attr("data-help_id"); var url = "/user/myjobs/deletejob_confirm_lost"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, help_id: help_id, }, dataType: "text", success: function (script_response) { $(".action-confirm-delete-lost-job").html( ' Slett jobb' ); var data = $.parseJSON(script_response); if (data["success"] == "true") { if (data["new_count_lost_offer"] == "0") { $("#pills-lost .display-results").html( '
Du har ingen småjobber.
' ); } $("#pills-lost-tab .unreadedmessages-alert").html( data["new_count_lost_offer"] ); $("#lost_job_info_" + data["job_id"] + "").remove(); $("#commonModal").html(""); $("#commonModal").modal("hide"); } }, }); }); $(document).on("click", ".action-cancle-invite", function () { $(this).html("Vent.."); var job_id = $(this).attr("data-job_id"); var invite_id = $(this).attr("data-invite_id"); var url = "/user/myjobs/deleteinvite_confirm"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, invite_id: invite_id, }, dataType: "text", success: function (script_response) { $(".action-cancle-invite").html( ' Kanseller' ); var data = $.parseJSON(script_response); if (data["success"] == "true") { var job_id = data["job_id"]; $( "#job_active_row_" + job_id + " .action-See-Invited-Helpers" ).trigger("click"); } }, }); }); /************/ $(document).on("click", ".action-mobile-job-details", function () { var job_id = $(this).attr("data-job_id"); var tab = $(this).attr("data-tab"); var url = "/user/myjobs/mobile_job_details"; $.ajax({ url: url, method: "POST", data: { job_id: job_id, tab: tab, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); setTimeout(function () { $("#commonModal").modal(); }, 300); setTimeout(function () { $(".job-detail-slider").slick({ dots: true, arrows: false, autoplaySpeed: 8000, infinite: true, speed: 500, fade: true, cssEase: "linear", }); }, 500); /* $(window).on('shown.bs.modal', function() { $('.job-detail-slider').slick('setPosition'); }); */ } }, }); }); $(document).on("click", ".action-popup-rating", function () { var user_id = $(this).attr("data-user_id"); var url = "/browse/popup_rating"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); }); $(document).on("click", ".action-get-info", function () { var type = $(this).attr("data-info-type"); var url = "/browse/get_info"; $.ajax({ url: url, method: "POST", data: { type: type, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); }); $(document).on("click", ".action-change-phone-step-1", function () { var url = "/user/profile/change_phone_step_1"; $.ajax({ url: url, method: "POST", data: {}, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); }); $(document).on("click", ".action-change-phone-step-2", function () { $(".action-change-phone-step-2").html("Vent.."); var phone = $("#popup_phone").val(); var url = "/user/profile/change_phone_step_2"; $.ajax({ url: url, method: "POST", data: { phone: phone, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".action-change-phone-step-2").html("Send"); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } else if (data["success"] == "false") { $(".response-msg").html( "
" + data["message"] + "
" ); } }, }); }); $(document).on("click", ".action-change-phone-step-3", function () { $(".action-change-phone-step-3").html("Send"); var verify_number = $("#popup_code").val(); var url = "/user/profile/change_phone_step_3"; $.ajax({ url: url, method: "POST", data: { verify_number: verify_number, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".action-change-phone-step-3").html("Bekreft"); if (data["success"] == "true") { $("#validationServerUserMobile").val(data["new_phone"]); $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } else if (data["success"] == "false") { $(".response-msg").html( "
" + data["message"] + "
" ); } }, }); }); $(document).on("click", ".action-set-redirect", function () { var redirect = $(this).attr("data-redirect"); if (typeof redirect != "undefined") { var url = "/ajax/set_redirect"; $.ajax({ url: url, method: "POST", data: { redirect: redirect, }, dataType: "text", success: function (script_response) {}, }); } }); $(document).on("click", ".action-get-forget-password", function () { $("#mySidenav .closebtn").addClass("action-get-login-sidebar"); $(".action-get-forget-password").html("Vent.."); var url = "/user/login/get_password_page"; $.ajax({ url: url, method: "POST", data: {}, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".action-get-forget-password").html("Glemt passordet?"); if (data["success"] == "true") { $("#sidebar-response").html(data["main_content"]); } else if (data["success"] == "false") { $(".LoginResponse").html( "
" + data["message"] + "
" ); } }, }); }); $(document).on("click", ".action-get-login-sidebar", function () { $("#mySidenav .closebtn").removeClass("action-get-login-sidebar"); /*$(".action-get-forget-password").html("Vent..");*/ var url = "/user/login/get_sidebar_login_content"; $.ajax({ url: url, method: "POST", data: {}, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); /*$(".action-get-forget-password").html('Glemt passordet?');*/ if (data["success"] == "true") { $("#sidebar-response").html(data["main_content"]); } else if (data["success"] == "false") { } }, }); }); /* $(document).on("click", '#totalt-tab', function () { $("input:radio[name='payment_type']").filter('[value="total"]').attr('checked', true); }); $(document).on("click", '#time-tab', function () { $("input:radio[name='payment_type']").filter('[value="per_hour"]').attr('checked', true); }); $(document).on("click", '#tilbud-tab', function () { $("input:radio[name='payment_type']").filter('[value="proposals_wanted"]').attr('checked', true); }); */ $(document).on("click", "#totalt-tab,#time-tab,#tilbud-tab", function () { if ($("#totalt-tab").hasClass("active")) { $("input:radio[name='payment_type']") .filter('[value="total"]') .prop("checked", true); } if ($("#time-tab").hasClass("active")) { $("input:radio[name='payment_type']") .filter('[value="per_hour"]') .prop("checked", true); } if ($("#tilbud-tab").hasClass("active")) { $("input:radio[name='payment_type']") .filter('[value="proposals_wanted"]') .prop("checked", true); } event_price_change(); }); $(document).on("click", ".action-option_professional", function () { let ispectionLabel = ""; var option_professional = $( "input:radio[name='proposals_wanted_option_professional']:checked" ).val(); if (option_professional == 1 || option_professional == 0) { if (option_professional == 0) { ispectionLabel = "Småjobb /privat hjelp"; } else if (option_professional == 1) { ispectionLabel = "Oppdrag for profesjonelle"; } $("#inspectionButton") .html(``); } $("#inspectionModalCenter").modal("hide"); }); $(document).on("click", ".action-option_professional-pwa", function () { let ispectionLabel = ""; var option_professional = $( "input:radio[name='proposals_wanted_option_professional']:checked" ).val(); if (option_professional == 1 || option_professional == 0) { if (option_professional == 0) { ispectionLabel = "Småjobb"; } else if (option_professional == 1) { ispectionLabel = "PRO"; } $("#inspectionButton") .html(``); } $("#inspectionModalCenter").modal("hide"); }); $(document).on("click", ".action-registrer-firma", function () { $(".action-registrer-firma").html("Vent.."); var url = "/user/profile/registrer_firma"; $.ajax({ url: url, method: "POST", data: {}, dataType: "text", success: function (script_response) { $(".action-registrer-firma").html("Registrer firma"); var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); }); /************/ $(document).on("click", ".action-firm-next", function () { $(".action-firm-next").html("Vent.."); var url = "/user/profile/registrer_firma_next"; var company_number = $("#company_number").val(); $.ajax({ url: url, method: "POST", data: { company_number: company_number, }, dataType: "text", success: function (script_response) { $(".action-firm-next").html("Videre"); var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); if ($("#payment-option-modal").length > 0) { $("#payment-option-modal").html(data["main_content"]); } } else { $("#common_error").html( "
" + data["message"] + "
" ); setTimeout(function () { $("#common_error").html(""); }, 3000); } }, }); }); $(document).on("click", ".action-firm-confirm", function () { $(".action-firm-confirm").html("Vent.."); var url = "/user/profile/registrer_firma_confirm"; var company_number = $("#company_number").val(); var confirm_number = $("input[name='confirm_number']:checked").val(); $.ajax({ url: url, method: "POST", data: { company_number: company_number, confirm_number: confirm_number, }, dataType: "text", success: function (script_response) { $(".action-firm-confirm").html("Bekreft"); var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#organisasjons_content").html(data["organisasjons_content"]); if ($("#payment-option-modal").length > 0) { $("#payment-option-modal").html(data["main_content"]); } } else { $("#common_error").html( "
" + data["message"] + "
" ); setTimeout(function () { $("#common_error").html(""); }, 3000); } }, }); }); /*********************/ $(document).on("click", ".action-remove-registrer-firma", function () { $(".action-remove-registrer-firma").html("Vent.."); var url = "/user/profile/registrer_firma_remove"; $.ajax({ url: url, method: "POST", data: {}, dataType: "text", success: function (script_response) { $(".action-remove-registrer-firma").html("Avregistrer firma"); var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#organisasjons_content").html(data["organisasjons_content"]); } else { } }, }); }); /* $(document).on("change", "#your_offer,#expected_hours", function () { let your_offer = $("#your_offer").val(); let expected_hours = $("#expected_hours").val(); if (your_offer != "" && expected_hours != "") { let price_hourly = parseInt(your_offer) / parseInt(expected_hours); price_hourly = parseInt(price_hourly); $("#price_hourly").val(price_hourly); } }); */ $(document).on("change", "#your_offer,#expected_hours", function () { let your_offer = $("#your_offer").val(); let expected_hours = $("#expected_hours").val(); let proposal_amount = 0; let assignment_fee = $("#assignment_fee").val(); let get_assignment_fee = parseInt(assignment_fee); console.log("your_offer :", your_offer); console.log("get_assignment_fee :", get_assignment_fee); if (your_offer != "" && your_offer != 0) { your_offer = parseInt(your_offer); if (typeof get_assignment_fee !== "undefined" && get_assignment_fee != "") { proposal_amount = get_assignment_fee + your_offer; $("#proposal_amount").val(proposal_amount); if (expected_hours != "" && expected_hours != 0) { expected_hours = parseInt(expected_hours); let price_hourly = parseFloat( parseInt(your_offer) / parseInt(expected_hours) ).toFixed(2); let txtclass = ""; if (price_hourly < 100) { txtclass = "text-danger"; } else if (price_hourly < 140) { txtclass = "text-warning"; } $("#hourly-price-show").html( "Timepris utgjør kr. " + price_hourly + " .- (Vårt gebyr legges automatisk til prisforslag)" ); } } } }); $(document).on("click", ".action-get-attachment-popup-info", function () { var chat_id = $(this).attr("data-chat_id"); var url = "/messages/get_attachment_popup_info"; $.ajax({ url: url, method: "POST", data: { chat_id: chat_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal(); } }, }); }); $(document).on("click", ".action-send-til-epost", function () { $(".action-send-til-epost").html("Vent.."); var chat_id = $(this).attr("data-id"); var url = "/messages/send_til_epost"; $.ajax({ url: url, method: "POST", data: { chat_id: chat_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); } }, }); }); $(document).on("click", ".action-chat-sms-notification-send", function () { $(".action-chat-sms-notification-send").html("Vent.."); var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var url = "/messages/chat_sms_notification"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); } }, }); }); $(document).on("click", ".get-popup-content", function () { var content_type = $(this).attr("data-contentpopup"); if (content_type != "") { $(".get-popup-content").html("Vent.."); var url = "/messages/getcontractcontent"; $.ajax({ url: url, method: "POST", data: { content_type: content_type, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["chat_content"]); } }, }); } }); $(document).on("click", ".action-popup-content", function () { var content_type = $(this).attr("data-contentpopup"); if (content_type != "") { var url = "/messages/getcontractcontent"; $.ajax({ url: url, method: "POST", data: { content_type: content_type, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["chat_content"]); if ($("#commonModal").hasClass("show") == false) { $("#commonModal").modal(); } } }, }); } }); $(document).on("click", ".action-close-popup", function () { $("#commonModal").modal("hide"); }); function goBack() { //var url = window.history.back(); let url = document.referrer; let host = window.location.hostname; let t = window.location.href.indexOf(host); console.log("host: ", host); console.log("goBack: ", url); console.log(" : ", t); if (url == "") { url = "https://" + host; } window.location.href = url; } $("#actionSlideInfo").click(function () { /* $("#SlideInfoContent").slideToggle("slow"); $("#SlideInfoContent_2023").hide(); */ /* $("#tbl-2").slideToggle("slow"); $("#tbl-1").slideToggle(); */ if ($("#SlideInfoContent").is(":visible")) { SlideInfoContent_main(); } else { $("#report-table-2").hide(); $("#report-table-1").show(); $("#SlideInfoContent").slideDown("slow"); $("#SlideInfoContent_2023").slideUp(); $("#tbl-2").slideDown("slow"); $("#tbl-1").slideUp(); } }); $("#actionSlideInfo_2023").click(function () { /* $("#SlideInfoContent_2023").slideToggle("slow"); $("#SlideInfoContent").hide(); */ /* $("#tbl-2").slideToggle("slow"); $("#tbl-1").slideToggle(); */ if ($("#SlideInfoContent_2023").is(":visible")) { SlideInfoContent_main(); } else { $("#report-table-1").hide(); $("#report-table-2").show(); $("#SlideInfoContent_2023").slideDown("slow"); $("#SlideInfoContent").slideUp(); $("#tbl-2").slideDown("slow"); $("#tbl-1").slideUp(); } }); function SlideInfoContent_main() { $("#SlideInfoContent_2023").slideUp(); $("#SlideInfoContent").slideUp(); $("#tbl-2").slideUp(); $("#tbl-1").slideDown("slow"); } $(document).on("click", ".popular-search-items", function () { var txt = $(this).text().trim(); $("#form1").val(txt); /*$("#btn-form1-search").trigger('click');*/ $("#form1").trigger("keyup"); }); $(document).on("click", "#btn-form1-search", function () { $("#form1").trigger("keyup"); }); $(document).on("search", "#form1", function () { $("#form1").trigger("keyup"); }); /*$(document).on("click", "#btn-form1-search", function () {*/ $(document).on("keyup", "#form1", function () { var searchTerm = $("#form1").val().toLowerCase(); if (searchTerm != "") { $("#create_job_row li").each(function () { var text = $(this).text().toLowerCase(); if (text.includes(searchTerm)) { $(this).addClass("font-weight-bold"); /*$(this).parents('.create_job_col').addClass("highlight-main-job");*/ } else { $(this).removeClass("font-weight-bold"); /*$(this).parents(".create_job_col").removeClass("highlight-main-job");*/ } }); } else { $(".font-weight-bold").removeClass("font-weight-bold"); } /**/ setTimeout(function () { $("#create_job_row .create_job_col").removeClass("highlight-main-job"); setTimeout(function () { var length = $("li.font-weight-bold").length; if (length > 0) { $("#create_job_row").addClass("highlight-row-job"); } else { $("#create_job_row").removeClass("highlight-row-job"); } $("#create_job_row li.font-weight-bold").each(function () { //console.log("this html :", $(this).html() ); //console.log("this parent :", $(this).closest(".create_job_col").html()); $(this).closest(".create_job_col").addClass("highlight-main-job"); }); }, 200); }, 200); /**/ }); /* send-business-cards */ $(document).on("click", ".action-send-business-cards", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var help_id = $(".selected-listing").attr("data-help_id"); var url = "/messages/get_send_business_cards_data"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, help_id: help_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["chat_content"]); $("#commonModal").modal("show"); } }, }); }); $(document).on("click", ".action-send-business-confirm", function () { var user_id = $(".selected-listing").attr("data-user_id"); var job_id = $(".selected-listing").attr("data-job_id"); var helper = $(".selected-listing").attr("data-helper"); var help_id = $(".selected-listing").attr("data-help_id"); $(".action-send-business-confirm").html("Vent.."); var url = "/messages/send_business_cards_data_confirm"; $.ajax({ url: url, method: "POST", data: { user_id: user_id, job_id: job_id, helper: helper, help_id: help_id, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); /* $(".action-send-business-confirm").html( ' Send visittkort' ); */ $(".action-send-business-confirm").html("Avslutt uten visittkort"); if (data["success"] == "true") { $(".selected-listing").trigger("click"); $(".close").trigger("click"); console.log("Send chat_message_refresh_2 - 13"); socket.emit("chat_message_refresh_2", { job_id: job_id, help_id: help_id, timestamp: new Date().toISOString(), }); } else if (data["success"] == "false" && data["chat_content"] != "") { $("#commonModal").html(data["chat_content"]); $("#commonModal").modal("show"); } }, }); }); /*end send-business-cards */ /*popup*/ $(document).on("click", ".action-get-verification-email", function () { var popup_type = "1"; get_verification_email_popup(popup_type); }); function get_verification_email_popup(popup_type) { var url = "/user/profile/get_verification_email_popup"; $.ajax({ url: url, method: "POST", data: { popup_type: popup_type, }, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); $("#commonModal").modal("show"); send_verification_email(); } }, }); } $(document).on("click", ".action-send-email-again", function () { var url = "/user/profile/send_verification_email_popup"; $(".action-send-email-again").html("Vent.."); $.ajax({ url: url, method: "POST", data: {}, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); $(".action-send-email-again").html("Jeg fikk ingen e-post"); if (data["success"] == "true") { $("#commonModal").html(data["main_content"]); timepassed = 1; var x = setInterval(function () { document.getElementById("timer_email").innerHTML = (40 - timepassed) .toString() .padStart(2, "0"); timepassed += 1; if (timepassed > 40) { $("#send_again_btn").prop("disabled", false); clearInterval(x); send_verification_email(); } }, 1000); } }, }); }); function send_verification_email() { var url = "/user/profile/send_verification_email"; /*$("#send_again_btn").hide();*/ $.ajax({ url: url, method: "POST", data: {}, dataType: "text", success: function (script_response) { var data = $.parseJSON(script_response); if (data["success"] == "true") { //$("#commonModal").html(data["main_content"]); } }, }); } $(document).on("click", ".action-need-verification-email-2", function () { var popup_type = "2"; get_verification_email_popup(popup_type); }); $(document).on("change", "#inspection_date", function () { $("#time").empty(); var selectedDate = $(this).val(); $.ajax({ url: "/user/profile/fetch_time_slots", method: "POST", data: { selectedDate: selectedDate, }, dataType: "json", success: function (response) { if (response.success) { $.each(response.times, function (index, time) { $("#time").append( $("