function microtime(get_as_float) { var unixtime_ms = new Date().getTime(); var sec = parseInt(unixtime_ms / 1000); return get_as_float ? (unixtime_ms/1000) : (unixtime_ms - (sec * 1000))/1000 + ' ' + sec; } function ajax_post(url, pass_data, ok_script, retry_times, retry_timeout) { var AJAX_start = microtime(true); if(typeof retry_times === "undefined") { var retry_times = 5; } if(typeof retry_timeout === "undefined") { var retry_timeout = 10000; } // var timeout = 10000; pass_data.ajax_url = url; $.ajax({ url : url, type : 'POST', data : pass_data, tryCount : 0, retryLimit : retry_times, timeout: retry_timeout, success : ok_script, error : function(xhr, textStatus, errorThrown ) { this.tryCount++; if (errorThrown=='timeout' && this.tryCount <= this.retryLimit) { console.log("Ajax timeout on try " + this.tryCount + ', timeout ' + this.timeout); this.timeout = this.timeout + 5000; $.ajax(this); return; } console.error('AJAX error in file: /home/ukaucic/domains/kaucic.si/public_html/core/ajax_functions.php, PHPline: 135', xhr, textStatus, errorThrown); if(this.retryLimit>0) { location.reload(); } return; } }).done(function(data) { }); } function setCookie(name, value, expires) { var potece = new Date(); potece.setTime(potece.getTime() + expires * 1000); var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + potece.toGMTString() : "") + "; path=/"; document.cookie = curCookie; } function getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) end = dc.length; return unescape(dc.substring(begin + prefix.length, end)); } function deleteCookie(name) { var path_prefix = '/'; var domain = 'www.gostilnanakmetiji-kaucic.si'; var domain_no_www = '.www.gostilnanakmetiji-kaucic.si'; console.log('deleting cookie: ' + name + "=" + "; expires=Thu, 01-Jan-1970 00:00:01 GMT" + "; domain=" + domain + "; path=" + path_prefix); document.cookie = name + "=" + "; expires=Thu, 01-Jan-1970 00:00:01 GMT" + "; domain=" + domain + "; path=" + path_prefix; console.log('deleting cookie: ' + name + "=" + "; expires=Thu, 01-Jan-1970 00:00:01 GMT" + "; domain=" + domain_no_www + "; path=" + path_prefix); document.cookie = name + "=" + "; expires=Thu, 01-Jan-1970 00:00:01 GMT" + "; domain=" + domain_no_www + "; path=" + path_prefix; console.log('deleting cookie: ' + name + "=" + "; expires=Thu, 01-Jan-1970 00:00:01 GMT" + "; path=" + path_prefix); document.cookie = name + "=" + "; expires=Thu, 01-Jan-1970 00:00:01 GMT" + "; path=" + path_prefix; } $.fn.tooltip.defaults.position = 'right'; $.fn.tooltip.defaults.showDelay = 1000; $.fn.tooltip.defaults.hideDelay = 500; $.fn.validatebox.defaults.delay = 0; $.fn.validatebox.defaults.showDelay = 0; $.fn.validatebox.defaults.hideDelay = 0; $.fn.tooltip.defaults.deltaX = 0; $.fn.tooltip.defaults.deltaX = 0; $.fn.calendar.defaults.firstDay = 1; $.fn.datebox.defaults.panelWidth = 200; $.fn.datebox.defaults.height = 19; $.fn.datetimebox.defaults.panelWidth = 200; $.fn.datetimebox.defaults.height = 19; $.fn.pagination.defaults.layout = ['first', 'prev', 'manual', 'next', 'last', 'sep', 'list', 'sep', 'refresh']; $.fn.datagrid.defaults.filterDelay = 1000; $.fn.menu.defaults.duration = 1000; $.extend($.fn.window.methods, { fixed: function(jq){ return jq.each(function(){ var opts = $(this).window('options'); var shadow = $(this).data('window').shadow; $(this).panel('options').onMove = function(left,top){ var p = $(this).panel('panel'); setTimeout(function(){ p.add($(shadow)).css({ position:'fixed', top: p.offset().top-$(document).scrollTop() }); },0); opts.onMove.call(this, left, top); } $(this).window('window').draggable({ onBeforeDrag:function(e){ e.data.startTop = $(this).offset().top; } }); $(this).window('move'); }) } }) $.extend($.fn.validatebox.defaults.rules, { past: { validator: function(value, param){ var ss = value.split('.'); var d = parseInt(ss[0],10); var m = parseInt(ss[1],10); var y = parseInt(ss[2],10); entered_date = new Date(y,m-1,d); today = new Date; return entered_date <= today; }, message: 'Datum ne more biti v prihodnosti!' } , phone: { validator: function(value, param){ var chars_test = value.replace(/[0-9\-\.\(\)\+\/ ]/gi, ''); if(chars_test!=='') { return false; } var number_test = value.replace(/[^0-9]/gi, ''); if(number_test.length<9) { return false; } return true; }, message: 'Vpišite veljavno telefonsko številko. ' } , emails: { // validacija za več emailov hkrati - razbije besedilo, ki je ločeno z vejicami in preverja vsak del posebej validator: function(value, param){ var emails = value.split(","); var is_valid = true; emails.forEach(function (email) { is_valid = $.fn.validatebox.defaults.rules.email.validator(email.trim()) ? is_valid : false; }); return is_valid; }, message: 'Prosimo, vnesite veljavne elektronske naslove, ločene z vejicami.' } }); $.fn.datebox.defaults.formatter = function(date){ if(date.valueOf() == new Date(0).valueOf()) { return ''; } else { var y = date.getFullYear(); var m = date.getMonth()+1; var d = date.getDate(); return (d<10?('0'+d):d) + '.' + (m<10?('0'+m):m) + '.' + y; } } $.fn.datetimebox.defaults.formatter = function(date){ if(date.valueOf() == new Date(0).valueOf()) { return ''; } else { var y = date.getFullYear(); var m = date.getMonth()+1; var d = date.getDate(); var h = date.getHours(); var n = date.getMinutes(); var s = date.getSeconds(); return (d<10?('0'+d):d) + '.' + (m<10?('0'+m):m) + '.' + y + ' ' + (h<10?('0'+h):h) + ':' + (n<10?('0'+n):n) + ':' + (s<10?('0'+s):s); } } $.fn.datebox.defaults.parser = function(s){ var today = new Date(); var ss = s.split('.'); if(ss.length<=1) { ss = s.split('/'); } if(ss.length<=1) { ss = s.split('-'); } var d = parseInt(ss[0],10); if(isNaN(d)) { d = today.getDate(); } var m = parseInt(ss[1],10); if(isNaN(m)) { m = today.getMonth() + 1; } var y = parseInt(ss[2],10); if(isNaN(y)) { y = today.getFullYear(); } if(y<100) { y = y + 2000; } if (!isNaN(y) && !isNaN(m) && !isNaN(d)){ return new Date(y,m-1,d); } else { return new Date(); } } $.fn.datetimebox.defaults.parser = function(s){ return easyui_datetimebox_parser(s, 'now'); } function easyui_datetimebox_parser(s, time_of_day) { var today = new Date(); if(typeof time_of_day === "undefined") { time_of_day = 'now'; } if(time_of_day == 'end' || time_of_day == '23:59:59') { var shours = 23; // default var sminutes = 59; // default var sseconds = 59; // default } else if(time_of_day == 'start' || time_of_day == '0:00:00' || time_of_day == '00:00:00' || time_of_day == 0) { var shours = 0; // default var sminutes = 0; // default var sseconds = 0; // default } else { var shours = today.getHours(); var sminutes = today.getMinutes(); var sseconds = today.getSeconds(); } var sdt = s.split(' '); if(sdt.length==2) { st = new Date('2000/01/01 '+sdt[1]); var shours = st.getHours(); var sminutes = st.getMinutes(); var sseconds = st.getSeconds(); } var sd = sdt[0].split('.'); if(sd.length<=1) { sd = sdt[0].split('/'); } if(sd.length<=1) { sd = sdt[0].split('-'); } var d = parseInt(sd[0],10); if(isNaN(d)) { d = today.getDate(); } var m = parseInt(sd[1],10); if(isNaN(m)) { m = today.getMonth() + 1; } var y = parseInt(sd[2],10); if(isNaN(y)) { y = today.getFullYear(); } if(y<100) { y = y + 2000; } if (!isNaN(y) && !isNaN(m) && !isNaN(d)){ return new Date(y, m-1, d, shours, sminutes, sseconds, 0); } else { return new Date(); } } $(document).on('click', '.uc_editors_only', function(e) { if(e.offsetY < 0) { $.messager.alert( '' , '' , 'info' ); } }); $(document).on('blur', '.datebox .combo-text', function() { // za datetimebox var textbox = $(this).parent().prev('.easyui-datetimebox'); if(textbox.length>0) { var datetimebox_value = textbox.datetimebox('getValue'); if(datetimebox_value=='') { if(textbox.val()!=datetimebox_value) { textbox.val(''); textbox.change(); } } else { var opts = textbox.datetimebox('options'); datetimebox_value = opts.formatter(opts.parser(datetimebox_value)); textbox.datetimebox('setValue', datetimebox_value); if(textbox.val()!=datetimebox_value) { textbox.val(datetimebox_value); textbox.change(); } } } // za datebox - ista koda, samo da je namesto datetimebox vedno datebox var textbox = $(this).parent().prev('.easyui-datebox'); if(textbox.length>0) { var datebox_value = textbox.datebox('getValue'); if(datebox_value=='') { if(textbox.val()!=datebox_value) { textbox.val(''); textbox.change(); } } else { var opts = textbox.datebox('options'); datebox_value = opts.formatter(opts.parser(datebox_value)); textbox.datebox('setValue', datebox_value); if(textbox.val()!=datebox_value) { textbox.val(datebox_value); textbox.change(); } } } }); $.fn.datebox.defaults.onChange = function(newValue, oldValue) { $(this).val(newValue).change(); if($(this).hasClass('easyui-validatebox')) { $(this).validatebox('validate'); } } $.fn.datetimebox.defaults.onChange = function(newValue, oldValue) { $(this).val(newValue).change(); if($(this).hasClass('easyui-validatebox')) { $(this).validatebox('validate'); } } $.fn.spinner.defaults.onChange = function(newValue, oldValue) { $(this).val(newValue).change(); if($(this).hasClass('easyui-validatebox')) { $(this).validatebox('validate'); } } $.fn.numberspinner.defaults.onChange = function(newValue, oldValue) { $(this).val(newValue).change(); if($(this).hasClass('easyui-validatebox')) { $(this).validatebox('validate'); } } function uc_deselect_text() { if (window.getSelection) { if (window.getSelection().empty) { window.getSelection().empty(); } else if (window.getSelection().removeAllRanges) { window.getSelection().removeAllRanges(); } } else if (document.selection) { document.selection.empty(); } } var dateFormat = function () { var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, timezoneClip = /[^-+\dA-Z]/g, pad = function (val, len) { val = String(val); len = len || 2; while (val.length < len) val = "0" + val; return val; }; return function (date, mask, utc) { var dF = dateFormat; if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { mask = date; date = undefined; } date = date ? new Date(date) : new Date; if (isNaN(date)) throw SyntaxError("invalid date"); mask = String(dF.masks[mask] || mask || dF.masks["default"]); if (mask.slice(0, 4) == "UTC:") { mask = mask.slice(4); utc = true; } var _ = utc ? "getUTC" : "get", d = date[_ + "Date"](), D = date[_ + "Day"](), m = date[_ + "Month"](), y = date[_ + "FullYear"](), H = date[_ + "Hours"](), M = date[_ + "Minutes"](), s = date[_ + "Seconds"](), L = date[_ + "Milliseconds"](), o = utc ? 0 : date.getTimezoneOffset(), flags = { d: d, dd: pad(d), ddd: dF.i18n.dayNames[D], dddd: dF.i18n.dayNames[D + 7], m: m + 1, mm: pad(m + 1), mmm: dF.i18n.monthNames[m], mmmm: dF.i18n.monthNames[m + 12], yy: String(y).slice(2), yyyy: y, h: H % 12 || 12, hh: pad(H % 12 || 12), H: H, HH: pad(H), M: M, MM: pad(M), s: s, ss: pad(s), l: pad(L, 3), L: pad(L > 99 ? Math.round(L / 10) : L), t: H < 12 ? "a" : "p", tt: H < 12 ? "am" : "pm", T: H < 12 ? "A" : "P", TT: H < 12 ? "AM" : "PM", Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""), o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10] }; return mask.replace(token, function ($0) { return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); }); }; }(); dateFormat.masks = { "default": "dd.mm.yyyy HH:MM:ss", shortDate: "m/d/yy", mediumDate: "mmm d, yyyy", longDate: "mmmm d, yyyy", fullDate: "dddd, mmmm d, yyyy", shortTime: "h:MM TT", mediumTime: "h:MM:ss TT", longTime: "h:MM:ss TT Z", isoDate: "yyyy-mm-dd", isoTime: "HH:MM:ss", isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" }; dateFormat.i18n = { dayNames: $.fn.calendar.defaults.weeks, monthNames: $.fn.calendar.defaults.months, }; Date.prototype.format = function (mask, utc) { return dateFormat(this, mask, utc); }; function trim(str, chars) { return ltrim(rtrim(str, chars), chars); } function ltrim(str, chars) { chars = chars || "\\s"; return str.replace(new RegExp("^[" + chars + "]+", "g"), ""); } function rtrim(str, chars) { chars = chars || "\\s"; return str.replace(new RegExp("[" + chars + "]+$", "g"), ""); } function now(format) { if(format===undefined) { format = 'dd.mm.yyyy HH:MM:ss'; } var d = new Date(); return d.format(format); } function date(days_from_now, format) { if(format===undefined) { format = 'dd.mm.yyyy'; } if(days_from_now===undefined) { days_from_now = 0; } var d = new Date(); d.setDate(d.getDate() + days_from_now); return d.format(format); } var uc_download_check_count = 0; var uc_download_check_max_count = 10; var uc_download_check_interval = 1000; var uc_download_complete_function = null; function uc_download_check(complete_function) { uc_download_check_count++; if(typeof complete_function !== 'undefined') { uc_download_check_count = 1; uc_download_complete_function = complete_function; } if(uc_download_check_count <= uc_download_check_max_count) { if(getCookie('uc_download')) { setTimeout('uc_download_check()', uc_download_check_interval); } else { deleteCookie('uc_download'); uc_download_complete_function(); } } else { } } var uc_last_active_editor = null; var tinymce_init_user = { selector: ".uc_edit_user" , theme: "modern" , plugins: "advlist autolink charmap code colorpicker contextmenu fullscreen image link lists media nonbreaking noneditable paste searchreplace table textcolor visualblocks visualchars wordcount" , add_unload_trigger: false , schema: "html5" , language: 'sl_SI' , inline: true , image_advtab: true , object_resizing: true , menubar: false , statusbar: false , toolbar1: "bold italic underline strikethrough removeformat | undo redo | alignleft aligncenter alignright alignjustify | cut copy paste pastetext | bullist numlist | link unlink | nonbreaking charmap image media | searchreplace " , fontsize_formats: "6px 8px 9px 10px 11px 12px 13px 14px 15px 16px 18px 20px 24px 28px 32px 36px 40px 48px" , style_formats: [ {title: 'Odstavek', block: 'p'} , {title: 'Naslov', block: 'h1'} , {title: 'Podnaslov', block: 'h2'} , {title: 'Pod-podnaslov', block: 'h3'} , {title: 'Citat', block: 'pre'} ] , textcolor_map: [ "000000", "Črna", "993300", "Kamin oranžna", "333300", "Temno olivna", "003300", "Temno zelena", "003366", "Temno azurna", "000080", "Mornarsko modra", "333399", "Indigo", "444444", "Zelo temno siva", "CCCCCC", "Svetlo siva", "800000", "Kostanjeva", "FF6600", "Oranžna", "808000", "Olivna", "008000", "Zelena", "008080", "Zelenomodra", "0000FF", "Modra", "666699", "Sivomodra", "666666", "Temno siva", "DDDDDD", "Zelo svetlo siva", "FF0000", "Rdeča", "FF9900", "Jantarjeva", "99CC00", "Rumenozelena", "339966", "Morsko zelena", "33CCCC", "Turkizna", "3366FF", "Kraljevsko modra", "800080", "Vijolična", "888888", "Rahlo temno siva", "EEEEEE", "Skoraj bela", "FF00FF", "Škrlatna", "FFCC00", "Zlata", "FFFF00", "Rumena", "00FF00", "Limetna", "00FFFF", "Vodna", "00CCFF", "Nebesno modra", "993366", "Rjava", "AAAAAA", "Siva", "FFFFFF", "Bela", "FF99CC", "Roza", "FFCC99", "Breskova", "FFFF99", "Svetlo rumena", "CCFFCC", "Bledo zelena", "CCFFFF", "Bledo modrozelena", "99CCFF", "Svetlo nebesno modra", "CC99FF", "Slivova", "BBBBBB", "Rahlo svetlo siva" ] , textcolor_rows: 5 , textcolor_cols: 9 , entity_encoding : "raw" , relative_urls : false , convert_urls : true , remove_script_host : true , document_base_url : "http://www.gostilnanakmetiji-kaucic.si/" , setup: function(editor) { editor.off('PreInit'); editor.on('PreInit', function(e) { if($('[href="/core/edit_tinymce.css?rand=1440510436"]').length==0) { $('head').append( $('').attr('href', '/core/edit_tinymce.css?rand=1440510436') ); } }); editor.off('focus'); editor.on('focus', function(e) { uc_last_active_editor = editor; // editor.isNotDirty = false; }); } }; $(window).off('beforeunload'); $(window).on('beforeunload', function(){ if(uc_last_active_editor && uc_last_active_editor.isDirty()) { var uc_editor_dataset = uc_last_active_editor.getElement().dataset; if(uc_editor_dataset.save_before_unload=="false") { return "POZOR: Nekateri podatki na strani niso shranjeni. \nČe zapustite stran, boste morda izgubili te podatke." } else { var new_value = uc_last_active_editor.getContent(); ajax_post( '/core/edit_functions.php', { ajax: 'edit_field_save' , PHPfile: '/home/ukaucic/domains/kaucic.si/public_html/core/functions.js.php' , PHPline: 701 , object_id: uc_editor_dataset.id , lang: 'sl' , table: uc_editor_dataset.table , key_field: uc_editor_dataset.key_field , key_value: uc_editor_dataset.key_value , field: uc_editor_dataset.field , new_value: new_value } ); } } }); function tinymce_destroy_all() { if(typeof(tinyMCE) !== 'undefined') { var length = tinyMCE.editors.length; for (var i=length; i>0; i--) { tinyMCE.editors[i-1].destroy(); }; } } function tinymce_destroy_selector(selector) { // console.log(tinymce.editors); if(typeof(tinyMCE) !== 'undefined') { var length = tinyMCE.editors.length; for (var i=length; i>0; i--) { if(tinyMCE.editors[i-1].selector==selector) { tinyMCE.editors[i-1].destroy(); } }; } }