All pastes #192107 Raw Edit

Someone

public javascript v1 · immutable
·published 2006-10-05 17:53 UTC
rendered paste body
    var IE = (navigator.appName == "Microsoft Internet Explorer");    var scrollObj = null;		var scrollObjInfo = null;		var NOSCROLL = -1;		var scrollId = NOSCROLL;		var scrollDelta = 0;		var scrollDelay = 20;		var scrollMin = 1;		var scrollMax = 5;		var parabollicFactor = 2;		var topBarPercent = 0.33;		var botBarPercent = 0.67;				var idEvent;		var event_tmp = [], onevent=null;		//scroller		function scroll_handle(e)		{			var y, topbar, botbar, shouldScroll = true;						e = e || event;			y = e.clientY - scrollObjInfo.y; //e.layerY || e.offsetY;			//y -= scrollObj.scrollTop;						status = y;					topbar = scrollObj.clientHeight * topBarPercent;			botbar = scrollObj.clientHeight * botBarPercent;						if (y > 0 && y < topbar && scrollObj.scrollTop > 0)				scrollDelta = -Math.floor(Math.pow((topbar - y) / topbar, parabollicFactor) * (scrollMax - scrollMin)) - scrollMin;			else if (y > botbar && y < scrollObj.clientHeight && scrollObj.scrollTop < scrollObj.scrollHeight)				scrollDelta = Math.floor(Math.pow((y - botbar) / topbar, parabollicFactor) * (scrollMax - scrollMin)) + scrollMin;			else {				scroll_stop();				shouldScroll = false;			}						if (shouldScroll && scrollId == NOSCROLL)				scrollId = setInterval(scroll_int, scrollDelay);		}				function scroll_stop()		{			clearInterval(scrollId);			scrollId = NOSCROLL;		}		function scroll_int()		{			var scrollTop = scrollObj.scrollTop + scrollDelta;						scrollTop = Math.min(scrollObj.scrollHeight, scrollTop);			scrollTop = Math.max(0, scrollTop);			scrollObj.scrollTop = scrollTop;						if ( scrollTop == 0 || scrollTop == scrollObj.scrollHeight )				scroll_stop();		}				function getNodeInfo(node)		{			var xPos = 0, yPos = 0, width = 0, height = 0, srcNode = node;			while ( (IE) ? node : (typeof node.tagName != "undefined") )			{				if (node.tagName != "TR")				{					xPos += node.offsetLeft;					yPos += node.offsetTop;				}				node = (IE) ? node.parentElement: node.parentNode;			}			if (typeof srcNode.offsetWidth != "undefined")			{				width = srcNode.offsetWidth;				height = srcNode.offsetHeight;			} else if (typeof srcNode.width != "undefined") {				width = srcNode.width;				height = srcNode.height;			}			return(				{ x : xPos , y : yPos , w : width , h : height }			);		}		// event handlingfunction EventClass(id_event, id_title, event_text, index){	this.idEvent = id_event;	this.name = id_title;	this.index = index;	this.cEvent = event_text;	this.node = null;	this.generateHTML = event_HTML;}function event_HTML(){	var parent = document.getElementById("events_list");	var d_row = document.createElement("DIV");	var p_text = document.createElement("P");		if ( this.index % 2 == 0 )	{		d_row.setAttribute("row_count", "1");		d_row.className = "event row_1";	} else {		d_row.setAttribute("row_count", "2");		d_row.className = "event row_2";	}		d_row.setAttribute("id", "event_"+ this.idEvent);	d_row.setAttribute("title", this.name);	d_row.onmouseover = over_event;	d_row.onmouseout = off_event;	d_row.onclick = click_event;		p_text.appendChild( document.createTextNode(this.index + 1 +".  "+ this.name) );	p_text.setAttribute("title", this.name);	d_row.appendChild( p_text );		parent.appendChild( d_row );		this.node = document.getElementById("event_"+ this.idEvent);}function over_event(){	// mouse rolls over div.event		var id = this.getAttribute("id").replace("event_", "");		this.className = "event_hover";}function off_event(){	// mouse rolls off div.event		var id = this.getAttribute("id").replace("event_", "");	this.className = "event row_"+ this.getAttribute("row_count");}function click_event(){	var id = this.getAttribute("id").replace("event_", "");	var i, len = event_tmp.length;		for (i = 0; i < len; i++)	{		if ( event_tmp[i].idEvent == id )		{			alert(event_tmp[i].cEvent)			break;		}	}}function add_event(id_event, id_title, event_text){	var i, len = event_tmp.length;		event_tmp.push( new EventClass(id_event, id_title, event_text, len) );	event_tmp[len].generateHTML();	scrollMax = (event_tmp.length > 30) ? 12 : 6;}