MINI
C:
/
SiakApp
/
web
/
CatatanSipilAssets
/
js
/
Upload File:
files >> C:/SiakApp/web/CatatanSipilAssets/js/default.js
function actionSubmit() { try { document.getElementById('adminForm').onsubmit(); } catch(e){} document.getElementById('adminForm').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 actionObject(key) { if (document.getElementById(key)) return document.getElementById(key); } 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,1}[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 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 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(); } } else alert('Error : Please select from the list to delete'); } function actionDelSelected() { if (actionGet('boxchecked')!=0) { actionSetId(""); actionSetAction("delete"); if (confirm('Anda yakin akan menghapus data yang terpilih/tercontreng? ')){ actionSubmit(); } } else alert('Error : Please select from the list to delete'); } function actionCheckAll( n, fieldName ) { if (!fieldName) { fieldName = 'cb'; } var chk = document.getElementById('toggle').checked; var n2 = 0; for (i=0; i < n; i++) { //alert('document.getElementById(\'cb' + '' + 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.adminForm.boxchecked.value++; } else { document.adminForm.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 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(); } } } //actionLoadEvent(actionInitBox);
Copyright ©2021 || Defacer Indonesia