Februari
13
2006

Smarty Hoe: Javascript Debug Template

UPDATE: Een download pakket is hier beschikbaar: http://ideamesh.com/file/11/Smarty-Debug-with-Collapsible-Variables.html

Hier is de aangepaste code, werk-en klaar om te gaan ..

Hier is de link waar u kunt downloaden van de nanotree javascript ...
http://nanotree.sourceforge.net/~~V

Vervang mijn variabele {$ Site.framework_pub} behoren, zodat de javascript en afbeeldingen correct kan worden geladen.

Ook let, heb ik toegevoegd in een sectie om door de gebruiker gedefinieerde debug vars gaan ... Mijn debug-structuur is de naam '_user_debug' en '_user_debug_key'

Voor meer informatie over hoe u deze blik op deze draad te voeren:
http://www.smarty.net/forums/viewtopic.php?p=31241 # 31241

Anders als je niet geïnteresseerd bent, is het veilig om dat gedeelte te verwijderen van de sjabloon. Je zou ook kunnen verwijderen {if} uitspraak die ik gebruikt om de template var sectie wikkelen.

Een ander ding dat je zou willen spelen is hoeveel tekens worden uitgevoerd als de waarde voor debug. Kijk voor deze en het tweede nummer aan de max. tekens uitgang te veranderen te wijzigen: @ debug_print_var: 0:1000

PS Kan iemand erachter te komen waarom ik het krijgen van een ruimte boven de <h3> in de juiste cel?

Hoop dat dit helpt, ik weet dat ik leuk vinden Lachen

PS Om alle javascript goed werkt hoef je alleen maar om de lijn te wijzigen "var mynanopath =" en zorg ervoor dat het verwijst naar uw openbare nanopath directory te maken. U kunt naar beneden de nanotree pakket van http://sourceforge.net/projects/nanotree/

Hier is de bijgewerkte code

Code:
{*
Smarty Custom DHTML Debug sjabloon
@ Auteur Hielke Hoeve
@ Auteur Owen Cole <owenc op ideamesh dot com>
@ Sinds 02/13/2006 Smarty 2.6.12
@ Pakket Smarty
@ Bestandsnaam debug.tpl
*}

{Assign_debug_info}

<SCRIPT LANGUAGE="JavaScript">
var mynanopath = "{$ Site.javascript_path} \ / nanotree \ /";

