note 86436 added to book.dom
| From: | cgorbitspamless_atyadotru at osu1 dot php dot net | Date: | Sat, 18 Oct 2008 17:39:22 +0000 |
| Subject: | note 86436 added to book.dom | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-145477@lists.php.net to get a copy of this message | ||
Show expandable DOM like in Firebug.
http://cgorbit.itkm.ru/temp/phpdotnet/common.js
needed for script, sorry, but it's my framework.
<?php
function gaie( $node, &$arr, $attr )
{
if ( $value = $node->getAttribute( $attr ) )
$arr[ $attr ] = u2w( $value );
}
function innerXML( $l, $collapse_all = true, $top_run = true )
{
$atts4elements = array(
'a' => 'href',
'table' => 'border,cellpadding,cellspacing',
'td' => 'colspan,rowspan'
);
$s = '';
if ( $top_run ) :
ob_start();
?><html>
<head>
<meta http-uquiv="Content-type" content="text/html; charset=windows-1251"
/>
<script type="text/javascript" src="/common.js"></script>
</head>
<body>
<style type="text/css">
body {
}
.root-inner-xml-list {
list-style-type: none;
font-size: 1em;
font-family: monospace;
}
.root-inner-xml-list ul {
list-style-type: none;
}
.root-inner-xml-list li.text-node span.value {
color: black;
font-weight: bold;
background-color: lightgrey;
margin-right: 1em;
padding: 0em 0.2em;
}
.root-inner-xml-list li.text-node span.hex {
color: gray;
font-style: italic;
}
.root-inner-xml-list li.element-node {
color: blue;
}
.root-inner-xml-list .attribute-name {
color: green;
}
.root-inner-xml-list .attribute-value {
color: red;
color: rgb( 205, 0, 0 );
}
.root-inner-xml-list .node-with-childs {
cursor: pointer;
//cursor: hand;
}
.root-inner-xml-list .collapsed-node {
background-color: yellow;
}
.root-inner-xml-list .collapsed-node + ul {
display: none;
}
</style>
<ul class="root-inner-xml-list">
<?
$s .= ob_get_clean();
endif;
//if ( $top_run ) $l = $l->childNodes;
foreach ( $l as $i => $node )
{
if ( $node->nodeType == XML_ELEMENT_NODE )
{
$atts = array();
$atts2get = array( 'id', 'class', 'style' );
if ( @$atts4elements[ $node->tagName ] )
$atts2get = array_merge( $atts2get, explode( ',', $atts4elements[ $node->tagName ]
) );
foreach ( $atts2get as $att2get )
gaie( $node, $atts, $att2get );
$attr_arr = array();
foreach ( $atts as $name => $value )
$attr_arr[] = sprintf( '<span
class="attribute-name">%s</span>="<span
class="attribute-value">%s</span>"', $name, $value );
$atts_s = '';
if ( $attr_arr )
$atts_s = join( ' ', $attr_arr );
$span_class_name = array( 'node-name' );
if ( $node->childNodes->length )
$span_class_name[] = 'node-with-childs';
if ( $collapse_all )
$span_class_name[] = 'collapsed-node';
$span_class_name = join( ' ', $span_class_name );
$inner = '<span class="' . $span_class_name . '"><'.
$node->tagName . ' ' . $atts_s . '></span>';
if ( $node->childNodes->length )
$inner .= '<ul>' . innerXML( $node->childNodes, $collapse_all, false ) .
'</ul>';
$className = 'element-node';
}
elseif ( $node->nodeType == XML_TEXT_NODE )
{
$value = htmlspecialchars( u2w( $node->nodeValue ) );
$inner = '<span class="value">' . $value . '</span><span
class="hex">' . string2hex( $value ) . '</span>';
$className = 'text-node';
}
else
continue;
$s .= '<li class="' . $className . '">' . $inner .
'</li>';
if ( $top_run ) echo '<hr />';
}
if ( $top_run ):
ob_start();
?></ul>
<script type="text/javascript">
onLoad( function(){
addEvent( $( '.root-inner-xml-list .node-with-childs', true ), 'click',
function( e ){
var el = e.target;
ul = getNextSibling( el );
if ( !ul || ul.tagName != 'UL' ) return;
invertClass( el, 'collapsed-node' );
});
});
globalInit();
</script>
</body>
</html>
<?
$s .= ob_get_clean();
endif;
return $s;
}
?>
----
Server IP: 91.189.86.54
Probable Submitter: 80.252.129.236 (proxied: 80.252.129.236)
----
Manual Page -- http://www.php.net/manual/en/book.dom.php
Edit -- https://master.php.net/note/edit/86436
Del: integrated -- https://master.php.net/note/delete/86436/integrated
Del: useless -- https://master.php.net/note/delete/86436/useless
Del: bad code -- https://master.php.net/note/delete/86436/bad+code
Del: spam -- https://master.php.net/note/delete/86436/spam
Del: non-english -- https://master.php.net/note/delete/86436/non-english
Del: in docs -- https://master.php.net/note/delete/86436/in+docs
Del: other reasons-- https://master.php.net/note/delete/86436
Reject -- https://master.php.net/note/reject/86436
Search -- https://master.php.net/manage/user-notes.php