function create_coutry_city_district(args={"country_code":"all","city_name":"İSTANBUL","district_name":"AVCILAR","country_elem":null,"city_elem":null,"district_elem":null,"district_elem_chcks":null})
{
var apixurl= "/Apps/Api/AppApi/GlobalApi/il_ilce_api.php";
if(args["country_elem"]!=null)
{
var country_iso2=document.getElementById(args["country_elem"]).value;
var post_data="request=get_country&country_code=all";
delegate_http_request(apixurl,post_data,false,function(response) {
data= response;
const jsonvalue = JSON.parse(data.response);
if(jsonvalue["status"]=="SUCCESS")
{
document.getElementById(args["country_elem"]).innerHTML="";
var js_arr=jsonvalue["value"];
ekcode="";
var i=-1;
for (var key in js_arr)
{
i++;
var select_code="";
if(key==args["country_code"]){select_code="selected";}
else if((args["country_code"]==null||args["country_code"]=="all")&&i==0){select_code="selected";}
ekcode+='';
}
document.getElementById(args["country_elem"]).innerHTML+=ekcode;
}
});
}
if(args["city_elem"]!=null&&args["country_elem"]!=null)
{
var country_iso2=document.getElementById(args["country_elem"]).value;
var post_data="request=get_citys&country_code="+country_iso2;
delegate_http_request(apixurl,post_data,false,function(response) {
data= response;
const jsonvalue = JSON.parse(data.response);
if(jsonvalue["status"]=="SUCCESS")
{
document.getElementById(args["city_elem"]).innerHTML="";
var js_arr=jsonvalue["value"];
ekcode="";
var i=-1;
for (var key in js_arr)
{
i++;
var select_code="";
if(key==args["city_name"]){select_code="selected";}
else if((args["city_name"]==null)&&i==0){select_code="selected";}
ekcode+='';
}
document.getElementById(args["city_elem"]).innerHTML+=ekcode;
}
});
}
if( args["district_elem"]!=null&&args["city_elem"]!=null&&args["country_elem"]!=null)
{
var country_iso2=document.getElementById(args["country_elem"]).value;
var city_code=document.getElementById(args["city_elem"]).value;
var post_data="request=get_districts&country_code="+country_iso2+"&city_code="+city_code;
delegate_http_request(apixurl,post_data,false,function(response) {
data= response;
const jsonvalue = JSON.parse(data.response);
if(jsonvalue["status"]=="SUCCESS")
{
document.getElementById(args["district_elem"]).innerHTML="";
var js_arr=jsonvalue["value"];
ekcode="";
var i=-1;
for (var key in js_arr)
{
i++;
var select_code="";
if(key==args["district_name"]){select_code="selected";}
else if((args["district_name"]==null)&&i==0){select_code="selected";}
ekcode+='';
}
document.getElementById(args["district_elem"]).innerHTML+=ekcode;
}
});
}
if( args["district_elem_chcks"]!=null&&args["city_elem"]!=null&&args["country_elem"]!=null)
{
var country_iso2=document.getElementById(args["country_elem"]).value;
var city_code=document.getElementById(args["city_elem"]).value;
var post_data="request=get_districts&country_code="+country_iso2+"&city_code="+city_code;
delegate_http_request(apixurl,post_data,false,function(response) {
data= response;
const jsonvalue = JSON.parse(data.response);
if(jsonvalue["status"]=="SUCCESS")
{
document.getElementById(args["district_elem_chcks"]).innerHTML="";
var js_arr=jsonvalue["value"];
ekcode="";
var i=-1;
for (var key in js_arr)
{
i++;
var select_code="";
if(args["district_name"].indexOf(key)!=-1){select_code="checked";}
ekcode+='
'+
'
'+
' '+
' '+
'
'+
'
';
}
document.getElementById(args["district_elem_chcks"]).innerHTML+=ekcode;
}
});
}
}
function get_user_limited_countrys()
{
var rt_value=null;
var apixurl= "/Apps/Api/AppApi/GlobalApi/il_ilce_api.php";
var post_data="request=get_country_limited&country_code=all";
var post_back_data=delegate_http_request(apixurl,post_data,false,function(response) {
data= response;
});
const jsonvalue = JSON.parse(post_back_data);
if(jsonvalue["status"]=="SUCCESS")
{
return jsonvalue["value"];
}
return rt_value;
}
function get_city_district_arr(country_code="TR",city_code="all")
{
var rt_value=null;
var apixurl= "/Apps/Api/AppApi/GlobalApi/il_ilce_api.php";
if(country_code!=null)
{
var post_data="request=get_city_districts&country_code="+country_code+"&city_code="+city_code;
var rt_value=delegate_http_request(apixurl,post_data,false,function(response) {
data= response;
const jsonvalue = JSON.parse(data.response);
if(jsonvalue["status"]=="SUCCESS")
{
return jsonvalue["value"];
}
});
return rt_value;
}
return rt_value;
}
function copy_func(elem,copy_type="normal",value="",subtext="Kopyalanan : \n"){
var copyval="";
if(copy_type=="value"){copyval=elem.value;}
else if(copy_type=="innertext"){copyval=elem.innerText;}
else if(copy_type=="innerhtml"){copyval=elem.innerHTML;}
else if(copy_type=="outertext"){copyval=elem.outerText;}
else if(copy_type=="outerhtml"){copyval=elem.outerHTML;}
else if(copy_type=="normal"){copyval=value;}
navigator.clipboard.writeText(copyval);
notify(subtext+copyval,"Kopyalama İşlemi");
}
function notify_js_css_controller()
{
var js_mevcut=false;
var css_mevcut=false;
var scriptElements = document.querySelectorAll("script");
for (var i = 0; i < scriptElements.length; i++) {
var script = scriptElements[i];
var src = script.getAttribute("src");
if (src && src.trim().indexOf("toastr.js") >= 0) {
js_mevcut = true;
break;
}
}
var linkElements = document.querySelectorAll("link");
for (var i = 0; i < linkElements.length; i++) {
var script = linkElements[i];
var src = script.getAttribute("href");
if (src && src.trim().indexOf("toastr.css") >= 0) {
css_mevcut = true;
break;
}
}
if(css_mevcut==false)
{
addStyle_element(document.body, "/cdn/new-theme-v2/vendor/libs/toastr/toastr.css",null);
return false;
}
if(js_mevcut==false)
{
addScript_element(document.body, "/cdn/new-theme-v2/vendor/libs/toastr/toastr.js",null);
return false;
}
return true;
}
function notify(value,title="",type="info",positionClass="toast-bottom-center")
{
var rt_val=notify_js_css_controller();
if(rt_val==false){setTimeout(function(){notify(value,title,type,positionClass)}, 100);}
if(rt_val==true)
{
try{
var new_title=title;
if(new_title=="")new_title="Bilgilendirme";
toastr[type](value,title=new_title, {
positionClass: 'toast-bottom-center',
"timeOut": "2500",
closeButton: true,
tapToDismiss: true,
progressBar: true
});
}catch(err){
document.addEventListener("DOMContentLoaded", function(){
var new_title=title;
if(new_title=="")new_title="Bilgilendirme";
toastr[type](value,new_title, {
positionClass: 'toast-bottom-center',
"timeOut": "2500",
closeButton: true,
tapToDismiss: true,
progressBar: true
});
});
}
}
}
function setCookie(name,value,minutes) {
var expires = "";
if (minutes) {
var date = new Date();
date.setTime(date.getTime() + (minutes*60*1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
}
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
var cookieclick=false;
function change_theme_color()
{
/*if(cookieclick==false){
var get_theme_ck=getCookie("theme_color");
if(get_theme_ck=="dark")theme="light";
else theme="dark";
setCookie("theme_color",theme,60*24*30);
}cookieclick=false;*/
}
function copy_func(elem,copy_type="normal",value="",subtext="Kopyalanan : \n"){
var copyval="";
if(copy_type=="value"){copyval=elem.value;}
else if(copy_type=="innertext"){copyval=elem.innerText;}
else if(copy_type=="innerhtml"){copyval=elem.innerHTML;}
else if(copy_type=="outertext"){copyval=elem.outerText;}
else if(copy_type=="outerhtml"){copyval=elem.outerHTML;}
else if(copy_type=="normal"){copyval=value;}
navigator.clipboard.writeText(copyval);
notify(subtext+copyval,"Kopyalama İşlemi");
}
document.addEventListener('DOMContentLoaded', function() {
/*
var get_theme_ck=getCookie("theme_color");
if(get_theme_ck=="dark"){cookieclick=true;document.getElementById("theme_color_btn").click(); }*/
moneymaskstart();
}, false);
function max_min_input_int(elem,min,max)
{
var minValue = min;
var maxValue = max;
var elem_val=Number(elem.value);
if(minValue!=null)
{
if(elem_valmaxValue)elem_val=maxValue;
}
if(Number.isInteger(elem_val)==true)
{
elem.value=elem_val;
}
else
{ if(minValue!=null)
elem.value=minValue;
else elem.value=minValue;
}
}
function moneymaskstart()
{
try{
$('.moneymask').mask('000.000.000.000.000.00', {
placeholder: "0,00",
reverse: true,
onChange: function(val, e, field){
// get only the numeric figures from the input value
val = val.replace( /[^0-9]+/g, '');
// strip leading zeros
val = (""+val).replace(/^0+/, '');
// fill up leading zeros if its a cent value
while( val.length <= 2 ) {
val = val+0;
}
// mask the new value and set it for the input element
$(field).val(field.masked(val));
}
});
}catch(err){}
try{
$('.phonemask').inputmask({
mask: '999 999 9999',
placeholder: '',
showMaskOnHover: false,
onBeforePaste: function (pastedValue, opts) {
// strip all non-numeric characters
return pastedValue.replace(/\D/g,'');
}
});
}catch(err){}
}
async function generate_intervalfunc(funcname,timeoutx=5000)
{
try{
funcname();
setInterval(function() {funcname();}, timeoutx);
}catch(err){}
}
async function generate_settimeoutfunc(funcname,timeoutx=5000)
{
try{
setTimeout(function(){ funcname(); }, timeoutx);
}catch(err){}
}
async function async_html_get(urlx)
{
try{
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 &&this.status == 200) {
}
};
xhttp.open("GET", urlx,true);
xhttp.send();
}
catch(err){}
}
function html_get(urlx)
{
var returndata="";
try{
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 &&this.status == 200) {
returndata= this.responseText;
}
};
xhttp.open("GET", urlx,false);
xhttp.send();
}
catch(err){}
return returndata;
}
async function async_html_post(urlx,params)
{
try{
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 &&this.status == 200) {
}
};
xhttp.open("POST", urlx,true);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.send(params);
}
catch(err){}
}
function html_post(urlx,params)
{
var returndata="";
try{
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 &&this.status == 200) {
returndata= this.responseText;
}
};
xhttp.open("POST", urlx,false);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.send(params);
}
catch(err){}
return returndata;
}
async function get_current_geocode()
{
var lat=0;
var lng=0;
try{
if (navigator.geolocation) {
const getCoords = async () => {
const pos = await new Promise((resolve, reject) => {
navigator.geolocation.getCurrentPosition(resolve, reject);
});
return {
long: pos.coords.longitude,
lat: pos.coords.latitude,
};
};
const coords = await getCoords();
lat=coords["lat"];
lng=coords["long"];
}
}catch(err){}
var lat_lng = new Array(lat, lng);
return lat_lng;
}
function get_set_setting(setting_name,setting_value=null)
{
var return_data="";
try{
var setting=getCookie(setting_name);
if(setting_value!=null)
{
setCookie(setting_name,setting_value,60*24*99);
}
return_data=setting;
}catch(err){}
return return_data;
}
function serialize(form) {
var field, s = [];
if (typeof form == 'object' && form.nodeName == "FORM") {
var len = form.elements.length;
for (i=0; i=0; j--) {
if(field.options[j].selected)
s[s.length] = encodeURIComponent(field.name) + "=" + encodeURIComponent(field.options[j].value);
}
} else if ((field.type != 'checkbox' && field.type != 'radio') || field.checked) {
s[s.length] = encodeURIComponent(field.name) + "=" + encodeURIComponent(field.value);
}
}
}
}
return s.join('&').replace(/%20/g, '+');
}
function openWindowWithPost(url, data, blank="_blank") {
var form = document.createElement("form");
if(blank=="_blank"){form.target = "_blank";}
form.method = "POST";
form.action = url;
form.style.display = "none";
for (var key in data) {
var input = document.createElement("input");
input.type = "hidden";
input.name = key;
input.value = data[key];
form.appendChild(input);
}
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
}
String.prototype.turkishToLower = function(){
var string = this;
var letters = { "İ": "i", "I": "ı", "Ş": "ş", "Ğ": "ğ", "Ü": "ü", "Ö": "ö", "Ç": "ç" };
string = string.replace(/(([İIŞĞÜÇÖ]))/g, function(letter){ return letters[letter]; })
return string.toLowerCase();
}
String.prototype.turkishToUpper = function(){
var string = this;
var letters = { "i": "İ", "ş": "Ş", "ğ": "Ğ", "ü": "Ü", "ö": "Ö", "ç": "Ç", "ı": "I" };
string = string.replace(/(([iışğüçö]))/g, function(letter){ return letters[letter]; })
return string.toUpperCase();
}
//asd
function autocomplete(inp, arr,new_class=null,click_show=false,selected_ok_fnc=null) {
/*the autocomplete function takes two arguments,
the text field element and an array of possible autocompleted values:*/
var currentFocus=-1;
/*execute a function when someone writes in the text field:*/
inp.addEventListener("input", function(e) {
var a, b, i, val = this.value;
var val_lower=val.turkishToLower();
/*close any already open lists of autocompleted values*/
if (!val) { return false;}
currentFocus = -1;
/*create a DIV element that will contain the items (values):*/
a = document.createElement("DIV");
a.setAttribute("id", this.id + "autocomplete-list");
if(new_class!=null)
a.setAttribute("class", "autocomplete-items "+ new_class);
else
a.setAttribute("class", "autocomplete-items");
/*append the DIV element as a child of the autocomplete container:*/
this.parentNode.appendChild(a);
/*for each item in the array...*/
for (i = 0; i < arr.length; i++) {
/*check if the item starts with the same letters as the text field value:*/
let index = arr[i].turkishToLower().indexOf(val_lower);
if (index!=-1) {
// if (arr[i].substr(0, val.length).turkishToLower() == val_lower) {
/*create a DIV element for each matching element:*/
b = document.createElement("DIV");
/*make the matching letters bold:*/
b.innerHTML = "" + arr[i] + "";
//b.innerHTML += arr[i].substr(val.length);
/*insert a input field that will hold the current array item's value:*/
b.innerHTML += "";
/*execute a function when someone clicks on the item value (DIV element):*/
b.addEventListener("click", function(e) {
/*insert the value for the autocomplete text field:*/
inp.value = this.getElementsByTagName("input")[0].value;
/*close the list of autocompleted values,
(or any other open lists of autocompleted values:*/
closeAllLists();
});
a.appendChild(b);
}
}
});
if(click_show==true)
{
inp.addEventListener("click", function(e) {
/*
setTimeout(function(){
var a = document.createElement("DIV");
a.setAttribute("id", inp.id + "autocomplete-list");
if (new_class != null)
a.setAttribute("class", "autocomplete-items " + new_class);
else
a.setAttribute("class", "autocomplete-items");
// Tüm önerileri göstermek için arr dizisini kullanabilirsiniz.
for (var i = 0; i < arr.length; i++) {
var b = document.createElement("DIV");
b.innerHTML = "" + arr[i] + "";
b.innerHTML += "";
b.addEventListener("click", function(e) {
inp.value = this.getElementsByTagName("input")[0].value;
closeAllLists();
});
a.appendChild(b);
}
inp.parentNode.appendChild(a);
}, 50);
*/
});
}
/*execute a function presses a key on the keyboard:*/
inp.addEventListener("keydown", function(e) {
var x = document.getElementById(this.id + "autocomplete-list");
if (x) x = x.getElementsByTagName("div");
if (e.keyCode == 40) {
/*If the arrow DOWN key is pressed,
increase the currentFocus variable:*/
currentFocus++;
/*and and make the current item more visible:*/
addActive(x);
} else if (e.keyCode == 38) { //up
/*If the arrow UP key is pressed,
decrease the currentFocus variable:*/
currentFocus--;
/*and and make the current item more visible:*/
addActive(x);
} else if (e.keyCode == 13||e.keyCode== 32) {
/*If the ENTER key is pressed, prevent the form from being submitted,*/
e.preventDefault();
if (currentFocus > -1) {
/*and simulate a click on the "active" item:*/
if (x) x[currentFocus].click();currentFocus=-1;
}
else if (e.keyCode==32 &¤tFocus > -1) {if (x) x[currentFocus].click();currentFocus=-1;}
else if(e.keyCode==32 &&(currentFocus <= -1||currentFocus==null)){ this.setRangeText(" ", this.selectionStart, this.selectionEnd, "end"); currentFocus=-1; e.returnValue = true;}
else if(e.keyCode==32){e.returnValue = true;}
}
});
function addActive(x) {
/*a function to classify an item as "active":*/
if (!x) return false;
/*start by removing the "active" class on all items:*/
removeActive(x);
if (currentFocus >= x.length) currentFocus = 0;
if (currentFocus < 0) currentFocus = (x.length - 1);
/*add class "autocomplete-active":*/
x[currentFocus].classList.add("autocomplete-active");
}
function removeActive(x) {
/*a function to remove the "active" class from all autocomplete items:*/
for (var i = 0; i < x.length; i++) {
x[i].classList.remove("autocomplete-active");
}
}
function closeAllLists(elmnt) {
/*close all autocomplete lists in the document,
except the one passed as an argument:*/
var x = document.getElementsByClassName("autocomplete-items");
for (var i = 0; i < x.length; i++) {
if (elmnt != x[i] && elmnt != inp) {
x[i].parentNode.removeChild(x[i]);
}
}
}
/*execute a function when someone clicks in the document:*/
document.addEventListener("click", function (e) {
closeAllLists(e.target);
if(selected_ok_fnc!=null)selected_ok_fnc();
});
}
function create_autocomplate_fox(elem,arr,class_name=null,click_show=false,selected_ok_fnc=null)
{
autocomplete(elem, arr,class_name,click_show,selected_ok_fnc);
}
function setStorage(name,value) {
localStorage.setItem(name, value);
if(value==null)localStorage.removeItem(name);
}
function getStorage(name) {
var rt_val=null;
try{
rt_val=localStorage.getItem(name);
}catch(err){ rt_val=null;}
return rt_val;
}
function clean_str(str)
{
cleanStr=str.replace(/[^a-zA-Z ]/g,"").turkishToLower().trim();;
return cleanStr;
}
function get_page_name(clean=false)
{
var page = location.pathname.substring(1);
if(clean==true)return clean_str(page);
return page;
}
function get_set_Storage(setting_name,setting_value=null)
{
var return_data="";
try{
var setting=getStorage(setting_name);
if(setting_value!=null)
{
setStorage(setting_name,setting_value);
}
return_data=setting;
}catch(err){}
return return_data;
}
function delete_saves_areas()
{
var var_keys="var_"+get_page_name(true)+"_";
for (var key in localStorage) {
if (key.startsWith(var_keys)) {
localStorage.removeItem(key);
}
}
}
var fox_dim_events_arr={};
function saved_areas(level="0",process_type="set_get") {
setTimeout(function(){
if(level=="0")level="";
var elems = document.getElementsByClassName("fox_saves"+level);
for (var q = 0; q < elems.length; q++) {
var elem = elems[q];
var type = elem.type;
var elem_id = elem.id;
var elem_value = elem.value;
var elem_key = "var_"+get_page_name(true)+"_"+elem_id;
if (type == "select-one") {
var setting = getStorage(elem_key);
if (setting != null) {
var select = document.getElementById(elem_id);
var options = select.options;
var hasSelected = false;
for (var i = 0; i < options.length; i++) {
if (options[i].hasAttribute("selected")) {
hasSelected = true;
}
}
if(process_type=="force_get"){hasSelected = false;}
if(hasSelected==true)break;
if (hasSelected == false) {
document.getElementById(elem_id).value = setting;
var event = new Event("change");
document.getElementById(elem_id).dispatchEvent(event);
}
}
if(process_type=="set"||process_type=="get_set"){
try{fox_dim_events_arr["another_f_event_"+elem_id]=document.getElementById(elem_id).onchange;}catch(err){}
document.getElementById(elem_id).onchange = function(previousOnChange) {
const old_elem_fnc=fox_dim_events_arr["another_f_event_"+this.id];
if (typeof old_elem_fnc === 'function') {
old_elem_fnc.call(this);
}
var options = this.options;
for (var i = 0; i < options.length; i++) {
if (options[i].value === this.value || options[i].text === this.value) {
this.value = options[i].value;
var elem_key = elem_key = "var_"+get_page_name(true)+"_"+this.id;;
var elem_value = this.value;
setStorage(elem_key, elem_value);
break;
}
}
};}
}
else if(type=="checkbox")
{
var setting = getStorage(elem_key);
if (setting != null) {
if(document.getElementById(elem_id).outerHTML.indexOf("checked")==-1||process_type=="force_get")
{
if(setting=="true")
document.getElementById(elem_id).checked = true;
else document.getElementById(elem_id).checked = false;
}
}
if(process_type=="set"||process_type=="get_set"){
try{fox_dim_events_arr["another_f_event_"+elem_id]=document.getElementById(elem_id).onchange;}catch(err){}
document.getElementById(elem_id).onchange = function(previousOnChange) {
const old_elem_fnc=fox_dim_events_arr["another_f_event_"+this.id];
if (typeof old_elem_fnc === 'function') {
old_elem_fnc.call(this);
}
var elem_key = elem_key = "var_"+get_page_name(true)+"_"+this.id;;
var elem_value = this.checked;
setStorage(elem_key, elem_value);
};}
}
else if(type=="textarea"||type=="email"||type=="text"||type=="number"||type=="password"||type=="date"||type=="datetime-local"||type=="time")
{
var setting = getStorage(elem_key);
if (setting != null) {
if(document.getElementById(elem_id).value==null||process_type=="force_get")
{
document.getElementById(elem_id).value = setting;
}
}
if(process_type=="set"||process_type=="get_set"){
try{fox_dim_events_arr["another_f_event_"+elem_id]=document.getElementById(elem_id).onkeyup;}catch(err){}
document.getElementById(elem_id).onkeyup = function(previousOnKeyUp) {
const old_elem_fnc=fox_dim_events_arr["another_f_event_"+this.id];
if (typeof old_elem_fnc === 'function') {
old_elem_fnc.call(this);
}
var elem_key = elem_key = "var_"+get_page_name(true)+"_"+this.id;;
var elem_value = this.value;
setStorage(elem_key, elem_value);
};}
}
}
}, 100*level);
}
function fox_uppercase()
{
var elems=document.getElementsByClassName("fox_touppercase");
for(var q=0;q {
fox_uppercase();
saved_areas("","get_set");
});
function get_ililce_exploded(name) {
var nameParts = name.trim().split(" ");
var firstName = nameParts.shift();
var lastName = nameParts.join(" ");
return [firstName, lastName];
}
function delegate_fnc(User_Func) {
const start = performance.now();
const response = User_Func();
const end = performance.now();
const total = end - start;
const total_ms = total.toFixed(3);
const total_sec = (total / 1000).toFixed(3);
var response_size = 0;
if(response!=null)response_size = response.length;
const response_data = response;
const dataSpeed = (response_size / total_ms) * 1000;
var speed_mbs = ((dataSpeed) / 1024/1024).toFixed(2);
if (isNaN(speed_mbs)) {speed_mbs=99999;}
return { start, end, total, total_ms, total_sec, speed: speed_mbs,speed_type:"MB/S",speed_str:speed_mbs+" MB/S", response: response_data };
}
/*delegate_fnc(function("test_data_arr") {
//console.log(response);
return response;//async =null;
});*/
function delegate_http_request(Url,POST_STR,ASYNC=false,User_Func)
{
const start = performance.now();
var returndata=null;
try{
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4) {
returndata=null;
if(this.status == 200)returndata=this.responseText;
const response = returndata;
const end = performance.now();
const total = end - start;
const total_ms = total.toFixed(3);
const total_sec = (total / 1000).toFixed(3);
var response_size = 0;
if(response!=null)response_size = response.length;
const response_data = response;
const dataSpeed = (response_size / total_ms) * 1000;
var speed_mbs = ((dataSpeed) / 1024/1024).toFixed(2);
if (isNaN(speed_mbs)) {speed_mbs=99999;}
fnc_data= { start, end, total, total_ms, total_sec, speed: speed_mbs,speed_type:"MB/S",speed_str:speed_mbs+" MB/S", response_size: response_size, response: response_data };
User_Func(fnc_data);
}
};
if(POST_STR.length>=1){
xhttp.open("POST",Url,ASYNC);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.send(POST_STR);
}
else {xhttp.open("GET",Url,ASYNC); xhttp.send();}
}
catch(err){ returndata=null;}
return returndata;
}
/*delegate_http_request("https://www.w3schools.com/","",true,function(response) {
//console.log(response);
return response;//async =null;
});*/
/*HEADER ZOOM olcek alani*/
function olcek_change(elem,typex="set")
{
try{
value=elem.value;
if(value==null||value=="")value=90;
if(typex=="get")
{
value=get_set_setting("olcek-settings",value);
if(value=="")value=100;
elem.value=value;
}
if(value>=50&&value<=150){
var zomlevel= (value/100);//1
var canvaslevel=1;
document.body.style.zoom = zomlevel;
setTimeout(function(){
var all_canvas=document.getElementsByTagName("canvas");
//modal
for(var i=0;i=1)
{
elemx.style.height="auto";
elemx.style.width="100%";
var new_zoom=(canvaslevel/zomlevel);
elemx.style.zoom = new_zoom;
}
}
}, 50);
get_set_setting("olcek-settings",value);
}
}catch(err){}
}
generate_settimeoutfunc(function() {olcek_change(document.getElementById('olcek_elem'),'get');},5);
document.addEventListener("DOMContentLoaded", function() {
generate_settimeoutfunc(function() {olcek_change(document.getElementById('olcek_elem'),'get');},50);
});
function add_elem_html(el=document.body, html)
{
var div = document.createElement('div'); //container to append to
div.innerHTML = html;
el.appendChild(div);
var codes = div.getElementsByTagName("script");
for(var i=0;iGrafik İşleme: "+delegate_return["total_sec"]+" SN";}catch(err){}
});
}, 50);
}
}
if (document.readyState === "complete" || document.readyState === "loaded") {
code_fnc();
} else {
document.addEventListener("DOMContentLoaded", function() {
code_fnc();
});
}
}
function create_loading_div(elem_id,source_elem=document.body)
{
var loading_elem='
';
var div = document.createElement('div');
div.id="loading_"+elem_id;
div.innerHTML = loading_elem;
source_elem.appendChild(div);
}
function close_loading_div(elem_id)
{
try{
document.getElementById("loading_"+elem_id).outerHTML="";
}catch(err){}
}
function user_select_create_country_select(element,elem_id='user_select_city',district_elem_id='user_select_district')
{
try{
if(element.value!=null)
{
var selectedIndex = element.selectedIndex;
//console.log(selectedIndex);
var selectedOptionId = element.options[selectedIndex].dataset.id;
var url= "/Apps/Api/AppApi/GlobalApi/il_ilce_apiv3.php?id="+selectedOptionId+"&request=get_cities";
FOX_ASYNCED.Async_Delegate_Serial_Request(url,"",null,false,function(response_arr) {
var response=response_arr["response"];
if(response!=null)
{
const jsonvalue = JSON.parse(response);
if(jsonvalue["STATUS"]=="SUCCESS")
{
document.getElementById(elem_id).innerHTML=jsonvalue["VALUE"];
}
if(district_elem_id!=null){
user_select_create_city_select(document.getElementById(elem_id),district_elem_id);
}
}
});
}
}catch(err){}
}
function user_select_create_city_select(element,elem_id='user_select_district')
{
try{
var selectedIndex = element.selectedIndex;
var selectedOptionId = element.options[selectedIndex].dataset.id;
if(selectedOptionId!=null)
{
var url= "/Apps/Api/AppApi/GlobalApi/il_ilce_apiv3.php?id="+selectedOptionId+"&request=get_districts";
FOX_ASYNCED.Async_Delegate_Serial_Request(url,"",null,false,function(response_arr) {
var response=response_arr["response"];
if(response!=null)
{
const jsonvalue = JSON.parse(response);
if(jsonvalue["STATUS"]=="SUCCESS")
{
document.getElementById(elem_id).innerHTML=jsonvalue["VALUE"];
}
}
});
}
}catch(err){}
}
function formserialize(form) {
var field, s = [];
if (typeof form == 'object' && form.nodeName == "FORM") {
var len = form.elements.length;
for (var i=0; i=0; j--) {
if(field.options[j].selected)
s[s.length] = encodeURIComponent(field.name) + "=" + encodeURIComponent(field.options[j].value);
}
} else if ((field.type != 'checkbox' && field.type != 'radio') || field.checked) {
s[s.length] = encodeURIComponent(field.name) + "=" + encodeURIComponent(field.value);
}
}
}
}
return s.join('&').replace(/%20/g, '+');
}
function formSerializeToJSON(form) {
var json = {};
if (typeof form == 'object' && form.nodeName == "FORM") {
var len = form.elements.length;
for (var i = 0; i < len; i++) {
var field = form.elements[i];
if (field.name && !field.disabled && field.type !== 'file' && field.type !== 'reset' && field.type !== 'submit' && field.type !== 'button') {
if (field.type === 'select-multiple') {
var selectedValues = [];
for (var j = field.options.length - 1; j >= 0; j--) {
if (field.options[j].selected) {
selectedValues.push(field.options[j].value);
}
}
json[field.name] = selectedValues;
} else if ((field.type !== 'checkbox' && field.type !== 'radio') || field.checked) {
json[field.name] = field.value;
}
}
}
}
return json;
}
function base64_decode(str) {
// Base64'den Unicode karakterlere dönüştürme
return decodeURIComponent(
atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join('')
);
}
function base64_encode(str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
return String.fromCharCode(parseInt(p1, 16))
}));
}
//File upload FNCS
var upload_files_json_datas;
var obj_file_upload_func=null;
function show_file_upload_modal(funtion_data=null,folder="other",typex="file",max_mb="5",user_id=null) {
var elem_cnt=document.getElementById("FileUploadModalForm");
if(elem_cnt==null)
{
delegate_http_request("/Apps/Api/FoxdimApi/Drive/generate_file_upload_modal.php","",false,function(response) {
var html_data=response["response"];
add_elem_html(document.body,html_data);
});
}
$("#FileUploadModalForm").modal("show");
document.getElementById("dropZone").src="/Apps/Api/FoxdimApi/Drive/FileUploadFrame.php?max_mb="+max_mb+"&u_id="+0+"&type="+typex+"&folder="+folder;
obj_file_upload_func=funtion_data;
}
function close_file_upload_modal(close_type='0') {
try{
var iframe = document.getElementById("dropZone");
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
var close_status=innerDoc.getElementById("fileuploader_modal_close_status").value;
if(close_status=="1")
{
$("#FileUploadModalForm").modal("hide");
if(close_type=='1')
{
upload_files_json_datas=innerDoc.getElementById("fileuploader_modal_json_data").value;
if(obj_file_upload_func!=null)obj_file_upload_func(upload_files_json_datas);
upload_files_json_datas=null;
}
}
}catch(err){}
}
function city_change(element)
{
try{
var selectedIndex = element.selectedIndex;
var selectedOptionId = element.options[selectedIndex].dataset.id;
if(selectedOptionId!=null)
{
var url= "/Apps/Api/AppApi/GlobalApi/il_ilce_apiv3.php?id="+selectedOptionId+"&request=get_districts";
delegate_http_request(url,"",true,function(response_arr) {
var response=response_arr["response"];
if(response!=null)
{
const jsonvalue = JSON.parse(response);
if(jsonvalue["STATUS"]=="SUCCESS")
{
user_select_district.innerHTML='';
user_select_district.innerHTML+=jsonvalue["VALUE"];
}
}
});
}
}catch(err){}
}
function create_package_pay_control(id,elem=null)
{
var form_post_data="id="+id;
var url="/Apps/Api/AppApi/FirmaApi/PackagePayControlApi.php";
var xasync=true;
delegate_http_request(url,form_post_data,xasync,function(response_arr) {
var response=response_arr["response"];
if(response!=null)
{
const jsonvalue = JSON.parse(response);
if(jsonvalue["STATUS"]=="SUCCESS")
{
if(elem!=null)
{
elem.outerHTML="";
}
notify(value=jsonvalue["VALUE"],
title="ÖDEME YAPILDI",type="success",positionClass="toast-bottom-center");
}
else if(jsonvalue["STATUS"]=="INFO")
{
var url=jsonvalue["URL"];
if(url!=null){
if(url.length>=3)
{
setTimeout(function(){ window.location.replace(url); }, 3000);
}
}
notify(value=jsonvalue["VALUE"],
title="BAKIYE YETERSİZ",type="info",positionClass="toast-bottom-center");
}
else
{
notify(value=jsonvalue["VALUE"],
title="ÖDEME HATASI",type="error",positionClass="toast-bottom-center");
}
}
});
}
function addScript_element(el=document.body, src,code ) {
var s = document.createElement( 'script' );
s.type="text/javascript"
if(src!=null)s.setAttribute( 'src', src );
if(code!=null){; s.innerHTML=code;}
el.appendChild(s);
}
function addStyle_element(el=document.body, src,code ) {
var s = null;
if(src==null)s=document.createElement( 'style' );
else s=document.createElement( 'link' );
s.rel="stylesheet"
if(src!=null)s.setAttribute( 'href', src );
if(code!=null){; s.innerHTML=code;}
el.appendChild(s);
}
function insertHtml_element(el = document.body, html, atEnd = true) {
var div = document.createElement('div'); //container to append to
div.innerHTML = html;
if (atEnd) {
el.appendChild(div);
} else {
el.insertBefore(div, el.firstChild);
}
var codes = div.getElementsByTagName("script");
for (var i = 0; i < codes.length; i++) {
eval(codes[i].innerHTML);
}
}
function salert(baslik=null,mesaj=null,type=null,redirurl=null,confirm_btn_text="Tamam")
{
if(baslik!=null)
{
try{
Swal.fire({
title: baslik,
icon: type,
html: ""+mesaj,
confirmButtonText: confirm_btn_text,
}).then(function() { if(redirurl!=null) location.href=redirurl; });
}catch(err){if(redirurl!=null) location.href=redirurl;}}
}
function salert2(baslik=null,mesaj=null,type=null,confirm_btn_text="Evet",deny_btn_text="Hayır",cancel_btn_text="İptal",user_fnc=null)
{
if(baslik!=null)
{
try{
var denyBtnStatus=false;
var cancelBtnStatus=false;
if(deny_btn_text!=null)denyBtnStatus=true;
if(cancel_btn_text!=null)cancelBtnStatus=true;
Swal.fire({
title: baslik,
icon: type,
html: ""+mesaj,
showDenyButton: denyBtnStatus,
showCancelButton: cancelBtnStatus,
confirmButtonText: confirm_btn_text,
denyButtonText: deny_btn_text,
cancelButtonText: cancel_btn_text,
}).then((result) => {
if (result.isConfirmed) {
if(user_fnc!=null){user_fnc("confirm");}
} else if (result.isDenied) {
user_fnc("deny");
}
});
}catch(err){if(user_fnc!=null){user_fnc("cancel");}}
}
}
function salert3(baslik="Test",mesaj="Test Mesajı",type="info",confirm_btn_text="Evet",deny_btn_text="Hayır",cancel_btn_text="İptal",user_fnc=null)
{
if(baslik!=null)
{
try{
var denyBtnStatus=false;
var cancelBtnStatus=false;
if(deny_btn_text!=null)denyBtnStatus=true;
if(cancel_btn_text!=null)cancelBtnStatus=true;
Swal.fire({
title: baslik,
icon: type,
html: ""+mesaj,
showDenyButton: denyBtnStatus,
showCancelButton: cancelBtnStatus,
confirmButtonText: confirm_btn_text,
denyButtonText: deny_btn_text,
cancelButtonText: cancel_btn_text,
}).then((result) => {
if (result.isConfirmed) {
if(user_fnc!=null){user_fnc(true);}
} else if (result.isDenied) {
if(user_fnc!=null){user_fnc(false);}
}
});
}catch(err){console.log(err)}
}
}
document.addEventListener("DOMContentLoaded", function(){
try{
var elem=document.getElementById("foxdim-overlay-loading");
if(elem!=null)
{
setTimeout(function(){ elem.classList.remove("foxdim-overlay-loading");}, 400);
}
}
catch(err){}
});
/*
window.addEventListener('beforeunload', function (event) {
try{
var elem=document.getElementById("foxdim-overlay-loading");
if(elem!=null)
{
elem.classList.add("foxdim-overlay-loading");
}
}
catch(err){}
});
*/
///////////////////////CLASS AREA//////////////////////////////
class FOXDIM_Asynced_Functions {
constructor() {
this.asynced_func_arr = [];
this.asynced_func_run_status = false;
this.asynced_func_interval = setInterval(this.asynced_func_controller.bind(this), 50);
}
formserialize(form) {
var field, s = [];
if (typeof form == 'object' && form.nodeName == "FORM") {
var len = form.elements.length;
for (var i=0; i=0; j--) {
if(field.options[j].selected)
s[s.length] = encodeURIComponent(field.name) + "=" + encodeURIComponent(field.options[j].value);
}
} else if ((field.type != 'checkbox' && field.type != 'radio') || field.checked) {
s[s.length] = encodeURIComponent(field.name) + "=" + encodeURIComponent(field.value);
}
}
}
}
return s.join('&').replace(/%20/g, '+');
}
asynced_func_controller() {
/*
var status=this.asynced_func_run_status;
if(status==false)
{
thatx.asynced_func_run_status_change(true);
Async_Send_Serial_Request(Url,POST_STR,POST_ELEM,User_Func)
}
*/
var status=this.asynced_func_run_status;
if (status == false && this.asynced_func_arr.length >= 1) {
this.asynced_func_run_status_change(true);
this.asynced_func_arr[0]();
this.asynced_remove_index_arr();
}
}
asynced_remove_index_arr()
{
if(this.asynced_func_arr[0] != null)
{this.asynced_func_arr.splice(0, 1);}
}
asynced_func_run_status_change(status=false)
{
this.asynced_func_run_status=status;
}
Request(Url,POST_STR,POST_ELEM=null,ASYNC=false,User_Func)
{
return this.Async_Delegate_Serial_Request(Url,POST_STR,POST_ELEM,ASYNC,User_Func);
}
Async_Request(Url,POST_STR,POST_ELEM=null,ASYNC=true,User_Func)
{
return this.Async_Delegate_Serial_Request(Url,POST_STR,POST_ELEM,ASYNC,User_Func);
}
Async_Serial_Request(Url,POST_STR,POST_ELEM=null,User_Func)
{
this.asynced_func_arr.push(() => this.Async_Send_Serial_Request(Url,POST_STR,POST_ELEM,User_Func));
}
Async_Send_Serial_Request(Url,POST_STR,POST_ELEM=null,User_Func)
{
var thatx = this;
thatx.asynced_func_run_status_change(true);
if(POST_STR==null)POST_STR="";
const start = performance.now();
var returndata=null;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4) {
returndata=null;
if(this.status == 200)returndata=this.responseText;
const response = returndata;
const end = performance.now();
const total = end - start;
const total_ms = total.toFixed(3);
const total_sec = (total / 1000).toFixed(3);
var response_size = 0;
if(response!=null)response_size = response.length;
const response_data = response;
const dataSpeed = (response_size / total_ms) * 1000;
var speed_mbs = ((dataSpeed) / 1024/1024).toFixed(2);
if (isNaN(speed_mbs)) {speed_mbs=99999;}
var fnc_data= { start, end, total, total_ms, total_sec, speed: speed_mbs,speed_type:"MB/S",speed_str:speed_mbs+" MB/S", response_size: response_size, response: response_data };
try{User_Func(fnc_data);}catch(err){}
thatx.asynced_func_run_status_change(false);
}
};
if(POST_ELEM!=null){
//console.log(POST_ELEM);
if(POST_STR.length>=1){POST_STR=POST_STR+"&"+this.formserialize(POST_ELEM);}
else {POST_STR=this.formserialize(POST_ELEM);}
}
if(POST_STR.length>=1){
xhttp.open("POST",Url,true);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.send(POST_STR);
}
else {xhttp.open("GET",Url,true); xhttp.send();}
/*try{ }
catch(err){ thatx.asynced_func_run_status_change(false);}*/
return returndata;
}
Send_Request(Url,POST_STR,POST_ELEM=null,ASYNC=false,User_Func)
{
var thatx = this;
const start = performance.now();
var returndata=null;
try{
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4) {
returndata=null;
if(this.status == 200)returndata=this.responseText;
const response = returndata;
const end = performance.now();
const total = end - start;
const total_ms = total.toFixed(3);
const total_sec = (total / 1000).toFixed(3);
var response_size = 0;
if(response!=null)response_size = response.length;
const response_data = response;
const dataSpeed = (response_size / total_ms) * 1000;
var speed_mbs = ((dataSpeed) / 1024/1024).toFixed(2);
if (isNaN(speed_mbs)) {speed_mbs=99999;}
var fnc_data= { start, end, total, total_ms, total_sec, speed: speed_mbs,speed_type:"MB/S",speed_str:speed_mbs+" MB/S", response_size: response_size, response: response_data };
try{User_Func(fnc_data);}catch(err){}
}
};
if(POST_ELEM!=null){
if(POST_STR.length>=1){POST_STR=POST_STR+"&"+this.formserialize(POST_ELEM);}
else {POST_STR=this.formserialize(POST_ELEM);}
}
if(POST_STR.length>=1){
xhttp.open("POST",Url,ASYNC);
xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.send(POST_STR);
}
else {xhttp.open("GET",Url,ASYNC); xhttp.send();}
}
catch(err){}
return returndata;
}
Async_Delegate_Serial_Request(Url,POST_STR,POST_ELEM=null,ASYNC=false,User_Func) {
if (ASYNC==true) { //fonksyion çalışıyorsa ve dizi dolu ise diziye kaydet ve return at.
this.Async_Serial_Request(Url,POST_STR,POST_ELEM,User_Func);
}
else
{
return this.Send_Request(Url,POST_STR,POST_ELEM=null,ASYNC=false,User_Func);
}
}
}
const FOX_ASYNCED = new FOXDIM_Asynced_Functions();
//page_full_load
document.addEventListener("DOMContentLoaded", function(){
try{
var modex=document.getElementsByTagName("html")[0].className.indexOf("dark-style");
var mode="ligth";
if(modex>=0){
//console.log("dark mode");
mode="dark";
}
else
{
//console.log("light mode");
mode="light";
}
var elements = document.querySelectorAll('[data-lightsrc]');
elements.forEach(function(element) {
try{
var darkSrc = element.getAttribute('data-darksrc');
var lightSrc = element.getAttribute('data-lightsrc');
var new_src=lightSrc;
if(mode=="dark"&&darkSrc!=null)
{new_src=darkSrc;}
else
{new_src=lightSrc;}
element.src=new_src;
}catch(err){}
});
}catch(err){}
});