if (self.name == ") {ldelim}
var title = 'Console';
{Rdelim}
else {} ldelim
var title = 'Console_' + self.name;
{Rdelim}
_smarty_console = window.open ("", title.value, "width = 800, height = 600, resizable, scrollbars = yes");
_smarty_console.document.write ("<head> <title> Smarty Debug Console_" + self.name + "<\ / title> \ n");
_smarty_console.document.write ("<style> \ n");
_smarty_console.document.write ("h3 {} ldelim padding: 5px 5px 5px 5px; margin: 0px 0px 0px 0px; background-color: # cccccc; {rdelim} \ n");
_smarty_console.document.write ("# debugtreetable {ldelim} width: 100%;} {rdelim \ n");
_smarty_console.document.write ("# debugtreetable td {} ldelim rand: dunne vaste zwart; {rdelim} \ n");
_smarty_console.document.write ("# debugtreetextdiv div {} ldelim padding-left: 10px;} {rdelim \ n");
_smarty_console.document.write ('<\ / style> \ n ");
_smarty_console.document.write ("<script language=\"Javascript\" src=\"" + mynanopath + "nanotree.js\"> <\ / script> \ n");
_smarty_console.document.write ("<script type=\"text\/javascript\" language=\"JavaScript\"> \ n");
_smarty_console.document.write ("<- \ n");
_smarty_console.document.write ("showRootNode = true; \ n");
_smarty_console.document.write ("sortNodes = 0; \ n");
_smarty_console.document.write ("dragable = false; \ n");
_smarty_console.document.write ("showAllNodesOnStartup = true; \ n");

_smarty_console.document.write ("\ / ** \ n");
_smarty_console.document.write ("* Nodig om de boom te initialiseren \ n.");
_smarty_console.document.write ("* En tot showTree (ImagePath) noemen;. om daadwerkelijk te tonen de boom \ n");
_smarty_console.document.write ("* alternatief kan gebeuren in een scriptblok onderaan de pagina \ n.")
_smarty_console.document.write ("* Hoewel deze methode enigszins schoner \ n.")
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("functie init () {ldelim} \ n");
_smarty_console.document.write ("container = document.getElementById ('debugtreediv'); \ n");
_smarty_console.document.write ("showTree (" + + mynanopath "'), \ n");
_smarty_console.document.write ("{rdelim} \ n");

_smarty_console.document.write ("\ / ** \ n");
_smarty_console.document.write ("* Wordt opgeroepen wanneer een gebruiker klikt op een node \ n.");
_smarty_console.document.write ("* @ param TreeNode de TreeNode object die zijn geklikt \ n.");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("functie standardClick (TreeNode) {ldelim} \ n");
_smarty_console.document.write ("var mytext = document.getElementById ('debugtreetextdiv'); \ n");
_smarty_console.document.write ("var param = treeNode.getParam (); \ n");
_smarty_console.document.write ("mytext.innerHTML = (param ==") treeNode.getName ():? '<h3>' + treeNode.getName () + '<\ / h3> <div>' + param + ' <\ / div> '; \ n ");
_smarty_console.document.write ("{rdelim} \ n");

_smarty_console.document.write ("functie nodeEdited (TreeNode) {ldelim} \ n");
_smarty_console.document.write ("{rdelim} \ n");

_smarty_console.document.write ("var closedGif = '" + mynanopath + "images \ / folder_closed.gif', \ n");
_smarty_console.document.write ("var openGif = '" + mynanopath + "images \ / folder_open.gif', \ n");
_smarty_console.document.write ("var pageIcon = '" + mynanopath + "images \ / page16 × 16.gif", \ n ");
_smarty_console.document.write ("var onbekend = '" + mynanopath + "images \ / user_16 × 16.gif", \ n ");
_smarty_console.document.write ("var helpIcon = '" + mynanopath + "images \ / help_16 × 16.gif", \ n ");

{* Maak basis knooppunt *}
{Var toewijzen = teller = 0}
_smarty_console.document.write ("rootNode = new TreeNode ({$ teller}, 'Smarty Debug', helpIcon, 'Dit is het Debug Tree Het vervangt de klassieke versie van de Smarty Debug Console.'); \ n");
{$ Teller + +}

{* Maak knooppunt voor sjabloon bevat *}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, 'opgenomen templates en configuratie bestanden (de laadtijd in seconden):", pageIcon, "");
_smarty_console.document.write ("<table width=\"100%\">");
{Sectie name = sjablonen loop = $ _debug_tpls}
_smarty_console.document.write ("<tr bgcolor={if %templates.index% is even}#eeeeee{else}#fafafa{/if}> <td colspan=2> <tt> {sectie name = streepje loop = $ _debug_tpls [templates]. diepte} &&& {/ section} <font color = {if $ _debug_tpls [templates]. het type eq "template"} {if $ bruine _debug_tpls [templates]. type EQ isset ($ _debug_tpls [templates] exec_time.)} <font size=-1> <i> ({$ _debug_tpls [templates] exec_time | string_format:. "% f 0.5"}) {if% templates.index% eq 0} (totaal) {/ if} <\ \ / i> <\ \ / font> {/ if} <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{Sectionelse}
_smarty_console.document.write ("<tr bgcolor=#eeeeee> <td colspan=2> <tt> <i> geen sjablonen meegeleverd <\ \ / i> <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{/ Section}
_smarty_console.document.write ('<\ \ / table> ");
_smarty_console.document.write ("), \ n");

_smarty_console.document.write ("rootNode.addChild (node ​​{$ teller}), \ n");
{$ Teller + +}

{* Maak knooppunt voor de gebruiker debug variabelen *}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, 'user debug variabelen:", new Array (closedGif, openGif)); \ n ");
_smarty_console.document.write ("rootNode.addChild (node ​​{$ teller}), \ n");
_smarty_console.document.write ("var parent = knooppunt {$ teller}; \ n");
{$ Teller + +}

{* Maak onderliggende knooppunten voor de gebruiker debug variabelen *}
{Sectie name = vars loop = $ _user_debug}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, '{ldelim} $ {$ _user_debug_key [Vars]} {rdelim}', pageIcon, '{$ _user_debug [Vars] | @ debug_print_var: 0:1000 | escape: javascript | escape: javascript} '); \ n ");
_smarty_console.document.write ("parent.addChild (node ​​{$ teller}), \ n");
{$ Teller + +}
{Sectionelse}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, 'No User Debug Informatie toegewezen', HelpIcon); \ n");
_smarty_console.document.write ("parent.addChild (node ​​{$ teller}), \ n");
{$ Teller + +}
{/ Section}

{* Maak knooppunt voor template variabelen *}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, 'template toegewezen variabelen:", new Array (closedGif, openGif)); \ n ");
_smarty_console.document.write ("rootNode.addChild (node ​​{$ teller}), \ n");
_smarty_console.document.write ("var parent = knooppunt {$ teller}; \ n");
{$ Teller + +}

{* Maak onderliggende knooppunten voor de template variabelen *}
{Sectie name = vars loop = $ _debug_keys}
{If $ _debug_keys [Vars]! = '_user_debug' && $ _debug_keys [Vars]! = '_user_debug_key'}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, '{ldelim} $ {$ _debug_keys [Vars]} {rdelim}', pageIcon, '{$ _debug_vals [Vars] | @ debug_print_var: 0:1000 | escape: javascript | escape: javascript} '); \ n ");
_smarty_console.document.write ("parent.addChild (node ​​{$ teller}), \ n");
{$ Teller + +}
{/ If}
{Sectionelse}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, 'No template variabelen toegewezen', HelpIcon); \ n");
_smarty_console.document.write ("parent.addChild (node ​​{$ teller}), \ n");
{$ Teller + +}
{/ Section}

{* Maak knooppunt voor smarty config file variabelen *}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, 'toegewezen configuratiebestand variabelen (buitenste template scope):", new Array (closedGif, openGif)); \ n ");
_smarty_console.document.write ("rootNode.addChild (node ​​{$ teller}), \ n");
_smarty_console.document.write ("var parent = knooppunt {$ teller}; \ n");
{$ Teller + +}

{* Maak onderliggende knooppunten voor smarty config file variabelen *}
{Sectie name = config_vars loop = $ _debug_config_keys}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, '{ldelim} $ {$ _debug_config_keys [config_vars]} {rdelim}', pageIcon, '{$ _debug_config_vals [config_vars] | @ debug_print_var: 0:1000 | escape: javascript | escape: javascript} '); \ n ");
_smarty_console.document.write ("parent.addChild (node ​​{$ teller}), \ n");
{$ Teller + +}
{Sectionelse}
_smarty_console.document.write ("var knooppunt {$ teller} = new TreeNode ({$ teller}, 'No config variabelen toegewezen', HelpIcon); \ n");
_smarty_console.document.write ("parent.addChild (node ​​{$ teller}), \ n");
{$ Teller + +}
{/ Section}

_smarty_console.document.write ("\ / \ / -> \ n");
_smarty_console.document.write ('<\ / script> \ n \ n ");
_smarty_console.document.write ('<\ / head> <body onload=\"init()\"> \ n ");
_smarty_console.document.write ("<h3> Smarty & User Debug Console <\ / h3>");
_smarty_console.document.write ("<h4> Klik op variabelen in de boom om de inhoud weergegeven in het rechter zijpaneel hebben <\ / h4>.");
_smarty_console.document.write ("<table border='0' id='debugtreetable'> <tr>");
_smarty_console.document.write ("<td valign='top' style='width: 250px;'> <div id='debugtreediv'> & <\ / div> <\ / td>");
_smarty_console.document.write ("<td valign='top'> <div id='debugtreetextdiv'> & <\ / td>");
_smarty_console.document.write ('<\ / tr> <\ / table> ");
_smarty_console.document.write ('<\ / body> <\ / html> ");
_smarty_console.document.close ();
</ SCRIPT>

tags: ,
geplaatst in de Gidsen , programmeren door Owen

Volg reacties via de RSS Feed | Plaats een reactie | Trackback URL

Laat een reactie achter

 
© 2008 - 2012 - All Rights Reserved - Ideamesh, Inc 22 queries. 0,614 seconde.