[opencms-dev] javascript

Christoph Kukulies kuku at physik.rwth-aachen.de
Wed Mar 8 17:05:37 CET 2006


In my page (offline) I see a section of javascrip code injected
which appears twice in the page source.

What portion or statement is responsible for this javascript
insertion?

It is the following piece of code:
<script type="text/javascript">
<!--
window.onresize = showButtonsOcms;
document.onkeyup = keyUpOcms;

var deButtonsOcms = new Array();
var ocms_btTimeout;
var visibleOcmsButtons = true;

function activateOcms(id) {
	var el = document.getElementById(id);
	if (el.className == "ocms_de_norm") {
		el.className = "ocms_de_over";
	}
	var bt = document.getElementById("bt_" + id);
	if (bt != null) {
		bt.style.backgroundImage = "url(/resources/buttons/directedit_op.png)";
	}

}
function deactivateOcms(id) {
	var el = document.getElementById(id);
	if (el.className == "ocms_de_over") {
		el.className = "ocms_de_norm";
	}
	var bt = document.getElementById("bt_" + id);
	if (bt != null) {
		bt.style.backgroundImage = "url(/resources/buttons/directedit_cl.png)";
	}
}
function submitOcms(id, action, link) {
	var form = document.getElementById("form_" + id);
	if (form != null) {
		if (action == "edit") {
			form.submit();
			return;
		} else if (action == "delete") {
			form.action = "/system/workplace/commons/delete.jsp";
			form.closelink.value = "/de/testindex.html";			
			form.submit();
			return;
		} else if (action == "new") {	
			form.editortitle.value = "Editing (new resource)";	
			form.newlink.value = link;	
			form.submit();
			return;
		}
	}
	alert("Unknown form action [" + id + "/" + action + "]");
}
function registerButtonOcms(id) {
	deButtonsOcms[deButtonsOcms.length] = id; 
	clearTimeout(ocms_btTimeout);
	ocms_btTimeout = setTimeout("showButtonsOcms()", 400);
}
function showButtonsOcms() {	
		
	var visStyle = "visible";
	if (!visibleOcmsButtons) {
		visStyle = "hidden";
	}
		
	for (var i = 0; i<deButtonsOcms.length; i++) {
		var btid = deButtonsOcms[i];
		var deDiv = document.getElementById(btid);
		var deButton = document.getElementById("buttons_" + btid);
		var deTable = document.getElementById("table_" + btid);
		var x = findPosXOcms(deDiv);
		var y = findPosYOcms(deDiv);
		var w1 = deDiv.offsetWidth; // width of surrounding div
		var w2 = deTable.offsetWidth; // width of button table
		
		x += (w1 - w2);		
		deButton.style.left = x + "px";
		deButton.style.top =  y + "px";				
		deButton.style.visibility = visStyle;
	}
}
function findPosXOcms(obj) {
    var curleft = 0; 
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curleft += obj.offsetLeft - obj.scrollLeft; 
            obj = obj.offsetParent; 
        } 
    } else if (obj.x) {
        curleft += obj.x; 
    }
    return curleft; 
}
function findPosYOcms(obj) {
    var curtop = 0; 
    if (obj.offsetParent) {
        while (obj.offsetParent) { 
            curtop += obj.offsetTop - obj.scrollTop; 
            obj = obj.offsetParent; 
        }
    } else if (obj.y) {
        curtop += obj.y;
    }
    return curtop;
}
function toggleVisibleOcms() {
	if (visibleOcmsButtons) {
		visibleOcmsButtons = false;
	} else {
		visibleOcmsButtons = true;
	}
	showButtonsOcms();
}
function keyUpOcms(evt) {
	if (!evt) {
		evt = window.event;
	}
	if ((evt.type == "keyup") && (evt.keyCode == 32) && evt.ctrlKey) {
		toggleVisibleOcms();
	}
}
//-->
</script>


--
Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de



More information about the opencms-dev mailing list