U
Une Bévue
the purpose :
avoid all banners and unusefull contents of an html document the leaves
intact the part from start to body and inside the body leave only the
part where user has clicked (by mousedown -- mousemove --> mouseup)).
for example a schematic document as input :
<html><title>...<meta<<link to csss, javascript ect>
<body...>
<div id="one">div one contents </div>
<div id="two">div two contents </div>
<div id="three">div three contents </div>
</body>
<.html>
suppose the user clicked down and up into div "two", i want to
transform (in-place) the given document into :
<html><title>...<meta<<link to csss, javascript ect>
<body...>
<div id="two">div two contents </div>
</body>
<.html>
then leaving only div two inside the body.
i've started to work about that (not successfully)
following :
<http://www.quirksmode.org/js/events_mouse.html>
and :
<http://www.quirksmode.org/dom/getElementsByTagNames.html>
where iI did extract a usefull function, to me :
--- getElementsByTagNames(list,obj) ---
function getElementsByTagNames(list,obj) {
nb_calls++;
if (!obj) var obj = document.body;
var tagNames = list.split(',');
var resultArray = new Array();
var tags;
for (var i=0;i<tagNames.length;i++) {
tags = obj.getElementsByTagName(tagNames);
nb_tags+=tags.length;
for (var j=0;j<tags.length;j++) {
resultArray.push(tags[j]);
nb_loop++;
}
}
return resultArray;
}
-----------------------------------------------------
here are the probs i get )))
with an html page as mentionned above having 5 divs inside the body, in
order to simulate a "real life" document :
div banner, div left, div extract, div right and div footer.
the div extract dom structure being ;
--- div#extract ----------------------------------------
<div id="extract">
<h3 id="click">Mousedown, mouseup, click</h3>
<p>...</p>
<ol>
<li><code>...</code>...</li>
<li><code>...</code>,...</li>
<li><code>...</code>...
<code>...</code>...<code>...</code>...</li>
</ol>
<p>... <code>...</code> ...<code>...</code>
....<code>...</code>...<code>...</code>....<code>...</code>...</p>
<p>...<code>...</code>... <code>...</code> ....</p>
<p>...<code>...</code>...<code>click</code>...</p>
<p>...</p>
</div>
-----------------------------------------------------------
if, on this div extract i do :
extract=document.getElementById("extract")
then :
elts_extract=getElementsByTagNames(the_list,extract);
with :
var the_list="div, h1, h2, h3, h4, h5, p, img, ul, li, table, pre"
i get NO elements at all using the function
"getElementsByTagNames(list,obj)"
notice that the vars : nb_calls, nb_tags and nb_loop are there only
for debuging.
in case someone have some light abour that...
avoid all banners and unusefull contents of an html document the leaves
intact the part from start to body and inside the body leave only the
part where user has clicked (by mousedown -- mousemove --> mouseup)).
for example a schematic document as input :
<html><title>...<meta<<link to csss, javascript ect>
<body...>
<div id="one">div one contents </div>
<div id="two">div two contents </div>
<div id="three">div three contents </div>
</body>
<.html>
suppose the user clicked down and up into div "two", i want to
transform (in-place) the given document into :
<html><title>...<meta<<link to csss, javascript ect>
<body...>
<div id="two">div two contents </div>
</body>
<.html>
then leaving only div two inside the body.
i've started to work about that (not successfully)
following :
<http://www.quirksmode.org/js/events_mouse.html>
and :
<http://www.quirksmode.org/dom/getElementsByTagNames.html>
where iI did extract a usefull function, to me :
--- getElementsByTagNames(list,obj) ---
function getElementsByTagNames(list,obj) {
nb_calls++;
if (!obj) var obj = document.body;
var tagNames = list.split(',');
var resultArray = new Array();
var tags;
for (var i=0;i<tagNames.length;i++) {
tags = obj.getElementsByTagName(tagNames);
nb_tags+=tags.length;
for (var j=0;j<tags.length;j++) {
resultArray.push(tags[j]);
nb_loop++;
}
}
return resultArray;
}
-----------------------------------------------------
here are the probs i get )))
with an html page as mentionned above having 5 divs inside the body, in
order to simulate a "real life" document :
div banner, div left, div extract, div right and div footer.
the div extract dom structure being ;
--- div#extract ----------------------------------------
<div id="extract">
<h3 id="click">Mousedown, mouseup, click</h3>
<p>...</p>
<ol>
<li><code>...</code>...</li>
<li><code>...</code>,...</li>
<li><code>...</code>...
<code>...</code>...<code>...</code>...</li>
</ol>
<p>... <code>...</code> ...<code>...</code>
....<code>...</code>...<code>...</code>....<code>...</code>...</p>
<p>...<code>...</code>... <code>...</code> ....</p>
<p>...<code>...</code>...<code>click</code>...</p>
<p>...</p>
</div>
-----------------------------------------------------------
if, on this div extract i do :
extract=document.getElementById("extract")
then :
elts_extract=getElementsByTagNames(the_list,extract);
with :
var the_list="div, h1, h2, h3, h4, h5, p, img, ul, li, table, pre"
i get NO elements at all using the function
"getElementsByTagNames(list,obj)"
notice that the vars : nb_calls, nb_tags and nb_loop are there only
for debuging.
in case someone have some light abour that...