File: /var/www/html/wp-content/plugins/ganryu_shop/js/common.js
function h(v){
if (v == undefined || v == null) return "";
v = ""+v;
v = v.replace(/&/g, '&');
v = v.replace(/"/g, '"');
v = v.replace(/</g, '<');
v = v.replace(/>/g, '>');
return v;
}
function grys_common_update_announce(message, type){
var aelm = document.getElementById('grys_update_announce');
if (!aelm) return;
if (!type) type = "green";
var div = document.createElement('DIV');
div.className = 'grys_announce grys_announce_'+type;
var divclose = document.createElement('DIV');
divclose.className = "announce_closebtn";
divclose.innerHTML = '<span class="wp-menu-image dashicons-before dashicons-no"></span>';
div.appendChild(divclose);
var div2 = document.createElement('DIV');
div2.className = "announce_message";
div2.innerHTML = message;
div.appendChild(div2);
aelm.appendChild(div);
divclose.firstChild.addEventListener('click', function(ev){aelm.removeChild(div)});
}
function grys_formdata(f, withnulls){
var elms = f.elements;
var dt = {};
for(var i = 0; i < elms.length; i++){
if (elms[i].disabled) continue;
if (!elms[i].name) continue;
if (elms[i].tagName.toLowerCase() == "input"){
if (elms[i].type.toLowerCase() == "radio" || elms[i].type.toLowerCase() == "checkbox"){
if (!elms[i].checked) continue;
}
}
var v = elms[i].value;
if (!withnulls){
if (v == "") continue;
}
dt[elms[i].name] = v;
}
return dt;
}
function grys_buildquery(dt){
var v = "";
for(var nm in dt){
if (v != "") v += '&';
v += encodeURIComponent(nm)+"="+encodeURIComponent(dt[nm]);
}
return v;
}
function grys_paging(cur, max, callback){
cur = parseInt(cur);
max = parseInt(max);
if (max == 1) return "";
var html = "";
var st = 1;
if (cur > 5) st = cur-5;
var ed = max;
if (cur < max-5) ed = cur+5;
if (cur > 1){
html += '<strong><a href="javascript:;" onclick="'+callback+'('+(cur-1)+')">←</a></strong>';
}
for(var i = st; i <= ed; i++){
if (cur == i){
html += '<strong class="current">'+i+'</strong>';
}
else{
html += '<strong><a href="javascript:;" onclick="'+callback+'('+(i)+')">'+i+'</a></strong>'
}
}
if (cur < max){
html += '<strong><a href="javascript:;" onclick="'+callback+'('+(cur+1)+')">→</a></strong>';
}
return html;
}