MINI
C:
/
SiakApp
/
web
/
CatatanSipilAssets
/
js
/
Upload File:
files >> C:/SiakApp/web/CatatanSipilAssets/js/capilFunction.js
function count_days(date1, date2) { var each_day = 1000 * 60 * 60 * 24;//milliseconds in a day var ms_date1 = date1.getTime();//milliseconds for date1 var ms_date2 = date2.getTime();//milliseconds for date2 var ms_date_diff = ms_date1 - ms_date2;//different of the two dates in milliseconds var days = Math.round(ms_date_diff / each_day);//divided the different with millisecond in a day return days; } function actionSubmit() { if (document.getElementById('formulir')) { try { document.getElementById('formulir').onsubmit(); } catch(e){} document.getElementById('formulir').submit(); } } function actionSet(key, val) { if (document.getElementById(key)) document.getElementById(key).value = val; } function actionGet(key) { if (document.getElementById(key)) return document.getElementById(key).value; } function actionSetTitle(key, val) { if (document.getElementById(key)) return document.getElementById(key).title = val; } function actionGetTitle(key) { if (document.getElementById(key)) return document.getElementById(key).title; } function actionObject(key) { if (document.getElementById(key)) return document.getElementById(key); } function actionType(key) { if (document.getElementById(key)) return document.getElementById(key).tagName; } function actionMaxLength(key) { if (document.getElementById(key)) return document.getElementById(key).maxLength; } function actionFocus(key) { //if (document.getElementById(key)) document.getElementById(key).focus(); } function actionDisabled(key, status) { if (document.getElementById(key)) document.getElementById(key).disabled=status; } function actionLength(key, lgth, mode) { var oval = actionGet(key); if (oval) { if (mode == "LESS") { return (oval.length < lgth) ? true : false; } else if (mode == "MORE") { return (oval.length > lgth) ? true : false; } else { return (oval.length == lgth) ? true : false; } } } function actionGetMultiple(key) { var txtSelectedObject = document.getElementById(key); var selectedArray = new Array(); if (txtSelectedObject) { var count = 0; for (var i=0; i < txtSelectedObject.options.length; i++) { if (txtSelectedObject.options[i].selected) { selectedArray[count] = txtSelectedObject.options[i].value; count++; } } return selectedArray; } } function actionCheckInteger(key) { if (document.getElementById(key)) { var txtObject = document.getElementById(key); reg = new RegExp("^[0-9]*$"); return (reg.test(txtObject.value)) ? true : false; } else return false } function actionGetChecked(key) { if (document.getElementById(key)) return document.getElementById(key).checked; } function actionCheckDoubleValue(obj) { var err = false; var arrObj = obj.split(";"); if (arrObj) { for (var i = 0; i< arrObj.length; i++) { for (var j = 0; j< arrObj.length; j++) { //alert(arrObj[i]+"/"+arrObj[j]); if (arrObj[i]!=arrObj[j]) { if(document.getElementById(arrObj[i]).value && document.getElementById(arrObj[j]).value) { if(document.getElementById(arrObj[i]).value == document.getElementById(arrObj[j]).value) { err = true; break; } } } } } } return err; } function actionGetCheckSelected(totalObject, keyObject) { if (actionGet(totalObject)) { var returnValue = ""; for (i = 0; i < actionGet(totalObject); i++) { if (actionGetChecked(keyObject + "" + i)) { if (returnValue != '') returnValue += ";"; returnValue += actionGet(keyObject + "" + i); } } return returnValue; } } function actionCheckMaxLength() { var form, elements, i, elm; form = document.getElementById ? document.getElementById('form') : document.forms['form']; var retValue = true; if (document.getElementsByTagName) { elements = form.getElementsByTagName('input'); for( i=0, elm; elm=elements.item(i++); ) { if (elm.getAttribute('type') == "text" && elm.maxlength) { if (elm.value.length > elm.maxlength) { alert('Error : Isian terlalu banyak!'); retValue = false; } } } } else { elements = form.elements; for( i=0, elm; elm=elements[i++]; ) { if (elm.type == "text" && elm.maxlength) { if (elm.value.length > elm.maxlength) { alert('Error : Isian terlalu banyak!'); retValue = false; } } } } return retValue; } function actionGetDate(year, month, day) { var theDate = ''; if (document.getElementById(year) && document.getElementById(year).value) theDate = document.getElementById(year).value; if (document.getElementById(month) && document.getElementById(month).value) theDate+= "-" + document.getElementById(month).value; if (document.getElementById(day) && document.getElementById(day).value) theDate+= "-" + document.getElementById(day).value; return theDate; } function actionSetClass(key, val) { if (document.getElementById(key)) document.getElementById(key).className = val; } function actionChecked(key, val) { if (document.getElementById(key)) document.getElementById(key).checked = val; } function actionReadonly(key, val) { if (document.getElementById(key)) document.getElementById(key).readonly = val; } function actionSetId(id) { document.getElementById('id').value=id; } function actionSetInner(key, val) { if (document.getElementById(key)) document.getElementById(key).innerHTML = val; } function actionSetAction(act) { document.getElementById('setAction').value=act; } function actionNew() { actionSetId(""); actionSetAction("add"); actionSubmit(); } function actionEdit(url, id) { window.open(url + '?id=' + id, 'capilWindow', 'fullscreen=yes, scrollbars=yes'); //capilWindow.focus(); } function actionDel(id) { actionSetId(id); if (actionGet('id') != '') { actionSetAction("delete"); if (confirm('Anda yakin akan menghapus data ini? ')){ actionSubmit(); //location.replace(location.href+"?id="+id+"&setAction=delete"); } } else alert('Kesalahan : Silahkan pilih data yang akan di hapus'); } function actionDelSelected() { if (actionGet('boxchecked')!=0) { actionSetId(""); actionSetAction("delete"); if (confirm('Anda yakin akan menghapus data yang terpilih/tercontreng? ')){ actionSubmit(); } } else alert('Kesalahan : Silahkan pilih data yang akan di hapus'); } function actionResetSelected() { if (actionGet('boxchecked')!=0) { actionSetId(""); actionSetAction("reset"); if (confirm('Anda yakin akan melakukan reset terhadap jumlah pencetakan pada rekod yang terpilih/tercontreng? ')){ actionSubmit(); } } else alert('Kesalahan : Silahkan pilih data yang akan di hapus'); } function actionCheckAll( n, fieldName ) { if (!fieldName) { fieldName = 'cb'; } var chk = document.getElementById('toggle').checked; var n2 = 0; for (i=0; i < n; i++) { cb = eval('document.getElementById(\'cb' + '' + i + '\')'); if (cb) { cb.checked = chk; n2++; } } if (chk) actionSet('boxchecked', n2); else actionSet('boxchecked', 0); } function actionCheckRow(n) { var cb = eval('document.getElementById(\'cb' + '' + n + '\')'); if (cb.checked) { cb.checked=false; } else { cb.checked=true; } isChecked(n); } function actionIsChecked(n){ var cb = eval('document.getElementById(\'cb' + '' + n + '\')'); if (cb.checked){ document.formulir.boxchecked.value++; } else { document.formulir.boxchecked.value--; } } function listChecked(cb){ if (cb.checked){ document.getElementById('listchecked').value++; if (document.getElementById('listchecked').value>6) { document.getElementById('listchecked').value = 6; cb.checked = false; } } else { document.getElementById('listchecked').value--; } } function popupWindow(mypage, myname, w, h, scroll) { var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable' win = window.open(mypage, myname, winprops) if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } } // Tab Function End function removeElement(divParent, divChild) { var d = document.getElementById(divParent); var olddiv = document.getElementById(divChild); d.removeChild(olddiv); } function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""); } function actionTags(tagField, tagTitle) { var fieldName = document.getElementById(tagField); var fieldValue = fieldName.value; if (fieldValue!='') { var val = fieldValue.split(","); } if (val) { for (var i = 0; i< val.length; i++) { val[i] = trim(val[i]); if (val[i]==tagTitle) { return alert('Sorry, Already exists!'); } } } if (fieldValue!='') document.getElementById(tagField).value+= ", " + tagTitle; else document.getElementById(tagField).value = tagTitle; } function actionGetAbsolutePos(el) { var r = { x: el.offsetLeft, y: el.offsetTop }; if (el.offsetParent) { var tmp = actionGetAbsolutePos(el.offsetParent); r.x += tmp.x; r.y += tmp.y; } return r; } function actionError(errObj, msg) { var theErrBox = actionObject("box_error"); var theMsgBox = actionObject("box_error_message"); var theErrObject = actionObject(errObj); var theErrPos = actionGetAbsolutePos(theErrObject); if (theErrBox) { theMsgBox.innerHTML = msg; theErrBox.style.display ="block"; theErrBox.style.left = theErrPos.x + "px"; theErrBox.style.top = (theErrPos.y + theErrObject.offsetHeight) + "px"; } } function actionErrors(errObj, msg) { var theName = "boxError"; var theMsgBox = "boxMessage"; var theErrObject = actionObject(errObj); var theErrPos = actionGetAbsolutePos(theErrObject); if (actionObject(theName)) { var theErrBox = actionObject(theName); theMsgBox.innerHtml = msg; theErrBox.className ="alertInside"; } else { var body = document.getElementsByTagName("body")[0]; var boxWarnImage = document.createElement("img"); boxWarnImage.src = "../../CatatanSipilAssets/images/ikon_alert.gif"; var boxCloseImage = document.createElement("img"); boxCloseImage.src = "../../CatatanSipilAssets/images/ikon_del.gif"; var boxClose = document.createElement("div"); boxClose.style.float = "right"; boxClose.style.marginTop = "5px"; boxClose.className = "pointer"; //boxClose.addEventListener("onclick", actionAlertClose, true); boxClose.appendChild(boxCloseImage); var boxWarn = document.createElement("div"); boxWarn.style.float = "left"; boxWarn.style.marginRight = "10px"; boxWarn.appendChild(boxWarnImage); var theMsgBox = document.createElement("div"); theMsgBox.className = "arial bold big red"; //theMsgBox.appendChild(msg); var theErrBox = document.createElement("div"); theErrBox.id = theName; //theErrBox.addEvent(boxClose, "mousedown", actionErrorClose); theErrBox.style.position = "absolute"; theErrBox.className ="alertInside"; theErrBox.appendChild(boxClose); theErrBox.appendChild(boxWarn); theErrBox.appendChild(theMsgBox); body.appendChild(theErrBox); } theErrBox.left = theErrPos.x + "px"; theErrBox.top = (theErrPos.y + theErrObject.offsetHeight) + "px"; } function actionHighlight(errObj) { if (obj = actionObject(errObj)) { obj.className = "errorHighlight"; } } function actionHighlightCapil(errObj,errorHighlight) { if(errorHighlight == "errorHighlight"){ errObj.className = errorHighlight; }else{ errObj.className = ""; } //if (obj = actionObject(errObj)) //{ // alert(errorHighlight); // obj.className = errorHighlight; //} } function actionGoNext(obj, event) { var oval = obj.value; if (event.keyCode != 9) { if (oval.length == obj.maxLength) { for (i = 0; i < obj.form.elements.length; i++) { if (obj.form.elements[i].tabIndex == obj.tabIndex+1) { obj.form.elements[i].focus(); if (obj.form.elements[i].type == "text") obj.form.elements[i].select(); break; } } return false; } return true; } } function actionGetPageSize(){ var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = document.body.scrollWidth; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { // all except Explorer windowWidth = self.innerWidth; windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if(xScroll < windowWidth){ pageWidth = windowWidth; } else { pageWidth = xScroll; } arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) return arrayPageSize; } function actionGetPageScroll(){ var yScroll; if (self.pageYOffset) { yScroll = self.pageYOffset; } else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict yScroll = document.documentElement.scrollTop; } else if (document.body) {// all other Explorers yScroll = document.body.scrollTop; } arrayPageScroll = new Array('',yScroll) return arrayPageScroll; } function actionInitBox() { var objBody = document.getElementsByTagName("body").item(0); var objOverlay = document.createElement("div"); objOverlay.setAttribute('id','overlay'); objOverlay.style.display = 'none'; objOverlay.style.position = 'absolute'; objOverlay.style.top = '0'; objOverlay.style.left = '0'; objOverlay.style.zIndex = '100'; objOverlay.style.width = '100%'; objBody.insertBefore(objOverlay, objBody.firstChild); } function actionShowWaitBox() { //if (!actionObject('overlay')) actionInitBox(); var objOverlay = actionObject('overlay'); var objFlash = actionObject('headflash'); var arrayPageSize = actionGetPageSize(); var arrayPageScroll = actionGetPageScroll(); objOverlay.style.height = (arrayPageSize[1] + 'px'); objOverlay.style.display = 'block'; objOverlay.style.visibility = "visible"; /*objFlash.style.display = 'none'; objFlash.style.visibility = "hidden";*/ selects = document.getElementsByTagName("select"); for (i = 0; i != selects.length; i++) { selects[i].style.visibility = "hidden"; } var arrayPageSize = actionGetPageSize(); var arrayPageScroll = actionGetPageScroll(); if (actionObject('box_wait')) { box = actionObject('box_wait'); box.style.display = 'block'; box.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 85) / 2) + 'px'); box.style.left = (((arrayPageSize[0] - 450) / 2) + 'px'); } } function actionShowSuccessBox() { //if (!actionObject('overlay')) actionInitBox(); var objOverlay = actionObject('overlay'); var objFlash = actionObject('headflash'); var arrayPageSize = actionGetPageSize(); var arrayPageScroll = actionGetPageScroll(); objOverlay.style.height = (arrayPageSize[1] + 'px'); objOverlay.style.display = 'block'; objFlash.style.display = 'none'; objFlash.style.visibility = "hidden"; selects = document.getElementsByTagName("select"); for (i = 0; i != selects.length; i++) { selects[i].style.visibility = "hidden"; } var arrayPageSize = actionGetPageSize(); var arrayPageScroll = actionGetPageScroll(); if (actionObject('box_success')) { box = actionObject('box_success'); box.style.display = 'block'; box.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 85) / 2) + 'px'); box.style.left = (((arrayPageSize[0] - 520) / 2) + 'px'); } } function actionHideSuccessBox() { var objOverlay = actionObject('overlay'); objOverlay.style.display = 'none'; objOverlay.style.visibility = "hidden"; var objFlash = actionObject('headflash'); objFlash.style.display = 'block'; objFlash.style.visibility = "visible"; selects = document.getElementsByTagName("select"); for (i = 0; i != selects.length; i++) { selects[i].style.visibility = "visible"; } var arrayPageSize = actionGetPageSize(); var arrayPageScroll = actionGetPageScroll(); if (actionObject('box_success')) { var box = actionObject('box_success'); box.style.display = 'none'; } } function actionLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function'){ window.onload = func; } else { window.onload = function(){ oldonload(); func(); } } } function actionShowDocument(url) { var divOverlay = actionObject('overlay'); var divDocument = actionObject('boxDoc'); var contentDocument = actionObject('content_pdf'); var arrayPageSize = actionGetPageSize(); var scrollPos = actionGetPageScroll(); var newWidth = Math.round(arrayPageSize[2] * 0.85); var newHeight = Math.round(arrayPageSize[3] * 0.8); window.showModalDialog(url,"nama","dialogWidth:760px;dialogHeight:"+newHeight+"px;status:no;scroll:no"); /* contentDocument.style.height = (newHeight - 20) + 'px'; divOverlay.style.height = (arrayPageSize[1] + 'px'); divOverlay.style.display = 'block'; divOverlay.style.visibility = "visible"; divDocument.style.width = (newWidth + 'px'); divDocument.style.height = (newHeight + 'px'); var posLeft = Math.round((arrayPageSize[2] / 2) - (newWidth / 2)); var posTop = Math.round((arrayPageSize[3] / 2) - (newHeight / 2)); if (scrollPos[1] > 0) posTop += scrollPos[1]; divDocument.style.top = posTop + 'px'; divDocument.style.left = posLeft + 'px'; divDocument.style.display = 'block'; divDocument.style.visibility = "visible"; selects = document.getElementsByTagName("select"); for (i = 0; i != selects.length; i++) { selects[i].style.visibility = "hidden"; } embeds = document.getElementsByTagName("embed"); for (i = 0; i != embeds.length; i++) { embeds[i].style.visibility = "hidden"; } objects = document.getElementsByTagName("object"); for (i = 0; i != objects.length; i++) { objects[i].style.visibility = "hidden"; } contentDocument.src = url; */ } function actionShowDocumentKwn(url) { var divOverlay = actionObject('overlay'); var divDocument = actionObject('boxDoc'); var contentDocument = actionObject('content_pdf'); var arrayPageSize = actionGetPageSize(); var scrollPos = actionGetPageScroll(); var newWidth = Math.round(arrayPageSize[2] * 0.85); var newHeight = Math.round(arrayPageSize[3] * 0.8); window.showModalDialog(url,"nama","dialogWidth:815px;dialogHeight:"+newHeight+"px;status:no;scroll:no"); } function actionCloseDocument() { var divOverlay = actionObject('overlay'); var divDocument = actionObject('boxDoc'); var contentDocument = actionObject('content_pdf'); divOverlay.style.display = 'none'; divOverlay.style.visibility = "hidden"; divDocument.style.display = 'none'; divDocument.style.visibility = "hidden"; selects = document.getElementsByTagName("select"); for (i = 0; i != selects.length; i++) { selects[i].style.visibility = "visible"; } embeds = document.getElementsByTagName("embed"); for (i = 0; i != embeds.length; i++) { embeds[i].style.visibility = "visible"; } objects = document.getElementsByTagName("object"); for (i = 0; i != objects.length; i++) { objects[i].style.visibility = "visible"; } contentDocument.src = ""; } function actionSetTabbed(totalObject, current) { for(var i = 0; i < totalObject; i++) { $('tab[' + i + ']').className = 'tab-close pointer'; $('group[' + i + ']').className = 'hide'; } $('tab[' + current + ']').className = 'tab-open'; $('group[' + current + ']').className = 'show'; }
Copyright ©2021 || Defacer Indonesia