84 lines
2.0 KiB
JavaScript
Executable File
84 lines
2.0 KiB
JavaScript
Executable File
var dataTools=new dataTools();
|
|
|
|
// Add an extends - function to the objects
|
|
// so that we have proper inheritance
|
|
Object.prototype.extends = function (oSuper) {
|
|
for (sProperty in oSuper) {
|
|
this[sProperty] = oSuper[sProperty];
|
|
}
|
|
}
|
|
|
|
function dataTools(){
|
|
var m_pkey=0;
|
|
this.getNewPKey=getNewPKey;
|
|
this.setPKey=setPKey;
|
|
this.urlArgs=new urlArgs();
|
|
this.getCookie=getCookie;
|
|
this.setCookie=setCookie;
|
|
this.imageDom=imageDom;
|
|
function getNewPKey(){
|
|
return(m_pkey++);
|
|
}
|
|
function setPKey(inPKey){
|
|
m_pkey=inPKey;
|
|
}
|
|
|
|
function urlArgs(){
|
|
var m_allPairs=window.location.search.substring(1).split("&");
|
|
this.getValueByKey=getValueByKey;
|
|
function getValueByKey(key){
|
|
for (var i=0;i<m_allPairs.length;i++){
|
|
var theKey,theValue;
|
|
theKey=m_allPairs[i].split("=")[0];
|
|
theValue=m_allPairs[i].split("=")[1];
|
|
if (key==theKey) {
|
|
return(theValue);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// setCookie and getCookie copied from w3schools
|
|
function setCookie(c_name,value,expiredays)
|
|
{
|
|
var exdate=new Date();
|
|
exdate.setDate(exdate.getDate()+expiredays);
|
|
document.cookie=c_name+ "=" +escape(value)+
|
|
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
|
|
}
|
|
|
|
function getCookie(c_name)
|
|
{
|
|
if (document.cookie.length>0)
|
|
{
|
|
c_start=document.cookie.indexOf(c_name + "=");
|
|
if (c_start!=-1)
|
|
{
|
|
c_start=c_start + c_name.length+1;
|
|
c_end=document.cookie.indexOf(";",c_start);
|
|
if (c_end==-1) c_end=document.cookie.length;
|
|
return unescape(document.cookie.substring(c_start,c_end));
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
function imageDom(imgFile,altText,titleText){
|
|
var imgNode=document.createElement("img");
|
|
imgNode.setAttribute("src",imgFile);
|
|
imgNode.setAttribute("alt",altText);
|
|
imgNode.setAttribute("title",titleText);
|
|
return(imgNode);
|
|
}
|
|
}
|
|
|
|
// Subscription-service for Document-Click
|
|
document.extends(new Publisher);
|
|
document.onclick=onDocumentClick;
|
|
|
|
function onDocumentClick(event){
|
|
if ("HTML"==event.target.nodeName) {
|
|
document.notifySubscribers(document,"clicked",null)
|
|
}
|
|
}
|