// Prompt box
var t = "";
function Toast(msg,type,duration) {
$('.msg-active').remove();
let html;
if(type=='warning'){
html =`
`
}else if(type=='success'){
html =`
`
}else{
html =`
${msg}
`
}
$('body').append(html);
setTimeout(()=>{
duration = isNaN(duration) ? 3000 : duration;
$('.msg-active').css({opacity:'1'})
$('.msg-active b').css({top:'0',opacity:'1'})
clearTimeout(t);
t = setTimeout(function () {
$('.msg-active').css({opacity:'0'})
$('.msg-active b').css({top:'.5rem',opacity:'0'})
setTimeout(()=>{
$('.msg-active').remove();
},300)
}, duration);
},100)
}
// loading
var hsycmsalert_loading_html = "";
hsycmsalert_loading_html += "";
hsycmsalert_loading_html += "";
hsycmsalert_loading_html += "
";
hsycmsalert_loading_html += " ";
hsycmsalert_loading_html += " ";
hsycmsalert_loading_html += " ";
hsycmsalert_loading_html += "
";
hsycmsalert_loading_html += "
loading
";
hsycmsalert_loading_html += "
";
let hsycmsalerthtml ={
'loading':hsycmsalert_loading_html
};
var hsycms = function() {
return {
// Open
open: function(id, txt = '',html) {
$("body").append(hsycmsalerthtml[id]);
var obj = $("#hsycmsalert-" + id);
$("#hsycmsalert-mask-" + id).fadeIn(300);
obj.addClass("hsycms-ani-open");
var height = obj.height();
obj.css("margin-top", "-" + Math.ceil(height / 2) + 'px');
if (txt != '') {
obj.find(".hsycms-model-text").html(txt);
}
obj.show();
setTimeout(res => {
obj.removeClass("hsycms-ani-open");
}, 300)
},
// Show loading
loading: function(txt) {
this.open('loading', txt);
},
// Hide loading
hideLoading(callback) {
this.close("loading");
if (typeof(callback) != 'undefined') {
callback();
}
},
// Close
close: function(id) {
var obj = $("#hsycmsalert-" + id);
$("#hsycmsalert-mask-" + id).fadeOut(200);
obj.addClass("hsycms-ani-close");
setTimeout(res => {
obj.hide();
obj.removeClass("hsycms-ani-close");
$("#hsycmsalert-mask-" + id).remove();
obj.remove();
}, 300)
}
}
}();
// Back
function onBack(){
window.history.back(-1);
}
// copy content
function copy(value) {
const text = document.createElement('textarea');
text.value = value;
text.setAttribute('readonly', 'readonly')
document.body.appendChild(text);
text.select();
if (document.execCommand('copy')) {
document.execCommand('copy');
}
document.body.removeChild(text);
Toast('Copy successfully','success')
}
// Get the parameters behind the URl
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg); // Get the string after the "?" character in the URL and match it regularly
var context = "";
if (r != null)
context = r[2];
reg = null;
r = null;
return context == null || context == "" || context == "undefined" ? "" : context;
}