var fdElement = '';
var ckContentField = 'content';
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
var tmpMouseX = 0
var tmpMouseY = 0
var MouseX = 0
var MouseY = 0
var clickX = 0
var clickY = 0
var scrnX = 0
var scrnY = 0
document.onmousemove = getMouseXY;
function getMouseXY(e) {
if (IE) {
tmpMouseX = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft
tmpMouseY = event.clientY + document.body.scrollTop + document.documentElement.scrollTop
scrnX = event.screenX;
scrnY = event.screenY;
} else {
tmpMouseX = e.pageX
tmpMouseY = e.pageY
scrnX = e.screenX;
scrnY = e.screenY;
}
if (scrnX < 0){scrnX = 0}
if (scrnY < 0){scrnY = 0}
if (tmpMouseX < 0){tmpMouseX = 0}
if (tmpMouseY < 0){tmpMouseY = 0}
MouseX = parseInt(tmpMouseX)
MouseY = parseInt(tmpMouseY)
return true
}
function getPageScroll(){
var scrollY = 0;
if (self.pageYOffset)
{
scrollY = self.pageYOffset;
}
else if (document.documentElement && document.documentElement.scrollTop)
{
scrollY = document.documentElement.scrollTop;
}
else if (document.body)
{
scrollY = document.body.scrollTop;
}
return scrollY;
}
function showFixedPopup(hoverPopupID, x, y){
if(x==undefined) x = 0;
if(y==undefined) y = 0;
hp = document.getElementById(hoverPopupID);
var scrollY = getPageScroll();
var tmpClickX = parseInt((screen.width-x) * .5);
var tmpClickY = parseInt(scrollY + (screen.height - y) * .30);
hp.style.top = (tmpClickY) + "px";
hp.style.left = (tmpClickX) + "px";
hp.style.display = 'block';
}
function showCustomPopup(hoverPopupID, x, y){
hp = document.getElementById(hoverPopupID);
hp.style.top = y + "px";
hp.style.left = x + "px";
hp.style.display = 'block';
}
function showPopup(hoverPopupID){
hp = document.getElementById(hoverPopupID);
if(clickX==0) clickX = MouseX;
if(clickY==0) clickY = MouseY;
hp.style.top = (clickY - 30) + "px";
hp.style.left = (clickX + 30) + "px";
hp.style.display = 'block';
}
function hidePopup(hoverPopupID){
hp = document.getElementById(hoverPopupID);
hp.style.display = 'none';
}
function setBgDefault(){
if(fdElement != ''){
document.getElementById(fdElement).style.backgroundColor = "#FFFFFF";
fdElement = '';
}
}
function setBgSelected(elementID){
if(fdElement != '') setBgDefault();
document.getElementById(elementID).style.backgroundColor = "#CCCCCC";
fdElement = elementID;
}
function getCkEditorContent(fieldName){
var fieldValue = CKEDITOR.instances[fieldName].getData();
return fieldValue;
}
function getFckEditorContent(fieldName){
var fieldValue = FCKeditorAPI.GetInstance(fieldName).GetXHTML();
return fieldValue;
}
var ajxReq, ajxVarHandleHttpResponse;
var ajxDivID, ajxListName, ajxFrmName, ajxModuleDir;
var globalUrl = "https://app.mylearningjourney.education/honeypots/global";
function DsAjax(){
var ajxUrl, ajxMethod, ajxParams, varHandleHttpResponse, ajxFrmName;
this.initAjaxRequest = function (){
this.ajxUrl = "";
this.ajxMethod = "GET";
this.ajxParams = "";
ajxVarHandleHttpResponse = eval("this.defaultGetResponseData");
if(window.XMLHttpRequest) ajxReq = new XMLHttpRequest();
else if (window.ActiveXObject) ajxReq = new ActiveXObject("Microsoft.XMLHTTP");
else alert("Your browser does not support XmlHttp");
};
this.setAjaxUrl = function (ajxUrl) {this.ajxUrl = ajxUrl;};
this.setAjaxMethod = function (ajxMethod) {this.ajxMethod = ajxMethod;};
this.setAjaxParams = function (ajxParams) {this.ajxParams = ajxParams;};
this.setQueryString = function (queryString) {this.ajxParams = queryString;};
this.setFinalReadyStateFunction = function (varHandleHttpResponse) {ajxVarHandleHttpResponse = eval(varHandleHttpResponse)};
this.setDivID = function (divID) {ajxDivID = divID;};
this.setAjaxParamsByForm = function (frm){
var params = "";
var paramArr = "document." + frm + ".elements";
paramArr = eval(paramArr);
paramArrLen = paramArr.length;
for(var i = 0; i < paramArrLen; i++){
var inputType = paramArr[i].type;
var inputName = paramArr[i].name;
var inputValue;
if(inputType=="checkbox"){
var isChecked = paramArr[i].checked;
if(isChecked==false) continue;
inputValue = paramArr[i].value;
}else if(inputType=="radio"){
var isChecked = paramArr[i].checked;
if(isChecked==false) continue;
inputValue = paramArr[i].value;
}else if(inputType=="select-multiple"){
var options = paramArr[i].options;
var count = options.length;
var inputValue = new Array();
for(var j = 0; j < count; j++){
var element = options[j];
var isSelected = element.selected;
if(isSelected==true){
inputValue.push(element.value);
}
}
}else{
inputValue = paramArr[i].value;
}
inputValue = escape(inputValue);
inputValue = inputValue.replace(/\+/g, "[PLUS]");
inputValue = inputValue.replace(/\µ/g, "[MU]");
params += inputName + "=" + inputValue + "&";
}
this.ajxParams = params;
};
this.sendAjaxRequest = function (){
if(this.ajxUrl==""){
alert("Please set ajax url");
return;
}
ajxReq.open(this.ajxMethod, this.ajxUrl, true);
ajxReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajxReq.onreadystatechange = this.handleHttpResponse;
ajxReq.send(this.ajxParams);
};
this.handleHttpResponse = function (){
if (ajxReq.readyState == 4){
var responseText = ajxReq.responseText;
ajxVarHandleHttpResponse(responseText);
}
};
this.defaultGetResponseData = function (responseText){
var frm = this.ajxFrmName.substring(3);
var divFrmID = "divFrm" + frm;
var actMsgID = "act" + frm + "Msg";
document.getElementById(actMsgID).innerHTML = " ";
if(responseText.match("##success##")=="##success##"){
responseText = responseText.replace(/##success##/, "");
document.getElementById(actMsgID).innerHTML = responseText;
setTimeout("hidePopup('" + divFrmID + "')", 1000);
}else if(responseText.match("##error##")=="##error##"){
responseText = responseText.replace(/##error##/, "");
document.getElementById(actMsgID).innerHTML = responseText;
}else{
//alert(responseText);
}
};
}
function ajaxRequestFrmEdit(frmName, actionUrl){
var dsAjax = new DsAjax();
dsAjax.initAjaxRequest();
dsAjax.setAjaxMethod("POST");
dsAjax.setAjaxUrl(actionUrl);
this.ajxFrmName = frmName;
dsAjax.setAjaxParamsByForm(frmName);
dsAjax.sendAjaxRequest();
var frm = frmName.substring(3);
document.getElementById("act" + frm + "Msg").innerHTML = "Please wait ...";
}
function setCkContentField(fieldName){
ckContentField = fieldName;
}
function ajaxRequestShowForm(frmName, moduleDir, params, popupType, x, y){
if(x==undefined) x = 0;
if(y==undefined) y = 0;
clickX = MouseX;
clickY = MouseY;
var dsAjax = new DsAjax();
dsAjax.initAjaxRequest();
dsAjax.setAjaxMethod("POST");
dsAjax.setAjaxUrl(globalUrl + "/ajax-form.php");
var divID = "div" + frmName;
dsAjax.setDivID(divID);
var ajaxParams = "frmName=" + frmName + "&moduleDir=" + moduleDir;
if(params!='') ajaxParams += "&" + params;
dsAjax.setAjaxParams(ajaxParams);
dsAjax.setFinalReadyStateFunction("ajaxResponseShowForm");
dsAjax.sendAjaxRequest();
hidePopup(ajxDivID);
var tdForm = "td" + frmName;
document.getElementById(tdForm).innerHTML = "Please wait...";
if(popupType=="fixed"){
showFixedPopup(ajxDivID, x, y);
}else if(popupType=="custom"){
showCustomPopup(ajxDivID, x, y);
}else{
showPopup(ajxDivID);
}
}
function ajaxResponseShowForm(responseText){
document.getElementById(ajxDivID).innerHTML = responseText;
if(responseText.match("!--loadCKEditor") == "!--loadCKEditor"){
loadCkEditor(ckContentField);
}else if(responseText.match("!--loadBasicCKEditor") == "!--loadBasicCKEditor"){
loadCkEditorBasic(ckContentField);
}
}
function loadCkEditor(element){
var instance = CKEDITOR.instances[element];
ckContentField=element;
if(instance){
CKEDITOR.remove(instance);
}
try{
CKEDITOR.replace(element,
{
filebrowserBrowseUrl : '../ckfinder/ckfinder.html',
filebrowserImageBrowseUrl : '../ckfinder/ckfinder.html?Type=Images',
filebrowserFlashBrowseUrl : '../ckfinder/ckfinder.html?Type=Flash',
filebrowserUploadUrl : '../ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
filebrowserImageUploadUrl : '../ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
filebrowserFlashUploadUrl : '../ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
});
}
catch(e)
{}
}
function loadCkEditorBasic(element)
{
var instance = CKEDITOR.instances[element];
ckContentField=element;
if(instance){
CKEDITOR.remove(instance);
}
try{
CKEDITOR.replace(element,
{
filebrowserBrowseUrl : '/honeypots/myaccount/ckfinder/ckfinder.html',
filebrowserImageBrowseUrl : '/honeypots/myaccount/ckfinder/ckfinder.html?Type=Images',
filebrowserFlashBrowseUrl : '/honeypots/myaccount/ckfinder/ckfinder.html?Type=Flash',
filebrowserUploadUrl : '/honeypots/myaccount/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
filebrowserImageUploadUrl : '/honeypots/myaccount/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
filebrowserFlashUploadUrl : '/honeypots/myaccount/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
});
}
catch(e)
{}
}
function ajaxRequestShowList(listName, moduleDir, params,divid){
var dsAjax = new DsAjax();
dsAjax.initAjaxRequest();
dsAjax.setAjaxMethod("POST");
dsAjax.setAjaxUrl(globalUrl + "/ajax-list.php");
if(divid) var divID = divid;
else var divID = "div" + listName;
dsAjax.setDivID(divID);
var ajaxParams = "listName=" + listName + "&moduleDir=" + moduleDir;
if(params!='') ajaxParams += "&" + params;
dsAjax.setAjaxParams(ajaxParams);
dsAjax.setFinalReadyStateFunction("ajaxResponseShowList");
dsAjax.sendAjaxRequest();
}
function ajaxResponseShowList(responseText){
hidePopup(ajxDivID);
document.getElementById(ajxDivID).innerHTML = responseText;
showPopup(ajxDivID);
}
function ajaxRequestShowFile(fileName, moduleDir, params){
var dsAjax = new DsAjax();
dsAjax.initAjaxRequest();
dsAjax.setAjaxMethod("POST");
dsAjax.setAjaxUrl(globalUrl + "/ajax-file.php");
var divID = "div" + fileName;
dsAjax.setDivID(divID);
var ajaxParams = "fileName=" + fileName + "&moduleDir=" + moduleDir;
if(params!='') ajaxParams += "&" + params;
dsAjax.setAjaxParams(ajaxParams);
dsAjax.setFinalReadyStateFunction("ajaxResponseShowFile");
dsAjax.sendAjaxRequest();
}
function ajaxResponseShowFile(responseText){
hidePopup(ajxDivID);
document.getElementById(ajxDivID).innerHTML = responseText;
showPopup(ajxDivID);
}
function ajaxRequestShowPopupFile(fileName, moduleDir, params,popupType,x,y){
if(x==undefined) x = 0;
if(y==undefined) y = 0;
clickX = MouseX;
clickY = MouseY;
var dsAjax = new DsAjax();
dsAjax.initAjaxRequest();
dsAjax.setAjaxMethod("POST");
dsAjax.setAjaxUrl(globalUrl + "/ajax-file.php");
var divID = "div" + fileName;
dsAjax.setDivID(divID);
var ajaxParams = "fileName=" + fileName + "&moduleDir=" + moduleDir;
if(params!='') ajaxParams += "&" + params;
dsAjax.setAjaxParams(ajaxParams);
dsAjax.setFinalReadyStateFunction("ajaxResponseShowPopupFile");
dsAjax.sendAjaxRequest();
if(popupType=="fixed"){
showFixedPopup(ajxDivID, x, y);
}else if(popupType=="custom"){
showCustomPopup(ajxDivID, x, y);
}else{
showPopup(ajxDivID);
}
}
function ajaxResponseShowPopupFile(responseText){
document.getElementById(ajxDivID).innerHTML = responseText;
}
function ajaxRequestDelete(deleteUrl, params, listName){
if(confirm("Are you sure to delete?")==false){
return;
}
var dsAjax = new DsAjax();
dsAjax.initAjaxRequest();
dsAjax.setAjaxMethod("POST");
dsAjax.setAjaxUrl(deleteUrl);
dsAjax.setAjaxParams(params);
ajxListName = listName;
dsAjax.setFinalReadyStateFunction("ajaxResponseDelete");
dsAjax.sendAjaxRequest();
var actListMsg = "act" + ajxListName + "Msg";
document.getElementById(actListMsg).innerHTML = "Please wait ...";
}
function ajaxResponseDelete(responseText){
var actListMsg = "act" + ajxListName + "Msg";
var divListID = "div" + ajxListName;
document.getElementById(actListMsg).innerHTML = " ";
if(responseText.match("##success##")=="##success##"){
responseText = responseText.replace(/##success##/, "");
document.getElementById(divListID).innerHTML = responseText;
window.location.href = "#msg";
}else if(responseText.match("##error##")=="##error##"){
responseText = responseText.replace(/##error##/, "");
document.getElementById(actListMsg).innerHTML = responseText;
}else{
alert(responseText);
}
}
function ajaxRequestChangeStatus(changeStatusUrl, params, listName){
if(confirm("Are you sure to change status?")==false){
return;
}
var dsAjax = new DsAjax();
dsAjax.initAjaxRequest();
dsAjax.setAjaxMethod("POST");
dsAjax.setAjaxUrl(changeStatusUrl);
dsAjax.setAjaxParams(params);
ajxListName = listName;
dsAjax.setFinalReadyStateFunction("ajaxResponseChangeStatus");
dsAjax.sendAjaxRequest();
var actListMsg = "act" + ajxListName + "Msg";
document.getElementById(actListMsg).innerHTML = "Please wait ...";
}
function ajaxResponseChangeStatus(responseText){
var actListMsg = "act" + ajxListName + "Msg";
var divListID = "div" + ajxListName;
document.getElementById(actListMsg).innerHTML = " ";
if(responseText.match("##success##")=="##success##"){
responseText = responseText.replace(/##success##/, "");
document.getElementById(divListID).innerHTML = responseText;
window.location.href = "#msg";
}else if(responseText.match("##error##")=="##error##"){
responseText = responseText.replace(/##error##/, "");
document.getElementById(actListMsg).innerHTML = responseText;
}else{
//alert(responseText);
}
}
function search(e,obj){
var valSearch;
var keychar;
var d = document.getElementById(obj.id);
valSearch=d.value;
if (e.keyCode == 13){
document.frmSearch.submit();
}else{}
}
function clearSearch(obj){
obj.value='';
}
function ajaxListingPositionEdit(pkID,event,refName,refTableName,msgID){
charCode = event.keyCode;
if (charCode == 13){
ajaxRequestListingPositionEdit(pkID,refName,refTableName,msgID);
}
}
function ajaxRequestListingPositionEdit(pkID,refName,refTableName,msgID){
var dsAjax = new DsAjax();
dsAjax.initAjaxRequest();
dsAjax.setAjaxMethod("POST");
var actUrl = "https://app.mylearningjourney.education/honeypots/global/ajax-listing-position-edit.php";
dsAjax.setAjaxUrl(actUrl);
var inputID = "listingPosition" + pkID;
if(msgID) inputID = msgID.replace("divListingPositionMsg","listingPosition");
var listingPosition = document.getElementById(inputID).value;
var divMsg = "divListingPositionMsg" + pkID;
if(msgID) divMsg = msgID;
var refFieldName = refName + "ID"
var params = refFieldName + "=" + pkID + "&listingPosition=" + listingPosition + "&tableName=" + refTableName + "&fieldName="+refFieldName + "&msgID=" + msgID;
dsAjax.setAjaxParams(params);
dsAjax.setFinalReadyStateFunction("ajaxResponseListingPositionEdit");
dsAjax.sendAjaxRequest();
document.getElementById(divMsg).innerHTML = "Please wait ...";
}
function ajaxResponseListingPositionEdit(responseText){
var divMsg = responseText.replace(/##success##/, "");
divMsg = divMsg.replace(/##error##/, "");
if(responseText.match("##success##")=="##success##"){
document.getElementById(divMsg).style.display="block";
document.getElementById(divMsg).innerHTML = "Listing Position Updated!";
setTimeout("hideDiv('"+divMsg+"')",2000);
}else{
document.getElementById(divMsg).innerHTML = "Sorry failed!";
}
}
function hideDiv(id){
document.getElementById(id).style.display="none";
}