Helmikuu
13
2006

Smarty Miten: Javascript Debug Template

UPDATE: ladattava paketti löytyy täältä: http://ideamesh.com/file/11/Smarty-Debug-with-Collapsible-Variables.html

Tässä on muutettu koodi, työ-ja valmis menemään ..

Tässä on linkki josta voit ladata nanotree javascript ...
http://nanotree.sourceforge.net/~~V

Vaihda my muuttuja {$ Site.framework_pub} asianmukaisesti niin, että javascript ja kuvia voidaan ladata oikein.

Pyydämme myös huomaamaan, olen lisätty osan käsitellä käyttäjän määrittämiä debug vars ... Minun debug rakenne on nimeltään "_user_debug 'ja' _user_debug_key"

Saat lisätietoja siitä, miten tätä katsomaan tätä säiettä:
http://www.smarty.net/forums/viewtopic.php?p=31241 # 31241

Muuten jos et ole kiinnostunut, se on turvallista poistaa kyseisen jakson mallista. Voit myös poistaa {jos} ilmoitus Käytin kääri malliin var osassa.

Toinen asia kannattaa leikkiä, kuinka monta merkkiä ulostulon arvo debug. Etsi tämän ja muuttaa toinen numero muuttaa max merkkiä teho: @ debug_print_var: 0:1000

PS Voisiko joku selvittää, miksi Saan yläpuolella <h3> oikeaan soluun?

Toivottavasti tämä auttaa, tiedän pidän siitä Hymyillä

PS Saadaksesi kaikki javascript toimi oikein sinun tarvitsee vain muuttaa linjan "var mynanopath =" ja varmista, että se viittaa omaan julkisten nanopath hakemistosta. Voit alas nanotree paketin http://sourceforge.net/projects/nanotree/

Tässä on päivitetty koodi

