Warning: Packets out of order. Expected 1 received 0. Packet size=145 in /var/www/html/Kotchasan/Database/PdoMysqlDriver.php on line 63

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/Kotchasan/Database/PdoMysqlDriver.php:63) in /var/www/html/Kotchasan/Language.php on line 445
var WEB_URL="https://ari.clus.cl.co.th/1/"; var UPLOAD_MAX_FILESIZE="12M"; var UPLOAD_MAX_BYTES=12582912; /** * Javascript Library for Kotchasan Framework * * @filesource js/gajax.js * @link https://www.kotchasan.com/ * @copyright 2018 Goragod.com * @license https://www.kotchasan.com/license/ */ window.$K = (function() { 'use strict'; var domloaded = false; var $K = { emptyFunction: function() {}, resultFunction: function() { return true; }, isMobile: function() { let check = false; (function(a) {if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true;})(navigator.userAgent || navigator.vendor || window.opera); return check; }, init: function(element) { forEach(element.querySelectorAll('input,textarea,select'), function(elem) { var tagName = $G(elem).tagName.toLowerCase(), type = elem.get('type'), type = type ? type.toLowerCase() : ''; if (elem.initObj !== true) { if (tagName == 'select') { elem.initObj = true; if (elem.get('checkbox') !== null) { new GSelect(elem); } } else if (tagName == 'textarea' || (type !== 'hidden' && type !== 'radio' && type !== 'checkbox' && type !== 'button' && type !== 'submit')) { var obj = new Object(); obj.tagName = tagName; obj.type = type; elem.initObj = true; obj.title = elem.title; obj.disabled = elem.get('disabled') !== null; obj.maxlength = floatval(elem.get('maxlength')); obj.pattern = elem.get('pattern'); if (obj.pattern !== null) { obj.pattern = new RegExp('^(?:' + obj.pattern + ')$'); elem.setAttribute('pattern', '(.*){0,}'); } obj.dataset = elem.dataset; if (typeof obj.dataset == 'undefined') { obj.dataset = {}; forEach(elem.attributes, function() { var hs = this.name.match(/^data\-(.+)/); if (hs) { obj.dataset[hs[0]] = this.value; } }); } if (obj.tagName == 'textarea') { if (obj.maxlength > 0 || obj.pattern) { var _docheck = function() { if (this.value != '' && obj.pattern && !obj.pattern.test(this.value)) { this.invalid(obj.title !== '' ? obj.title : trans('Invalid data')); } else if (obj.pattern) { this.reset(); } }; elem.srcObj = obj; elem.addEvent('keyup', _docheck); elem.addEvent('change', _docheck); } } else if (obj.tagName == 'input') { var c = elem.hasClass('currency number integer color inputgroup'); if (c !== false) { obj.type = c; } if (elem.min) { obj.min = elem.min; } if (elem.max) { obj.max = elem.max; } var autofocus = elem.get('autofocus'), inputs = ['number', 'integer', 'tel', 'email', 'url', 'color', 'currency'], text = elem; if (obj.type == 'date' || obj.type == 'datetime-local' || obj.type == 'time') { new GDateTime(elem); } else if (obj.dataset['keyboard'] || inputs.indexOf(obj.type) > -1) { var o = { type: 'text', name: elem.name, disabled: obj.disabled }; if (elem.id != '') { o.id = elem.id; } text = $G().create('input', o); if (elem.value != '') { text.value = elem.value; } if (obj.title != '') { text.title = obj.title; } if (elem.size) { text.size = elem.size; } if (elem.placeholder) { text.placeholder = elem.placeholder; } if (obj.maxlength > 0) { text.maxlength = obj.maxlength; } if (elem.readOnly) { text.readOnly = true; } if (obj.type == 'currency') { text.digit = floatval(obj.dataset['digit'] ? obj.dataset['digit'] : 2); } text.className = elem.className; text.initObj = true; elem.replace(text); if (obj.type == 'color') { new GDDColor(text, function(c) { this.input.style.backgroundColor = c; this.input.style.color = this.invertColor(c); this.input.value = c; this.input.callEvent('change'); }); } else if (obj.type == 'email' || obj.type == 'url') { if (obj.pattern == null) { if (obj.type == 'email') { obj.pattern = /^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/; } else { obj.pattern = /^[a-z0-9\-\.:\/\#%\?\&\=_@~]{3,}$/i; } } text.addEvent('keyup', _docheck); text.addEvent('change', _docheck); } else { if (!obj.dataset['keyboard']) { if (obj.type == 'integer') { obj.dataset['keyboard'] = '1234567890-'; } else if (obj.type == 'currency') { obj.dataset['keyboard'] = '1234567890.,'; } else if (obj.type == 'number' || obj.type == 'tel') { obj.dataset['keyboard'] = '1234567890'; } } if (obj.dataset['keyboard']) { obj.pattern = new RegExp('^(?:[' + obj.dataset['keyboard'].preg_quote() + ']+)$'); if (obj.type == 'integer' || obj.type == 'currency' || obj.type == 'number') { new GInput(text, obj.dataset['keyboard'], function() { if (obj.min) { this.value = Math.max(obj.min, floatval(this.value)); } if (obj.max) { this.value = Math.min(obj.max, floatval(this.value)); } if (obj.type == 'currency') { this.value = toCurrency(this.value, this.digit); } }); } else { new GInput(text, obj.dataset['keyboard']); } } } } else if (obj.type == 'file') { if (elem.hasClass('g-file')) { var p = elem.parentNode; elem.setStyle('opacity', 0); elem.style.cursor = 'pointer'; elem.style.position = 'absolute'; elem.style.left = 0; elem.style.top = 1; p.style.position = 'relative'; var display = document.createElement('input'); display.setAttribute('type', 'text'); display.id = elem.id; elem.id = elem.id + '_tmp'; display.disabled = true; display.placeholder = elem.placeholder; p.appendChild(display); elem.style.zIndex = text.style.zIndex + 1; elem.style.height = '100%'; elem.style.width = '100%'; elem.addEvent('change', function() { if (this.files) { var input = this, hs, files = [], preview = $E(this.get('data-preview')), max = floatval(input.get('data-max')), validImageTypes = ['image/gif', 'image/jpeg', 'image/jpg', 'image/png', 'image/webp']; if (preview) { preview.innerHTML = ''; } forEach(input.files, function() { if (max > 0 && this.size > max) { input.invalid(input.title); } else { files.push(this.name); input.valid(); if (preview) { hs = /\.([a-z0-9]+)$/.exec(this.name.toLowerCase()); var div = document.createElement('div'); div.className = 'file-thumb'; if (hs) { div.innerHTML = hs[1]; } preview.appendChild(div); if (validImageTypes.includes(this.type) && window.FileReader) { var r = new FileReader(); r.onload = function(evt) { div.innerHTML = ''; div.style.backgroundImage = 'url(' + evt.target.result + ')'; }; r.readAsDataURL(this); } } } }); display.value = files.join(', '); $G(display).callEvent('change', { value: this.value, files: this.files }); } }); elem.initObj = true; } } else if (obj.type == 'range') { new GRange(elem); } else if (obj.type == 'inputgroup') { new GInputGroup(elem); } else if (elem.get('list')) { new Datalist(elem); } else if (obj.pattern) { new GMask(text, function() { return obj.pattern.test(this.value); }); } if (elem.hasClass('showpassword') !== false) { var span = document.createElement('span'); text.parentNode.appendChild(span); span.onclick = function() { var type = text.getAttribute('type') === 'password' ? 'text' : 'password'; text.setAttribute('type', type); }; } if (typeof obj.dataset !== 'undefined') { for (var prop in obj.dataset) { if (obj.dataset[prop] !== null) { text.setAttribute('data-' + prop, obj.dataset[prop]); } } } if (autofocus !== null) { text.focus(); if (obj.type == 'text') { text.select(); } } if (obj.pattern) { text.srcObj = obj; } } } } }); var checkbox_loading = true, wCheckboxChanged = function(e) { this.checkId.disabled = !this.checked; if (!checkbox_loading && this.checked) { this.checkId.focus(); } }; forEach(element.querySelectorAll('.w_checkbox input[type=checkbox]'), function(elem) { if (!elem.checkId) { var id = elem.name.replace('checkbox_', '').replace('[', '').replace(']', ''); if ($E(id)) { elem.checkId = $E(id); $G(elem).addEvent('change', wCheckboxChanged); wCheckboxChanged.call(elem); } } }); window.setTimeout(function() { checkbox_loading = false; }, 1); } }; if (typeof Array.prototype.indexOf != 'function') { Array.prototype.indexOf = function(t, i) { i || (i = 0); var l = this.length; if (i < 0) { i = l + i; } for (; i < l; i++) { if (this[i] == t) { return i; } } return -1; }; } if (typeof forEach != 'function') { window.forEach = function(a, f) { var i, l = a.length, x = []; for (i = 0; i < l; i++) { x.push(a[i]); } for (i = 0; i < l; i++) { if (f.call(x[i], x[i], i) == true) { break; } } }; } window.floatval = function(val) { var n = parseFloat(typeof val == 'string' ? val.replace(/[^0-9\-\.]/g, '') : val); return isNaN(n) ? 0 : n; }; window.toCurrency = function(val, digit, zero) { if (typeof digit == 'undefined') { val = floatval(val).toFixed(2); } else if (typeof digit == 'number') { val = floatval(val).toFixed(digit); } else if (typeof val == 'number') { val = new String(floatval(val)); } var ds = val.split('.'), val = ds[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,'); if (zero && /[0]+/g.test(ds[1])) { ds[1] = null; } return val + (ds[1] ? '.' + ds[1] : ''); }; window.round = function(val, digit) { var value = Math.round(val * Math.pow(10, digit)) / Math.pow(10, digit); if (val - value > 0) { return value + Math.floor((2 * Math.round((val - value) * Math.pow(10, digit + 1))) / 10) / Math.pow(10, digit); } else { return value; } }; window.copyToClipboard = function(text) { var el = document.createElement('textarea'); el.value = text; el.setAttribute('readonly', ''); el.style.position = 'absolute'; el.style.top = '-1000px'; document.body.appendChild(el); el.select(); document.execCommand('copy'); document.body.removeChild(el); }; window.getTextFromClipboard = function(callback) { if (!navigator.clipboard) { var textArea = document.createElement("textarea"); textArea.style.position = 'fixed'; textArea.style.top = 0; textArea.style.left = 0; textArea.style.width = '2em'; textArea.style.height = '2em'; textArea.style.padding = 0; textArea.style.border = 'none'; textArea.style.outline = 'none'; textArea.style.boxShadow = 'none'; textArea.style.background = 'transparent'; textArea.value = ''; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { var successful = document.execCommand('paste'); var text = successful ? textArea.value : ''; callback(text); } catch (error) { console.error('Unable to read clipboard data:', error); callback(''); } document.body.removeChild(textArea); } else { navigator.clipboard.readText() .then(text => { callback(text); }) .catch(err => { console.error('Failed to read clipboard contents: ', err); callback(''); }); } }; window.trans = function(val) { try { var patt = /^[_]+|[_]+$/g; return eval(val.replace(/[\s]/g, '_').replace('?', '').replace(patt, '').toUpperCase()); } catch (e) { return val; } }; window.jsonToParams = function(json, separator) { var ret = []; for (var k in json) { ret.push(k + '=' + json[k]); } return ret.join(separator ? separator : '&'); }; window.jwt_decode = function(token) { var base64Url = token.split('.')[1], base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'), jsonPayload = decodeURIComponent( atob(base64) .split('') .map(function(c) { return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); }) .join('') ); return JSON.parse(jsonPayload); }; window.debug = function(val) { var p = document.createElement('p'), div = $E('gdebug'); if (!div) { div = document.createElement('div'); div.id = 'gdebug'; document.body.appendChild(div); div.style.cssText = 'left:0;bottom:0;width:100%;height:100px;color:#F00;background-color:#FFF;position:fixed;line-height:1;padding:10px;overflow:auto;'; } p.style.cssText = 'margin:0;'; p.innerText = val; div.appendChild(p); div.scrollTop = div.scrollHeight; }; window.timeToMinute = function(time) { var sp = time.split(':'); if (sp.length == 1) { return 0; } else { return (floatval(sp[0]) * 60) + floatval(sp[1]); } }; window.timeToSecond = function(time) { var sp = time.split(':'); if (sp.length == 1) { return 0; } else { return (floatval(sp[0]) * 60) + (floatval(sp[1] * 60) + floatval(sp[2])); } }; Function.prototype.bind = function(o) { var __method = this; return function() { return __method.apply(o, arguments); }; }; Date.prototype.fromTime = function(mktime) { return new Date(mktime * 1000); }; Date.prototype.format = function(fmt) { var result = ''; for (var i = 0; i < fmt.length; i++) { result += this.formatter(fmt.charAt(i)); } return result; }; Date.prototype.formatter = function(c) { switch (c) { case 'd': return this.getDate().toString().leftPad(2, '0'); case 'D': return Date.dayNames[this.getDay()]; case 'y': return this.getFullYear().toString(); case 'Y': return (this.getFullYear() + Date.yearOffset).toString(); case 'm': return (this.getMonth() + 1).toString().leftPad(2, '0'); case 'M': return Date.monthNames[this.getMonth()]; case 'F': return Date.longMonthNames[this.getMonth()]; case 'H': return this.getHours().toString().leftPad(2, '0'); case 'h': return this.getHours(); case 'A': return this.getHours() < 12 ? 'AM' : 'PM'; case 'a': return this.getHours() < 12 ? 'am' : 'pm'; case 'I': return this.getMinutes().toString().leftPad(2, '0'); case 'i': return this.getMinutes(); case 'S': return this.getSeconds().toString().leftPad(2, '0'); case 's': return this.getSeconds(); default: return c; } }; Date.prototype.tomktime = function() { return Math.floor(this.getTime() / 1000); }; Date.prototype.moveDate = function(value) { this.setDate(this.getDate() + value); return this; }; Date.prototype.moveMonth = function(value) { this.setMonth(this.getMonth() + value); return this; }; Date.prototype.moveYear = function(value) { this.setFullYear(this.getFullYear() + value); return this; }; Date.prototype.isLeapYear = function() { var year = this.getFullYear(); return (year & 3) == 0 && (year % 100 || (year % 400 == 0 && year)); }; Date.prototype.daysInMonth = function() { var arr = Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); arr[1] = this.isLeapYear() ? 29 : 28; return arr[this.getMonth()]; }; Date.prototype.dayOfWeek = function() { var a = parseInt((14 - this.getMonth()) / 12); var y = this.getFullYear() - a; var m = this.getMonth() + 12 * a - 2; var d = (this.getDate() + y + parseInt(y / 4) - parseInt(y / 100) + parseInt(y / 400) + parseInt((31 * m) / 12)) % 7; return d; }; Date.prototype.compare = function(d) { if (Object.isString(d)) { d = new Date(d.replace(/-/g, '/')); } var days = Math.floor((this.getTime() - d.getTime()) / 86400000), numDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; if (days < 0) { var fromDate = this.getDate(), fromMonth = this.getMonth(), fromYear = this.getFullYear(), toDate = d.getDate(), toMonth = d.getMonth(), toYear = d.getFullYear(); if (d.isLeapYear()) { numDays[1] = 29; } } else { var fromDate = d.getDate(), fromMonth = d.getMonth(), fromYear = d.getFullYear(), toDate = this.getDate(), toMonth = this.getMonth(), toYear = this.getFullYear(); if (this.isLeapYear()) { numDays[1] = 29; } } var diffYear = toYear - fromYear, diffMonth = toMonth - fromMonth, diffDate = toDate - fromDate; if (diffDate < 0) { diffMonth--; toMonth = toMonth == 0 ? 11 : toMonth - 1; diffDate = numDays[toMonth] + diffDate; } if (diffMonth < 0) { diffYear--; diffMonth = 12 + diffMonth; } return { day: diffDate, month: diffMonth, year: diffYear, days: days }; }; Date.monthNames = [ 'Jan.', 'Feb.', 'Mar.', 'Apr.', 'May.', 'Jun.', 'Jul.', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.' ]; Date.longMonthNames = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]; Date.longDayNames = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ]; Date.dayNames = ['Su.', 'Mo.', 'We.', 'Tu.', 'Th.', 'Fr.', 'Sa.']; Date.yearOffset = 0; String.prototype.entityify = function() { return this.replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, ''') .replace(/\\/g, '\') .replace(/\//g, '/') .replace(/&/g, '&') .replace(/\{/g, '{') .replace(/\}/g, '}'); }; String.prototype.unentityify = function() { return this.replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"') .replace(/&#[0]?39;/g, "'") .replace(/\/g, '\\') .replace(///g, '/') .replace(/&/g, '&') .replace(/{/g, '{') .replace(/}/g, '}'); }; String.prototype.toJSON = function() { try { var datas = JSON.parse(this); return typeof datas === 'object' ? datas : false; } catch (e) { return false; } }; String.prototype.toInt = function() { return floatval(this); }; String.prototype.currFormat = function() { return floatval(this).toFixed(2); }; String.prototype.preg_quote = function() { return this.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1'); }; String.prototype.capitalize = function() { return this.replace(/\b[a-z]/g, function(m) { return m.toUpperCase(); }); }; String.prototype.evalScript = function() { var regex = /(.*?)<\/script>/g; var t = this.replace(/[\r\n]/g, '').replace(/\/\/<\!\[CDATA\[/g, '').replace(/\/\/\]\]>/g, ''); var m = regex.exec(t); while (m) { try { eval(m[1]); } catch (e) {} m = regex.exec(t); } return this; }; String.prototype.leftPad = function(c, f) { var r = ''; for (var i = 0; i < c - this.length; i++) { r = r + f; } return r + this; }; String.prototype.trim = function() { return this.replace(/^(\s| )+|(\s| )+$/g, ''); }; String.prototype.ltrim = function() { return this.replace(/^(\s| )+/, ''); }; String.prototype.rtrim = function() { return this.replace(/(\s| )+$/, ''); }; String.prototype.strip_tags = function(allowed) { allowed = (((allowed || '') + '').toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join(''); var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi; var php = /|<\?(?:php)?[\s\S]*?\?>/gi; return this.replace(php, '').replace(tags, function($0, $1) { return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : ''; }); }; String.prototype.toDOM = function() { var s = function(a) { return a .replace(/>/g, '>') .replace(/</g, '<') .replace(/ /g, ' ') .replace(/"/g, '"') .replace(/&#[0]?39;/g, "'") .replace(/\/g, '\\') .replace(/&/g, '&'); }; var t = function(a) { return a.replace(/ /g, ''); }; var u = function(a) { var b = document.createDocumentFragment(); var c = a.indexOf(' '); if (c == -1) { var d = a.toLowerCase(); b.appendChild(document.createElement(d)); } else { d = t(a.substring(0, c)).toLowerCase(); if (document.all && (d == 'input' || d == 'iframe')) { try { b.appendChild(document.createElement('<' + a + '/>')); return b; } catch (e) {} } a = a.substring(c + 1); b.appendChild(document.createElement(d)); while (a.length > 0) { var e = a.indexOf('='); if (e >= 0) { var f = t(a.substring(0, e)).toLowerCase(); var g = a.indexOf('"'); a = a.substring(g + 1); g = a.indexOf('"'); var h = s(a.substring(0, g)); a = a.substring(g + 2); if (document.all && f == 'style') { b.lastChild.style.cssText = h; } else if (f == 'class') { b.lastChild.className = h; } else { b.lastChild.setAttribute(f, h); } } else { break; } } } return b; }; var v = function(a, b, c) { var d = a; var e = b; c = c.toLowerCase(); var f = e.indexOf(''); d = d.concat(e.substring(0, f)); e = e.substring(f); while (d.indexOf('<' + c) != -1) { d = d.substring(d.indexOf('<' + c)); d = d.substring(d.indexOf('>') + 1); e = e.substring(e.indexOf('>') + 1); f = e.indexOf(''); d = d.concat(e.substring(0, f)); e = e.substring(f); } return b.length - e.length; }; var w = function(a) { var b = document.createDocumentFragment(); while (a && a.length > 0) { var c = a.indexOf('<'); if (c == -1) { a = s(a); b.appendChild(document.createTextNode(a)); a = null; } if (c > 0) { var d = s(a.substring(0, c)); b.appendChild(document.createTextNode(d)); a = a.substring(c); } if (c == 0) { var e = a.indexOf(''); var g = a.substring(4, f); g = s(g); b.appendChild(document.createComment(g)); a = a.substring(f + 3); } else { var h = a.indexOf('>'); if (a.substring(h - 1, h) == '/') { var i = a.indexOf('/>'); var j = a.substring(1, i); b.appendChild(u(j)); a = a.substring(i + 2); } else { var k = a.indexOf('>'); var l = a.substring(1, k); var m = document.createDocumentFragment(); m.appendChild(u(l)); a = a.substring(k + 1); var n = a.substring(0, a.indexOf('') + 1); m.lastChild.appendChild(w(n)); b.appendChild(m); } } } } return b; }; return w(this); }; String.prototype.toDate = function() { if (this === '') { return null; } let d = new Date(), hs = /^(today|tomorrow|yesterday|((([0-9]{4,4})[\-\/]([0-9]{1,2})[\-\/]([0-9]{1,2}))?([T\s]{0,}(([0-9]{1,2}):([0-9]{1,2})(:([0-9]{1,2}))?))?))([\s]{0,}([\+\-]{0,})[\s]{0,}([0-9]{0,}))?$/.exec(this); if (hs) { if (typeof hs[4] !== 'undefined') { d.setFullYear(floatval(hs[4]), floatval(hs[5]) - 1, floatval(hs[6])); } if (typeof hs[9] !== 'undefined') { if (typeof hs[13] === 'undefined') { d.setHours(floatval(hs[9]), floatval(hs[10])); } else { d.setHours(floatval(hs[9]), floatval(hs[10]), floatval(hs[12])); } } if (hs[1] == 'yesterday') { d.setDate(d.getDate() - 1); } else if (hs[1] == 'tomorrow') { d.setDate(d.getDate() + 1); } if (hs[14] == '+' && floatval(hs[15]) > 0) { d.setDate(d.getDate() + floatval(hs[15])); } else if (hs[14] == '-' && floatval(hs[15]) > 0) { d.setDate(d.getDate() - floatval(hs[15])); } return d; } else { return null; } }; Number.prototype.format = function(decimals, dec_point, thousands_sep) { decimals = isNaN((decimals = Math.abs(decimals))) ? 2 : decimals; dec_point = dec_point == undefined ? '.' : dec_point; thousands_sep = thousands_sep == undefined ? ',' : thousands_sep; var n = this, s = n < 0 ? '-' : '', i = String(parseInt((n = Math.abs(Number(n) || 0).toFixed(decimals)))), j = (j = i.length) > 3 ? j % 3 : 0; return (s + (j ? i.substr(0, j) + thousands_sep : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousands_sep) + (decimals ? dec_point + Math.abs(n - i).toFixed(decimals).slice(2) : '')); }; document.viewport = { getWidth: function() { return ( document.documentElement.clientWidth || document.body.clientWidth || self.innerWidth ); }, getHeight: function() { return ( document.documentElement.clientHeight || document.body.clientHeight || self.innerHeight ); }, getscrollTop: function() { return ( window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop ); }, getscrollLeft: function() { return ( window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft ); } }; document.css = function(css, id) { var style = document.createElement('style'); if (id) { style.id = 'css_' + id; if ($E('css_' + id)) { $E('css_' + id).parentNode.removeChild($E('css_' + id)); } } if (css !== null) { if (style.styleSheet) { style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } document.getElementsByTagName('head')[0].appendChild(style); } }; Object.extend = function(d, s) { for (var property in s) { d[property] = s[property]; } return d; }; Object.extend(Object, { isObject: function(o) { return typeof o == 'object'; }, isFunction: function(o) { return typeof o == 'function'; }, isString: function(o) { return typeof o == 'string'; }, isNumber: function(o) { return typeof o == 'number'; }, isNull: function(o) { return typeof o == 'undefined'; }, isGElement: function(o) { return ( o != null && typeof o == 'object' && 'Ready' in o && 'element' in o ); }, toArray: function(o) { var prop, result = []; for (prop in o) { result.push(o[prop]); } return result; } }); window.GClass = { create: function() { return function() { this.initialize.apply(this, arguments); }; } }; window.GNative = GClass.create(); GNative.prototype = { initialize: function() { this.elem = null; }, Ready: function(f) { var s = this; var p = function() { if (domloaded && s.element()) { f.call($G(s.elem)); } else { window.setTimeout(p, 10); } }; p(); }, after: function(e) { var p = this.parentNode; if (this.nextSibling == null) { p.appendChild(e); } else { p.insertBefore(e, this.nextSibling); } return e; }, before: function(e) { var p = this.parentNode; if (p.firstChild == this) { p.appendChild(e); } else { p.insertBefore(e, this); } return e; }, insert: function(e) { e = $G(e); this.appendChild(e); return e; }, copy: function(o) { return $G(this.cloneNode(o || true)); }, replace: function(e) { var p = this.parentNode; p.insertBefore(e, this.nextSibling); p.removeChild(this); return $G(e); }, remove: function() { if (this.element()) { this.parentNode.removeChild(this); } return this; }, setHTML: function(o) { try { this.innerHTML = o; } catch (e) { o = o .replace(/[\r\n\t]/g, '') .replace(/]*>.*?<\/script>/gi, ''); this.appendChild(o.toDOM()); } return this; }, getTop: function() { return this.viewportOffset().top; }, getLeft: function() { return this.viewportOffset().left; }, getWidth: function() { return this.getDimensions().width; }, getHeight: function() { return this.getDimensions().height; }, getClientWidth: function() { return ( this.clientWidth - parseInt(this.getStyle('paddingLeft')) - parseInt(this.getStyle('paddingRight')) ); }, getClientHeight: function() { return ( this.clientHeight - parseInt(this.getStyle('paddingTop')) - parseInt(this.getStyle('paddingBottom')) ); }, viewportOffset: function() { var t = 0, l = 0, p = this; while (p) { t += parseInt(p.offsetTop); l += parseInt(p.offsetLeft); p = p.offsetParent; } if (this.getBoundingClientRect) { return {top: t, left: this.getBoundingClientRect().left}; } else { return {top: t, left: l}; } }, getDimensions: function() { var ow, oh; if (this == document) { ow = Math.max( Math.max( document.body.scrollWidth, document.documentElement.scrollWidth ), Math.max( document.body.offsetWidth, document.documentElement.offsetWidth ), Math.max( document.body.clientWidth, document.documentElement.clientWidth ) ); oh = Math.max( Math.max( document.body.scrollHeight, document.documentElement.scrollHeight ), Math.max( document.body.offsetHeight, document.documentElement.offsetHeight ), Math.max( document.body.clientHeight, document.documentElement.clientHeight ) ); } else { var d = this.getStyle('display'); if (d != 'none' && d !== null) { ow = this.offsetWidth; oh = this.offsetHeight; } else { var s = this.style; var ov = s.visibility; var op = s.position; var od = s.display; s.visibility = 'hidden'; s.position = 'absolute'; s.display = 'block'; ow = this.clientWidth; oh = this.clientHeight; s.display = od; s.position = op; s.visibility = ov; } } return {width: ow, height: oh}; }, getOffsetParent: function() { var e = this.offsetParent; if (!e) { e = this.parentNode; while (e != document.body && e.style.position == 'static') { e = e.parentNode; } } return GElement(e); }, getCaretPosition: function() { if (document.selection) { var range = document.selection.createRange(), textLength = range.text.length; range.moveStart('character', -this.value.length); var caretAt = range.text.length; return {start: caretAt, end: caretAt + textLength}; } else if (this.selectionStart || this.selectionStart == '0') { return {start: this.selectionStart, end: this.selectionEnd}; } }, setCaretPosition: function(start, length) { if (this.setSelectionRange) { this.focus(); this.setSelectionRange(start, start + length); } else if (this.createTextRange) { var range = this.createTextRange(); range.collapse(true); range.moveEnd('character', start + length); range.moveStart('character', start); range.select(); } return this; }, getStyle: function(s) { s = s == 'float' && this.currentStyle ? 'styleFloat' : s; s = s == 'borderColor' ? 'borderBottomColor' : s; var v = this.currentStyle ? this.currentStyle[s] : null; v = !v && window.getComputedStyle ? document.defaultView.getComputedStyle(this, null).getPropertyValue(s.replace(/([A-Z])/g, '-$1').toLowerCase()) : v; if (s == 'opacity') { return Object.isNull(v) ? 100 : floatval(v) * 100; } else { return v; } }, setStyle: function(p, v) { if (p == 'opacity') { if (window.ActiveXObject) { this.style.filter = 'alpha(opacity=' + v * 100 + ')'; } this.style.opacity = v; } else if (p == 'float' || p == 'styleFloat' || p == 'cssFloat') { if (Object.isNull(this.style.styleFloat)) { this.style['cssFloat'] = v; } else { this.style['styleFloat'] = v; } } else if ( p == 'backgroundColor' && this.tagName.toLowerCase() == 'iframe' ) { if (document.all) { this.contentWindow.document.bgColor = v; } else { this.style.backgroundColor = v; } } else if (p == 'borderColor') { this.style.borderLeftColor = v; this.style.borderTopColor = v; this.style.borderRightColor = v; this.style.borderBottomColor = v; } else { this.style[p] = v; } return this; }, center: function() { var size = this.getDimensions(); if (this.getStyle('position') == 'fixed') { this.style.top = (document.viewport.getHeight() - size.height) / 2 + 'px'; this.style.left = (document.viewport.getWidth() - size.width) / 2 + 'px'; } else { this.style.top = document.viewport.getscrollTop() + (document.viewport.getHeight() - size.height) / 2 + 'px'; this.style.left = document.viewport.getscrollLeft() + (document.viewport.getWidth() - size.width) / 2 + 'px'; } return this; }, get: function(p) { try { return this.getAttribute(p); } catch (e) { return null; } }, set: function(p, v) { try { this.setAttribute(p, v); } catch (e) {} return this; }, hasClass: function(v) { var vs = v.split(' '); var cs = this.className.split(' '); for (var c = 0; c < cs.length; c++) { for (v = 0; v < vs.length; v++) { if (vs[v] != '' && vs[v] == cs[c]) { return vs[v]; } } } return false; }, addClass: function(v) { if (this.className || this.className === '') { if (!v) { this.className = ''; } else { var rm = v.split(' '), cs = []; forEach(this.className.split(' '), function(c) { if (c !== '' && rm.indexOf(c) == -1) { cs.push(c); } }); cs.push(v); this.className = cs.join(' '); } } return this; }, removeClass: function(v) { if (this.className || this.className === '') { var rm = v.split(' '); var cs = []; forEach(this.className.split(' '), function(c) { if (c !== '' && rm.indexOf(c) == -1) { cs.push(c); } }); this.className = cs.join(' '); } return this; }, replaceClass: function(source, replace) { if (this.className || this.className === '') { var rm = (replace + ' ' + source).split(' '); var cs = []; forEach(this.className.split(' '), function(c) { if (c !== '' && rm.indexOf(c) == -1) { cs.push(c); } }); cs.push(replace); this.className = cs.join(' '); } return this; }, hide: function() { this.display = this.getStyle('display'); this.setStyle('display', 'none'); return this; }, show: function() { if (this.getStyle('display') == 'none') { this.setStyle('display', 'block'); } return this; }, visible: function() { return this.getStyle('display') != 'none'; }, toggle: function() { if (this.visible()) { this.hide(); } else { this.show(); } return this; }, nextNode: function() { var n = this; do { n = n.nextSibling; } while (n && n.nodeType != 1); return n; }, previousNode: function() { var p = this; do { p = p.previousSibling; } while (p && p.nodeType != 1); return p; }, firstNode: function() { var p = this.firstChild; do { p = p.nextSibling; } while (p && p.nodeType != 1); return p; }, nextTab: function() { var tag, result, self = this, check = null; forEach(document.forms, function() { return forEach(this.getElementsByTagName('*'), function() { if (this == self.elem) { check = this; } else if (check != null) { if ( this.tabIndex >= 0 && this.disabled != true && this.style.display != 'none' && this.offsetParent != null ) { result = this; return true; } } }); }); return result; }, sendKey: function(keyCode) { return this.callEvent('keypress', {keyCode: keyCode}); }, callEvent: function(t, params) { var evt; if (document.createEvent) { evt = document.createEvent('Events'); evt.initEvent(t, true, true); for (var prop in params) { evt[prop] = params[prop]; } this.dispatchEvent(evt); } else if (document.createEventObject) { evt = document.createEventObject(); for (var prop in params) { evt[prop] = params[prop]; } this.fireEvent('on' + t, evt); } return this; }, addEvent: function(t, f, c) { var ts = t.split(/[\s,]/g), input = this; forEach(ts, function(e) { if (input.addEventListener) { c = !c ? false : c; input.addEventListener(e, f, c); } else if (input.attachEvent) { input['e' + e + f] = f; input[e + f] = function() { input['e' + e + f](window.event); }; input.attachEvent('on' + e, input[e + f]); } }); return this; }, removeEvent: function(t, f, c) { var ts = t.split(/[\s,]/g), input = this; forEach(ts, function(e) { if (input.removeEventListener) { c = !c ? false : c; input.removeEventListener(e == 'mousewheel' && window.gecko ? 'DOMMouseScroll' : e, f, c); } else if (input.detachEvent) { input.detachEvent('on' + e, input[e + f]); input['e' + e + f] = null; input[e + f] = null; } }); return this; }, highlight: function(o) { this.addClass('highlight'); var self = this; window.setTimeout(function() { self.removeClass('highlight'); }, 1); return this; }, fadeIn: function(oncomplete) { this.addClass('fadein'); var self = this; window.setTimeout(function() { self.removeClass('fadein'); if (Object.isFunction(oncomplete)) { oncomplete.call(this); } }, 1000); return this; }, fadeOut: function(oncomplete) { this.addClass('fadeout'); var self = this; window.setTimeout(function() { self.removeClass('fadeout'); if (Object.isFunction(oncomplete)) { oncomplete.call(this); } }, 1000); return this; }, setValue: function(v) { function _find(e, a) { var s = e.getElementsByTagName('option'); for (var i = 0; i < s.length; i++) { if (s[i].value == a) { return i; } } return -1; } if (this.time) { this.time.setTime(v); } else if (this.calendar) { this.value = v; } else if (this.datalist) { this.selectedIndex = v; } else { v = decodeURIComponent(v); var t = this.tagName.toLowerCase(); if (t == 'img') { this.src = v; } else if (t == 'select') { this.selectedIndex = _find(this, v); } else if (t == 'input') { if (this.type == 'checkbox' || this.type == 'radio') { this.checked = v == this.value; } else { this.value = v.unentityify(); } } else if (t == 'textarea') { this.value = v.unentityify(); } else { this.setHTML(v); } } return this; }, getText: function() { if (!Object.isNull(this.elem.selectedIndex)) { if (this.elem.selectedIndex == -1) { return null; } return this.elem.options[this.elem.selectedIndex].text; } else if (this.elem.innerHTML) { return this.elem.innerHTML; } return this.elem.value; }, setOptions: function(json, value) { if (this.tagName.toLowerCase() == 'select') { for (var i = this.options.length; i > 0; i--) { this.removeChild(this.options[i - 1]); } var selectedIndex = 0; if (json) { var i = 0; for (var key in json) { if (key == value) { selectedIndex = i; } var option = document.createElement('option'); option.innerHTML = json[key]; option.value = key; this.appendChild(option); i++; } } this.selectedIndex = selectedIndex; } }, getSelectedText: function() { var text = ''; if (this.selectionStart) { if (this.selectionStart != this.selectionEnd) { text = this.value.substring(this.selectionStart, this.selectionEnd); } } else if (document.selection) { var range = document.selection.createRange(); if (range.parentElement() === this) { text = range.text; } } return text; }, setSelectedText: function(value) { if (this.selectionStart) { if (this.selectionStart != this.selectionEnd) { this.value = this.value.substring(0, this.selectionStart) + value + this.value.substring(this.selectionEnd); } } else { var range = document.selection.createRange(); if (range.parentElement() === this) { range.text = value; } } return this; }, findLabel: function() { var result = null, id = this.id; forEach(document.getElementsByTagName('label'), function() { if (this.htmlFor != '' && this.htmlFor == id) { result = this; return true; } }); return result; }, element: function() { return Object.isString(this.elem) ? document.getElementById(this.elem) : this.elem; }, elems: function(tagname) { return this.getElementsByTagName(tagname); }, create: function(tagname, o) { var v; if (tagname == 'iframe' || tagname == 'input') { var n = o.name || o.id || ''; var i = o.id || o.name || ''; if (window.ActiveXObject) { try { if (tagname == 'iframe') { v = document.createElement( '