getVarArray=function(data) {
htmljson=data.split("[SYSVAR]");
if(htmljson.length==1) {
htmljson="[SYSVAR]".split("[SYSVAR]");
}
return htmljson;
}
getJSON=function(jstr) {
if(jstr=='') {
return '';
}
try {
return $.parseJSON(jstr);
} catch(e) {
return {};
}
}
function getNoBr(str) {
str=trim(str);
str=str.replace(new RegExp("\n","gm"),"");
str=str.replace(new RegExp("\r","gm"),"");
return str;
}
function win(a,b,c,d)
{
dowin=window.open(a,b,'width='+c+',height='+d+',resizable=1,scrollbars=1,status=0,menubar=1');
dowin.creator=self;
}
//-----------------------------------------Control--------------------------------------------------------
clearUndef=function(sstr) {
if(sstr==undefined) {
return '';
} else {
return sstr;
}
}
function trim(stringToTrim) {
var i, j
//left trim
for(i=0; i=i; j--) {
if (stringToTrim.charAt(j) != " " || stringToTrim.charAt(i) != "\n") break
}
return stringToTrim.substring(i, j + 1)
}
function onlyNum()
{
if(!((event.keyCode>=48&&event.keyCode<=57)||(event.keyCode>=96&&event.keyCode<=105)||(event.keyCode==8 || event.keyCode==190 || event.keyCode==110 || event.keyCode==46))) {
event.returnValue=false;
}
}
function onlyEng()
{
if(!((event.keyCode>=65&&event.keyCode<=90)||(event.keyCode==8 || event.keyCode==190))) {
event.returnValue=false;
}
}
function validateDate(year, month, day)
{
var regex = new RegExp(/S/);
if(regex.test(day)&& regex.test(month) && regex.test(year))
{
var regExp = new RegExp(/d/);
if(!regExp.test(day)|| !regExp.test(month) || !regExp.test(year))
return ("The date fields contains non-number.");
var tempDateValue = year + "/" + month + "/" + day;
if(tempDateValue.length < 6||tempDateValue.length > 10)
return ("The length of date fields is invalid.");
var tempDate = new Date(tempDateValue);
if(isNaN(tempDate))
return ("The scope of date fields is invalid.");
if(parseInt(year) > 1900 && parseInt(year) < 2500 && ((tempDate.getUTCFullYear()).toString()==year) && (tempDate.getMonth()==parseInt(month)-1) && (tempDate.getDate()==parseInt(day)))
return ("The date fields is OK.");
else
return ("The date fields is invalid.");
}
}
//-----------------------------------------Control--------------------------------------------------------
function do_confirm_link(link,msg) {
var x=window.confirm(msg);
if (x) {
window.location.href = link;
}
}
function GookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function Gookie(name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return GookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function Sookie(name, value) {
var argv = Sookie.arguments;
var argc = Sookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires="
+ expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function Dookie(name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = Gookie (name);
document.cookie = name + "=" + cval + "; expires="
+ exp.toGMTString();
}
function SetCookie(COOKIENAME,DATAIS)
{
var expdate = new Date();
// 設定期限為一年後
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
Sookie(COOKIENAME, DATAIS, expdate, "/", null, false);
}
function GetCookie(COOKIENAME){
return Gookie(COOKIENAME)? Gookie(COOKIENAME) : '';
}
function do_search_change(nameis,valueis) {
SetCookie(nameis,valueis);
}
function ShowHide(l){
if(document.getElementById(l).style.display=="none"){
document.getElementById(l).style.display="";
}
else{
document.getElementById(l).style.display="none";
}
}
function showDiv(sDivID, bState) {
var oDiv = document.getElementById(sDivID);
/*@cc_on
@if (@_jscript_version >= 5)
try {
var oIframe = document.getElementById('HelpFrame');
oIframe.scrolling = 'no';
}
catch (e) {
var oIframe = document.createElement('iframe');
var oParent = oDiv.parentNode;
oIframe.id = 'HelpFrame';
oParent.appendChild(oIframe);
}
oIframe.frameborder = 0;
oIframe.style.position = 'absolute';
oIframe.style.top = 0;
oIframe.style.left = 0;
oIframe.style.display = 'none';
@end @*/
if (bState) {
oDiv.style.display = 'block';
/*@cc_on
@if (@_jscript_version >= 5)
oIframe.style.top = oDiv.style.top;
oIframe.style.left = oDiv.style.left;
oIframe.style.zIndex = oDiv.style.zIndex - 1;
oIframe.style.width = parseInt(oDiv.offsetWidth);
oIframe.style.height = parseInt(oDiv.offsetHeight);
oIframe.style.display = 'block';
@end @*/
}
else {
/*@cc_on
@if (@_jscript_version >= 5)
oIframe.style.display = 'none';
@end @*/
oDiv.style.display = 'none';
}
}
function ShowMe(l){
$('#'+l).show();
}
function HideMe(l){
$('#'+l).hide();
}
function focus_select(sel,selval) {
for (l=0; lw) {
w=1100;
}
var x = screen.width/2 - w/2;
var y = screen.height/2 - 600/2;
selfwin=window.open(t, 'openwin123','resizable=1,scrollbars=1,status=0,menubar=1,height=700,width='+w+',left='+x+',top='+y);
selfwin.creator=self;
void(0);
}
function openBlankWin(t)
{
var w=1024;
if(screen.width>w) {
w=1100;
}
var x = screen.width/2 - w/2;
var y = screen.height/2 - 700/2;
selfwin=window.open(t, '_blank','resizable=1,scrollbars=1,status=0,menubar=1,height=700,width='+w+',left='+x+',top='+y);
selfwin.creator=self;
void(0);
}
function openBlankWinOverLay(d,url) {
runOverLay(d,"openBlankWin('"+url+"');");
}
function openWinOverLay(d,url,w,h) {
runOverLayClose(d,"openSizeWin('"+url+"','"+w+"','"+h+"');");
}
function openSizeWin(t,w,h)
{
var x = screen.width/2 - w/2;
var y = screen.height/2 - h/2;
selfwin=window.open(t, 'openwin123','resizable=1,scrollbars=1,status=0,menubar=1,height='+h+',width='+w+',left='+x+',top='+y);
selfwin.creator=self;
void(0);
}
function openWinOverLay(d,url) {
runOverLayClose(d,"openWin('"+url+"');");
}
function openSizeWinOverLay(d,url,w,h) {
runOverLayClose(d,"openSizeWin('"+url+"','"+w+"','"+h+"');");
}
$(document).unbind('keydown').bind('keydown', function (event) {
var doPrevent = false;
if (event.keyCode === 8) {
var d = event.srcElement || event.target;
if ((d.tagName.toUpperCase() === 'INPUT' && (d.type.toUpperCase() === 'EMAIL' || d.type.toUpperCase() === 'TEL' || d.type.toUpperCase() === 'TEXT' || d.type.toUpperCase() === 'PASSWORD' || d.type.toUpperCase() === 'FILE'))
|| d.tagName.toUpperCase() === 'TEXTAREA') {
doPrevent = d.readOnly || d.disabled;
}
else {
doPrevent = true;
}
}
if (doPrevent) {
event.preventDefault();
}
});
function getAge(birth_year,birth_month,birth_day)
{
today_date = new Date();
today_year = today_date.getFullYear();
today_month = today_date.getMonth();
today_day = today_date.getDate();
age = today_year - birth_year;
if ( today_month < (birth_month - 1))
{
age--;
}
if (((birth_month - 1) == today_month) && (today_day < birth_day))
{
age--;
}
return age;
}
function checkEmail(e) {
ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
for(i=0; i < e.length ;i++){
if(ok.indexOf(e.charAt(i))<0){
return (false);
}
}
if (document.images) {
re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (!e.match(re) && e.match(re_two)) {
return (-1);
}
}
}
function checkLocalMobile(e) {
if(e.charAt(0)=='6' && e.length==8) {
return true;
} else {
return false;
}
}
function checkDateOK(yy,mm,dd,hh,min) {
var m = parseInt(mm, 10);
var d = parseInt(dd, 10);
var y = parseInt(yy, 10);
var date = new Date(y,m-1,d);
if (date.getFullYear() == y && date.getMonth() + 1 == m && date.getDate() == d && hh<=23 && min<=59) {
return true;
} else {
return false;
}
}
function showTips(x,y,w,h,msg) {
var idis='d'+x+''+y+''+w+''+h;
$('body').append("");
}
/* jQuery Storage API Plugin 1.7.3 https://github.com/julien-maurel/jQuery-Storage-API */
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports?require("jquery"):jQuery)}(function(e){function t(t){var r,i,n,o=arguments.length,s=window[t],a=arguments,u=a[1];if(2>o)throw Error("Minimum 2 arguments must be given");if(e.isArray(u)){i={};for(var f in u){r=u[f];try{i[r]=JSON.parse(s.getItem(r))}catch(c){i[r]=s.getItem(r)}}return i}if(2!=o){try{i=JSON.parse(s.getItem(u))}catch(c){throw new ReferenceError(u+" is not defined in this storage")}for(var f=2;o-1>f;f++)if(i=i[a[f]],void 0===i)throw new ReferenceError([].slice.call(a,1,f+1).join(".")+" is not defined in this storage");if(e.isArray(a[f])){n=i,i={};for(var m in a[f])i[a[f][m]]=n[a[f][m]];return i}return i[a[f]]}try{return JSON.parse(s.getItem(u))}catch(c){return s.getItem(u)}}function r(t){var r,i,n=arguments.length,o=window[t],s=arguments,a=s[1],u=s[2],f={};if(2>n||!e.isPlainObject(a)&&3>n)throw Error("Minimum 3 arguments must be given or second parameter must be an object");if(e.isPlainObject(a)){for(var c in a)r=a[c],e.isPlainObject(r)?o.setItem(c,JSON.stringify(r)):o.setItem(c,r);return a}if(3==n)return"object"==typeof u?o.setItem(a,JSON.stringify(u)):o.setItem(a,u),u;try{i=o.getItem(a),null!=i&&(f=JSON.parse(i))}catch(m){}i=f;for(var c=2;n-2>c;c++)r=s[c],i[r]&&e.isPlainObject(i[r])||(i[r]={}),i=i[r];return i[s[c]]=s[c+1],o.setItem(a,JSON.stringify(f)),f}function i(t){var r,i,n=arguments.length,o=window[t],s=arguments,a=s[1];if(2>n)throw Error("Minimum 2 arguments must be given");if(e.isArray(a)){for(var u in a)o.removeItem(a[u]);return!0}if(2==n)return o.removeItem(a),!0;try{r=i=JSON.parse(o.getItem(a))}catch(f){throw new ReferenceError(a+" is not defined in this storage")}for(var u=2;n-1>u;u++)if(i=i[s[u]],void 0===i)throw new ReferenceError([].slice.call(s,1,u).join(".")+" is not defined in this storage");if(e.isArray(s[u]))for(var c in s[u])delete i[s[u][c]];else delete i[s[u]];return o.setItem(a,JSON.stringify(r)),!0}function n(t,r){var n=a(t);for(var o in n)i(t,n[o]);if(r)for(var o in e.namespaceStorages)u(o)}function o(r){var i=arguments.length,n=arguments,s=(window[r],n[1]);if(1==i)return 0==a(r).length;if(e.isArray(s)){for(var u=0;ui)throw Error("Minimum 2 arguments must be given");if(e.isArray(o)){for(var a=0;a1?t.apply(this,o):n,a._cookie)for(var u in e.cookie())""!=u&&s.push(u.replace(a._prefix,""));else for(var f in a)s.push(f);return s}function u(t){if(!t||"string"!=typeof t)throw Error("First parameter must be a string");g?(window.localStorage.getItem(t)||window.localStorage.setItem(t,"{}"),window.sessionStorage.getItem(t)||window.sessionStorage.setItem(t,"{}")):(window.localCookieStorage.getItem(t)||window.localCookieStorage.setItem(t,"{}"),window.sessionCookieStorage.getItem(t)||window.sessionCookieStorage.setItem(t,"{}"));var r={localStorage:e.extend({},e.localStorage,{_ns:t}),sessionStorage:e.extend({},e.sessionStorage,{_ns:t})};return e.cookie&&(window.cookieStorage.getItem(t)||window.cookieStorage.setItem(t,"{}"),r.cookieStorage=e.extend({},e.cookieStorage,{_ns:t})),e.namespaceStorages[t]=r,r}function f(e){if(!window[e])return!1;var t="jsapi";try{return window[e].setItem(t,t),window[e].removeItem(t),!0}catch(r){return!1}}var c="ls_",m="ss_",g=f("localStorage"),h={_type:"",_ns:"",_callMethod:function(e,t){var r=[this._type],t=Array.prototype.slice.call(t),i=t[0];return this._ns&&r.push(this._ns),"string"==typeof i&&-1!==i.indexOf(".")&&(t.shift(),[].unshift.apply(t,i.split("."))),[].push.apply(r,t),e.apply(this,r)},get:function(){return this._callMethod(t,arguments)},set:function(){var t=arguments.length,i=arguments,n=i[0];if(1>t||!e.isPlainObject(n)&&2>t)throw Error("Minimum 2 arguments must be given or first parameter must be an object");if(e.isPlainObject(n)&&this._ns){for(var o in n)r(this._type,this._ns,o,n[o]);return n}var s=this._callMethod(r,i);return this._ns?s[n.split(".")[0]]:s},remove:function(){if(arguments.length<1)throw Error("Minimum 1 argument must be given");return this._callMethod(i,arguments)},removeAll:function(e){return this._ns?(r(this._type,this._ns,{}),!0):n(this._type,e)},isEmpty:function(){return this._callMethod(o,arguments)},isSet:function(){if(arguments.length<1)throw Error("Minimum 1 argument must be given");return this._callMethod(s,arguments)},keys:function(){return this._callMethod(a,arguments)}};if(e.cookie){window.name||(window.name=Math.floor(1e8*Math.random()));var l={_cookie:!0,_prefix:"",_expires:null,_path:null,_domain:null,setItem:function(t,r){e.cookie(this._prefix+t,r,{expires:this._expires,path:this._path,domain:this._domain})},getItem:function(t){return e.cookie(this._prefix+t)},removeItem:function(t){return e.removeCookie(this._prefix+t)},clear:function(){for(var t in e.cookie())""!=t&&(!this._prefix&&-1===t.indexOf(c)&&-1===t.indexOf(m)||this._prefix&&0===t.indexOf(this._prefix))&&e.removeCookie(t)},setExpires:function(e){return this._expires=e,this},setPath:function(e){return this._path=e,this},setDomain:function(e){return this._domain=e,this},setConf:function(e){return e.path&&(this._path=e.path),e.domain&&(this._domain=e.domain),e.expires&&(this._expires=e.expires),this},setDefaultConf:function(){this._path=this._domain=this._expires=null}};g||(window.localCookieStorage=e.extend({},l,{_prefix:c,_expires:3650}),window.sessionCookieStorage=e.extend({},l,{_prefix:m+window.name+"_"})),window.cookieStorage=e.extend({},l),e.cookieStorage=e.extend({},h,{_type:"cookieStorage",setExpires:function(e){return window.cookieStorage.setExpires(e),this},setPath:function(e){return window.cookieStorage.setPath(e),this},setDomain:function(e){return window.cookieStorage.setDomain(e),this},setConf:function(e){return window.cookieStorage.setConf(e),this},setDefaultConf:function(){return window.cookieStorage.setDefaultConf(),this}})}e.initNamespaceStorage=function(e){return u(e)},g?(e.localStorage=e.extend({},h,{_type:"localStorage"}),e.sessionStorage=e.extend({},h,{_type:"sessionStorage"})):(e.localStorage=e.extend({},h,{_type:"localCookieStorage"}),e.sessionStorage=e.extend({},h,{_type:"sessionCookieStorage"})),e.namespaceStorages={},e.removeAllStorages=function(t){e.localStorage.removeAll(t),e.sessionStorage.removeAll(t),e.cookieStorage&&e.cookieStorage.removeAll(t),t||(e.namespaceStorages={})}});
var sitekey="prognew";
var lStorage=$.localStorage;
/*=============cookie & storage================*/
function setCookie(name, value, days) {
var date,expires;
if (days) {
date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toGMTString();
} else {
expires = "";
}
document.cookie = escape(name) + "=" + escape(value) + expires + "; path=/";
}
function getCookie(name) {
var nameEQ = escape(name) + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1, c.length);
}
if (c.indexOf(nameEQ) == 0) {
return unescape(c.substring(nameEQ.length, c.length));
}
}
return null;
}
function delCookie(name) {
setCookie(name, "", 30);
}
function getLS(n) {
var enc="";
enc=sitekey+"_"+n;
var v="";
try {
v=lStorage.get(enc)||"";
} catch(e) {
v=getCookie(enc)||"";
}
return v;
}
function setLS(n,v) {
var enc="";
var env="";
enc=sitekey+"_"+n;
env=v;
try {
lStorage.set(enc,env);
} catch(e) {
setCookie(enc, env, 365);
}
}
function delLS(n) {
var enc="";
enc=sitekey+"_"+n;
try {
lStorage.remove(enc);
} catch(e) {
delCookie(enc);
}
}
var isIE="";
if (document.documentMode || /Edge/.test(navigator.userAgent)) {
isIE="1";
}
function refreshNumber() {
$(".codenumber").on("keypress keyup blur paste change",function (event) {
if(isIE=="") {
$(this).val($(this).val().replace(/[^0-9\-\/\(\)]/g,''));
}
if ((event.which != 40 && event.which != 41 && event.which != 45 && event.which != 47) && (event.which < 48 || event.which > 57)) {
event.preventDefault();
}
});
$(".number").on("keypress keyup blur paste change",function (event) {
if(isIE=="") {
$(this).val($(this).val().replace(/[^0-9\.]/g,''));
}
if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) {
event.preventDefault();
}
});
$(".intnumber").on("keypress keyup blur paste change",function (event) {
if(isIE=="") {
$(this).val($(this).val().replace(/[^0-9]/g,''));
}
if (event.which < 48 || event.which > 57) {
event.preventDefault();
}
});
$(".english").on("keypress keyup blur paste change",function (event) {
if(isIE=="") {
$(this).val($(this).val().replace(/[^a-zA-Z\s]/, ""));
}
if ((event.which < 65 || event.which > 90) && (event.which < 97 || event.which > 122) && event.which!=32) {
event.preventDefault();
}
});
$(".englishcodenumber").on("keypress keyup blur paste change",function (event) {
if(isIE=="") {
$(this).val($(this).val().replace(/[^0-9a-zA-Z\-\/\(\)]/g,''));
}
if ((event.which < 65 || event.which > 90) && (event.which < 97 || event.which > 122) && (event.which != 40 && event.which != 41 && event.which != 45 && event.which != 47) && (event.which < 48 || event.which > 57)) {
event.preventDefault();
}
});
}
$(window).load(function(){
refreshNumber();
});
var mousex;
var mousex;
var mousey;
var newmousex;
var newmousey;
var targetis;
var config = {
'.chosen-select' : {search_contains:true},
'.chosen-select-deselect' : {allow_single_deselect:true},
'.chosen-select-no-single' : {disable_search_threshold:10},
'.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
'.chosen-select-width' : {width:"95%"}
}
$(document).ready(function() {
// $('.number').jStepper({allowDecimals:true});
// $('.intnumber').jStepper({allowDecimals:false});
$(document).mousemove(function(e){
mousex=e.pageX;
mousey=e.pageY;
newmousex=mousex+60;
newmousey=mousey;
$targetis = $(event.target);
});
var savelang='已儲存! salvou! saved!';
$('body').append(''+savelang+'
');
$body = $("body");
$( document ).ajaxComplete(function( event, xhr, settings ) {
if((xhr.responseText).indexOf("RESULTTYPE=RELOGIN")!=-1) {
alert("系統因長期沒有資料上傳而連線中斷, 請重新登入以便繼續操作\n\nO sistema é desconectada desde não há dados de upload por um longo tempo, é favor de fazer o login novamente\n\nThe system is disconnected since there is no data upload for a long time, please login again");
}
refreshNumber();
refreshSelects();
});
for (var selector in config) {
$(selector).chosen(config[selector]);
}
});
function clickedStyle(idis,defaultcolor) {
defaultcolor=defaultcolor || '';
$('#'+idis).css('background-color','#99ffb1');
showSaved();
setTimeout(function() {
$('#'+idis).css('background-color',defaultcolor);
},500);
}
function showSaved() {
$('#savedmsg').css('left', (($(document).width()/2)-100)+'px').css('top',$(document).scrollTop()+'px');
$('#savedmsg').show();
window.setTimeout(function() {
$('#savedmsg').fadeOut();
},2000);
}
function formatFloat(num, pos)
{
var size = Math.pow(10, pos);
return Math.round(num * size) / size;
}
function getSelList(idis) {
var allstr='';
$('#'+idis+' :selected').each(function(i, selected){
allstr += $(selected).val()+',';
});
return allstr;
}
function refreshSelects() {
$('select').each(function(){
$(this).siblings('.chosen-container').css('width', realWidth($(this)));
});
function realWidth($element){
var $clone = $element.clone();
$clone.css("visibility","hidden");
$('body').append($clone);
var width = $clone.outerWidth();
$clone.remove();
return width;
}
}
(function ($) {
$.fn.restrict = function () {
return this.each(function(){
$(this).on('change', function(){
var _self = this,
v = parseFloat(_self.value),
min = parseFloat(_self.min),
max = parseFloat(_self.max);
if (v >= min && v <= max){
_self.value = v;
}
else {
_self.value = v < min ? min : max;
}
});
});
};
var oldshow = $.fn.show;
$.fn.show = function()
{
var ret = oldshow.apply(this, arguments);
refreshSelects();
return ret;
};
})(jQuery);