Koodi:
{*
Smarty Custom DHTML Debug malli
@ Author Hielke Hoeve
@ Author Owen Cole <owenc at ideamesh piste com>
@ Vuodesta 13.02.2006 Smarty 2.6.12
@ Paketti Smarty
@ Tiedostonimi 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, skaalautuvia, vierityspalkit = yes");
_smarty_console.document.write ("<html> <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} reunusta: ohut solid black; {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 ("* Tarvitaan alustaa puuhun. \ n");
_smarty_console.document.write ("* Ja soittaa showTree (Vedospolku) todella näyttää puu. \ n");
_smarty_console.document.write ("* Vaihtoehtoisesti tämä voidaan toteuttaa koodilohko alaosassa sivun. \ n");
_smarty_console.document.write ("* Vaikka tämä menetelmä on hieman puhtaampaa. \ n");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("toiminto init () {ldelim} \ n");
_smarty_console.document.write ("kontti = 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 ("* Kutsutaan, kun käyttäjä napsauttaa solmu. \ n");
_smarty_console.document.write ("* @ param treeNode TreeNode kohdetta, joka on napsautetaan. \ n");
_smarty_console.document.write ("* \ / \ n");
_smarty_console.document.write ("toiminto 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 ("toiminto nodeEdited (treeNode) {ldelim} \ n");
_smarty_console.document.write ("{rdelim} \ n");

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

{* Tee pohja solmu *}
{Määrittää var = laskurin arvo = 0}
_smarty_console.document.write ("rootNode = uusi TreeNode ({$ laskuri}, 'Smarty Debug", helpIcon,' Tämä on Debug Tree. Se korvaa perinteisen version Smarty Virheenkorjauskonsoli ') \ n ");
{$ Counter + +}

{* Luo solmu Malli sisältää *}
_smarty_console.document.write ("var node {$ laskuri} = uusi TreeNode ({$ laskuri}, 'sisältyvät mallit ja config-tiedostot (latausajan sekunneissa):", pageIcon, ");
_smarty_console.document.write ("<table width=\"100%\"> ');
{Section name = templates loop = $ _debug_tpls}
_smarty_console.document.write ("<tr bgcolor={if %templates.index% on even}#eeeeee{else}#fafafa{/if}> <td colspan=2> <tt> {section name = luetelmakohdassa loop = $ _debug_tpls [malleja]. syvyys} &&& {/ section} <font color = {if $ _debug_tpls [malleja]. tyyppi eq "malli"} ruskea {elseif $ _debug_tpls [malleja]. tyyppi eq isset ($ _debug_tpls [malleja]. exec_time)} <font size=-1> <i> ({$ _debug_tpls [malleja]. exec_time | string_format: "% .5 f"}) {if% templates.index% eq 0} (yhteensä) {/ if} <\ \ / i> <\ \ / font> {/ if} <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{Sectionelse}
_smarty_console.document.write ("<tr bgcolor=#eeeeee> <td colspan=2> <tt> <i> malleja ei sisälly <\ \ / i> <\ \ / tt> <\ \ / td> <\ \ / tr> ");
{/ Section}
_smarty_console.document.write ("<\ \ / table> ');
_smarty_console.document.write ("'); \ n");

_smarty_console.document.write ("rootNode.addChild (node ​​{$ laskuri}) \ n");
{$ Counter + +}

{* Luo solmu käyttäjän debug muuttujien *}
_smarty_console.document.write ("var node {$ laskuri} = uusi TreeNode ({$ laskuri}," käyttäjä debug muuttujat: ", new Array (closedGif, openGif)), \ n");
_smarty_console.document.write ("rootNode.addChild (node ​​{$ laskuri}) \ n");
_smarty_console.document.write ("var vanhempi = solmu {$ counter}, \ n");
{$ Counter + +}

{* Luo lapsen solmut käyttäjälle debug muuttujien *}
{Section name = vars loop = $ _user_debug}
_smarty_console.document.write ("var node {$ laskuri} = uusi TreeNode ({$ laskuri}, {ldelim} $ {$ _user_debug_key [VARS]} {rdelim} ', pageIcon,' {$ _user_debug [VARS] | @ debug_print_var: 0:1000 | esc: javascript | esc: javascript} ') \ n ");
_smarty_console.document.write ("parent.addChild (node ​​{$ laskuri}) \ n");
{$ Counter + +}
{Sectionelse}
_smarty_console.document.write ("var node {$ laskuri} = uusi TreeNode ({$ laskuri}," Ei käyttäjän virheenetsintätiedot määritetty ", HelpIcon) \ n");
_smarty_console.document.write ("parent.addChild (node ​​{$ laskuri}) \ n");
{$ Counter + +}
{/ Section}

{* Luo solmu mallin muuttujien *}
_smarty_console.document.write ("var node {$ laskuri} = uusi TreeNode ({$ laskuri}," osoitetaan mallin muuttujat ", new Array (closedGif, openGif)), \ n");
_smarty_console.document.write ("rootNode.addChild (node ​​{$ laskuri}) \ n");
_smarty_console.document.write ("var vanhempi = solmu {$ counter}, \ n");
{$ Counter + +}

{* Luo lapsen solmut mallin muuttujien *}
{Section name = vars loop = $ _debug_keys}
{If $ _debug_keys [VARS]! = '_user_debug' && $ _debug_keys [VARS]! = '_user_debug_key'}
_smarty_console.document.write ("var node {$ laskuri} = uusi TreeNode ({$ laskuri}, {ldelim} $ {$ _debug_keys [VARS]} {rdelim} ', pageIcon,' {$ _debug_vals [VARS] | @ debug_print_var: 0:1000 | esc: javascript | esc: javascript} ') \ n ");
_smarty_console.document.write ("parent.addChild (node ​​{$ laskuri}) \ n");
{$ Counter + +}
{/ Jos}
{Sectionelse}
_smarty_console.document.write ("var node {$ laskuri} = uusi TreeNode ({$ laskuri}, 'No mallin muuttujat määritetty", HelpIcon) \ n ");
_smarty_console.document.write ("parent.addChild (node ​​{$ laskuri}) \ n");
{$ Counter + +}
{/ Section}

{* Luo solmu smarty config tiedoston muuttujat *}
_smarty_console.document.write ("var node {$ laskuri} = uusi TreeNode ({$ laskuri}," annetaan config tiedosto muuttujat (ulompi malli soveltamisala): ", new Array (closedGif, openGif)), \ n");
_smarty_console.document.write ("rootNode.addChild (node ​​{$ laskuri}) \ n");
_smarty_console.document.write ("var vanhempi = solmu {$ counter}, \ n");
{$ Counter + +}

{* Luo lapsen solmut smarty config tiedoston muuttujat *}
{Section name = config_vars loop = $ _debug_config_keys}
_smarty_console.document.write ("var node {$ laskuri} = uusi TreeNode ({$ laskuri}, {ldelim} $ {$ _debug_config_keys [config_vars]} {rdelim} ', pageIcon,' {$ _debug_config_vals [config_vars] | @ debug_print_var: 0:1000 | esc: javascript | esc: javascript} ') \ n ");
_smarty_console.document.write ("parent.addChild (node ​​{$ laskuri}) \ n");
{$ Counter + +}
{Sectionelse}
_smarty_console.document.write ("var node {$ laskuri} = uusi TreeNode ({$ laskuri}, 'Ei config muuttujat määritetty", HelpIcon) \ n ");
_smarty_console.document.write ("parent.addChild (node ​​{$ laskuri}) \ n");
{$ Counter + +}
{/ 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 Virheenkorjauskonsoli <\ / h3>");
_smarty_console.document.write ("<h4> Klikkaa muuttujia puu on niiden sisältö näytetään oikeassa sivupaneelissa. <\ / 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: -
lähetetty oppaat , ohjelmointi Owen

Seuraa kommentteja kautta RSS Feed | Jätä kommentti | Trackback URL

Jätä kommentti

 
© 2008 - 2012 - Kaikki oikeudet pidätetään - Ideamesh, Inc. 22 kyselyitä. 0,779 sekuntia.