PHP Classes

File: displayer.js

Recommend this page to a friend!
  Classes of Patricio Cardó   Selector and Validator for XHTML parts   displayer.js   Download  
File: displayer.js
Role: Auxiliary data
Content type: text/plain
Description: Reference functions
Class: Selector and Validator for XHTML parts
Parse HTML to validate it and extract parts
Author: By
Last change:
Date: 12 years ago
Size: 3,315 bytes
 

Contents

Class file image Download
function compareNames(a, b) { var nameA = a.func.toLowerCase( ); var nameB = b.func.toLowerCase( ); if (nameA < nameB) {return -1} if (nameA > nameB) {return 1} return 0; } function ref_valida(fr){ fr.func = (fr.func)?fr.func:"no-name"; fr.descript = (fr.descript)?fr.descript:""; fr.usage = (fr.usage)?fr.usage:""; if(fr.parameters){ for(p=0;p<fr.parameters.length;p++){ fr.parameters[p].param = (fr.parameters[p].param)?fr.parameters[p].param:""; fr.parameters[p].desc = (fr.parameters[p].desc)?fr.parameters[p].desc:""; } }else{ fr.parameters = []; } fr.returned = (fr.returned)?fr.returned:""; if(fr.examples){ for(p=0;p<fr.examples.length;p++){ fr.examples[p].subt = (fr.examples[p].subt)?fr.examples[p].subt:""; fr.examples[p].code = (fr.examples[p].code)?fr.examples[p].code:""; } }else{ fr.examples = []; } return fr; } function show_ref(fr,ret){ ref = ref.sort(compareNames); if(isNaN(fr)){ found = false for(i=0;i<ref.length;i++){ if(ref[i].func==fr){ found = true; fr = ref[i]; break; } } }else{ fr = ref[fr]; found = true; } if(!found){ cont = "Function "+fr+" not found"; }else{ fr = ref_valida(fr); divo = document.getElementById('content'); cont = "<h1>"+fr.func+"</h1>"+ "\n<h2>Description</h2>"+ "\n<p class='normal'>"+fr.descript+"</p>"+ "\n<h2>Usage</h2>"+ "\n<p class='normal'>"+fr.usage+"</p>"+ "\n<h2>Parameters</h2>"; for(ii=0;ii<fr.parameters.length;ii++){ cont += "\n<p class='param'>"+fr.parameters[ii].param+"</p>"+ "\n<p class='param_desc'>"+fr.parameters[ii].desc+"</p>"; } cont += "\n<h2>Return values</h2>"+ "\n<p class='normal'>"+fr.returned+"</p>"+ "\n<h2>Examples</h2>"; for(ii=0;ii<fr.examples.length;ii++){ cont += "\n<h3>"+fr.examples[ii].subt+"</h3>"+ "\n<code>"+fr.examples[ii].code+"</code>"; } } if(ret){ return cont; }else{ divo.innerHTML = cont; return true; } } function show_all(ref){ document.sf.sinp.value = ""; divo = document.getElementById('content'); cont = ""; for(i=0;i<ref.length;i++){ cont += show_ref(i,true); } divo.innerHTML = cont; } function list_menu(ref){ tdm = document.getElementById('men'); cont = "<div style='margin-bottom:2px'><a href='#' onclick='show_all(ref)'><div class='menu'>Show all</div></a></div>"; ref = ref.sort(compareNames); for(a=0;a<ref.length;a++){ fr = ref_valida(ref[a]); cont += "<div style='margin-bottom:2px'><a href='#' onclick='show_ref("+a+",false)'>"+ "<div class='menu'>"+fr.func+"</div></a></div>" } tdm.innerHTML = cont; } function buscar(val, ref){ if(val){ rv = new RegExp(val, "gi"); nref = []; for(i=0;i<ref.length;i++){ pt = 0; fr = ref_valida(ref[i]); exam = ""; for(e=0;e<fr.examples.length;e++){ exam += fr.examples[e].subt + " ; " } if(fr.func.match(rv) || fr.descript.match(rv) || fr.usage.match(rv) || fr.returned.match(rv) || exam.match(rv)){ nref[nref.length] = {func:fr.func, descript:fr.descript, usage: fr.usage, parameters: fr.parameters, returned: fr.returned, examples: fr.examples} } } list_menu(nref); }else{ list_menu(ref); } }