// JavaScript Document var DEFAULT_ICON_WID = 16; var DEFAULT_ICON_HT = 16; var MAX_ICON_WID = 16; var MAX_ICON_HT = 16; var ICON_PAD = 8; var INVIS_ICON = "/images/invis.gif"; function makeImgTag(src,wid,ht,className,id) { if ( arguments.length < 4 ) className = 'absmiddle'; if ( arguments.length < 5 ) id = ''; var idatt=""; if ( id ) idatt="id=\""+id+"\""; //debug ( "<img "+idatt+" src=\"" + src + "\" width=\"" + wid + "\" height=\"" + ht + "\" class=\""+className+"\" alt=\"\">" ); return "\"\""; } function formatIcon(icon,w,h) { if ( ! icon ) { return makeImgTag( INVIS_ICON, MAX_ICON_WID+ICON_PAD, MAX_ICON_HT ); } else { if ( ! w ) w = DEFAULT_ICON_WID; if ( ! h ) h = DEFAULT_ICON_HT; if ( w > MAX_ICON_WID ) { h = h * MAX_ICON_WID / w; w = MAX_ICON_WID; } if ( h > MAX_ICON_HT ) { w = w * MAX_ICON_HT / h; h = MAX_ICON_HT; } pad = ICON_PAD + MAX_ICON_WID - w; icon_img = makeImgTag( icon, w, h ); pad_img = makeImgTag( INVIS_ICON, pad, MAX_ICON_HT ); return icon_img + pad_img; } } /* function formatAction(action,target) { if ( arguments.length < 2 ) target="_new"; var html = ""; debug("formatAction(match: {"+action.url +"} {"+action.description +"} {"+action.info +"} {"+action.icon +"} {"+action.iconW +"} {"+action.iconH +"})"); html += formatIcon(action.icon,action.iconW,action.iconH); if ( action.url ) { html += "" + action.description + ""; } else { html += action.description; } if ( action.info ) { html += " - " + action.info; } return html; } */ var FormatTypedActions_match_nos = 0; // so that ids unique across calls function FormatTypedActions() { this.target="_new"; this.targetTag=" target=\"_new\""; this.needsusercolour="#666666"; this.needsusertext=""; this.$showNoActionsMatches = false; this.preActionsFmt = ""; this.midActionsFmt = ""; this.postActionsFmt = ""; this.match_id_prefix = "m_"; this.max_title_width = 50; this.typedactions = new Array(); } FormatTypedActions.prototype.setTarget = function(target) { this.target = target; if ( target ) this.targetTag = " target=\"" + target+ "\""; else this.targetTag = ""; } FormatTypedActions.prototype.setActions = function(typedactions) { this.typedactions = typedactions; } /* function addActions($typedactions) { $this->typedactions = array_merge($this->typedactions,$typedactions); } */ FormatTypedActions.prototype.format = function(typedactions) { //debug("format("+typedactions+")"); // global FormatTypedActions_match_nos; if ( arguments.length < 1 ) typedactions = this.typedactions; var formatall = ""; for ( var m=0; m 0 ) { formatall += this.formatMatchWithActions(match_id,type,title,actions); } else { formatall += this.formatNoActions(match_id,type,title); } } return formatall; } FormatTypedActions.prototype.formatNoActions = function(match_id,type,title) { if ( this.showNoActionsMatches ) { return "
" + this.formatMatch(match_id,type,title) + "
\n"; } else { return ""; } } FormatTypedActions.prototype.formatMatchWithActions = function(match_id,type,title,actions) { var formatall = "
" + this.formatMatch(match_id,type,title) + "
\n"; formatall += this.formatActions(match_id,type,title,actions); formatall += "
"; return formatall; } FormatTypedActions.prototype.formatMatch = function(match_id,type,title) { //debug("FormatTypedActions.formatMatch("+match_id+","+type+","+title+")") if ( this.max_title_width > 0 && title.length > this.max_title_width ) { title = title.substr(0,this.max_title_width-3) + "..."; } return htmlentities(title); } FormatTypedActions.prototype.formatActions = function(match_id,type,title,actions) { var formatall = ""; for ( var a=0; a 0 ) formatall += "
\n"; formatall += this.formatOneAction(match_id,type,title,action); } return formatall; } FormatTypedActions.prototype.formatOneAction = function(match_id,type,title,action) { var formatone = action.description; if ( action.url ) { formatone = "" + formatone + ""; } /* if ( $action->needsuser ) { $formatone = "" . $formatone . ""; } */ if ( action.info ) { formatone += " - " + htmlentities(action.info); } var iconTag = formatIcon(action.icon,action.iconW,action.iconH); return iconTag + formatone; } function ShowHideActions() { //this.FormatTypedActions(); this.showNoActionsMatches = false; } ShowHideActions.prototype = new FormatTypedActions(); // sets constructor //ShowHideActions.prototype.parent_format = FormatTypedActions.prototype.format; // parent::format ShowHideActions.prototype.setTarget = function(target) { this.target = target; if ( target ) this.targetTag = " target=\"" + target+ "\""; else this.targetTag = ""; } /* ShowHideActions.prototype.format = function(typedactions) { var formatall = "
"; formatall += this.parent_format(typedactions); formatall += "
"; return formatall; } */ ShowHideActions.prototype.formatMatchWithActions = function(match_id,type,title,actions) { //debug("ShowHideActions.formatMatchWithActions("+match_id+","+type+","+title+")") var linktitle = "show/hide actions"; var anchor = ""; var formatall = "

"; formatall += anchor; formatall += this.formatMatch(match_id,type,title); formatall += " "; formatall += makeImgTag("/images/pull-down-closed.gif",32,8,"absmiddle","imgctrl_"+match_id); formatall += "

\n"; formatall += "

"; formatall += this.formatActions(match_id,type,title,actions); formatall += "

"; return formatall; }