Post Reply 
Table Toggle...
Mar. 29, 2009, 05:33 PM
Post: #1
Table Toggle...
running the latest sidki set and having difficulty wrapping my fingers around a toggle...

i've "captured" a nested <table...</table> into a \0 variable...


what would my replacement line be to toggle that \0 ???
Add Thank You Quote this message in a reply
Mar. 29, 2009, 08:04 PM (This post was last modified: Mar. 29, 2009 11:08 PM by lnminente.)
Post: #2
RE: Table Toggle...
That's what i use
Code:
<a class=\5 href="\3" title="\4\=\9" onclick="this.parentNode.innerHTML=unescape('$ESC(\0)');return false">table</a>
Add Thank You Quote this message in a reply
Mar. 29, 2009, 09:16 PM
Post: #3
RE: Table Toggle...
you LOST me!!! big time... Sad


let's start over...
i have a web page that contains this source code:
Code:
<table width=100% border=1 cellspacing=0 cellpadding=10 bordercolor=222255>
blah..blah..blah
</table>

i'm matching the code with this web filter:
Code:
Name = "Toggle Table Test"
Active = TRUE
URL = "$TYPE(htm)"
Bounds = "$NEST(<table,</table>)"
Limit = 20000
Match = "\1blah..blah..blah\2"

i need the Replace = line for the filter that will insert that table where i can toggle it on and off, where it is off by default...
Add Thank You Quote this message in a reply
Mar. 29, 2009, 11:03 PM (This post was last modified: Mar. 29, 2009 11:12 PM by lnminente.)
Post: #4
RE: Table Toggle...
Then i suppose is only take some code from the yahoo filters you maintain...I don't have proxomitron installed here.
I edited my above post to don't confuse this thread...
Add Thank You Quote this message in a reply
Mar. 30, 2009, 10:10 AM
Post: #5
RE: Table Toggle...
it's unfortunate that you edited that post, but all is good...

it's your href="\3" line that is the "you lost me" bit...
nowhere in the filter (which is now no longer there for readers to reference), nowhere is \3 "defined"...
Add Thank You Quote this message in a reply
Mar. 30, 2009, 11:14 AM (This post was last modified: Mar. 30, 2009 11:14 AM by sidki3003.)
Post: #6
RE: Table Toggle...
(Mar. 29, 2009 08:04 PM)lnminente Wrote:  
Code:
<a class=\5 href="\3" title="\4\=\9" onclick="this.parentNode.innerHTML=unescape('$ESC(\0)');return false">table</a>

Using $ESC with potentially huge strings is apparently critical. I got "unexpected" results when trying to do that with an early version of the "display cookies" filter. You could store your "to be innerHTMLed" data in another element, e.g. textarea.

Another way is to let the toggle switch the table's display. "MozillaZine: Alternate Display" is a good example but possibly not easy to read, so...

For the sake of simplicity let's assume that the "bordercolor" value is your identifier. Your example isn't rendered as table because text content must be within TD's, so, test code:

Code:
<table width=100% border=1 cellspacing=0 cellpadding=10 bordercolor=222255>
<td>blah..blah..blah</td>
</table>
Code:
[Patterns]
Name = "Table Toggle"
Active = TRUE
URL = "$TYPE(htm)"
Limit = 256
Match = "<table(^(^[^>]++bordercolor=$AV(222255)))"
Replace = "<a class="ProxRocks-Table" href="javascript:"
          "prxO.oInt.inToggleB('ProxRocks-Table','cl','a,table');"
          "">Toggle this Table</a><table class="ProxRocks-Table" style="display:none""
Add Thank You Quote this message in a reply
Mar. 30, 2009, 12:00 PM
Post: #7
RE: Table Toggle...
eureka! thanks!!

it was the MozillaZine that i was trying to reverse-engineer...
but it was kind of hard to follow, +'s and ++'s tend to lose me Sad

many thanks...
Add Thank You Quote this message in a reply
Mar. 30, 2009, 01:11 PM
Post: #8
RE: Table Toggle...


Attached File(s)
.txt  Collapse by classidname.txt (Size: 997 bytes / Downloads: 390)
Add Thank You Quote this message in a reply
Mar. 30, 2009, 01:42 PM
Post: #9
RE: Table Toggle...
Add Thank You Quote this message in a reply
Mar. 30, 2009, 05:53 PM
Post: #10
RE: Table Toggle...
(Mar. 30, 2009 01:42 PM)sidki3003 Wrote:  Seemed to me being the amount of data, because now that i've split the cookie string, using $ESC() on each fragment, it works (so far).
If you splitted the cookies, then you maybe removed the ;. After you telling it i went to the test window and i did a $UESC($ESC(a ; b)) , the result is a%20;%20b If i'm right this is bad, it should be "a ; b" again

Thanks Sidki i don't know javascript, all i do is comparison and modifications from one code to another. So, I modified your code moving it to onclick and returning false to be able to use href. It is useful for me for replacing banner links to be able to click on it when javascript is disabled. It would be:
Code:
<div id="original_\0" style="display:none">\8</div>
<div id="my_\0">
<a href="\1"
onclick="javascript:void(document.getElementById('my_\0').innerHTML=document.getElementById('original_\0').innerHTML);return false">
push
</a></div>
-\0 is the $GET(n) from the count list, and the link is moved to "my_div", so the link is hided after clicked.
-\8 is the original content matched by the filter

There is a worst problem now: we download the content of the original div, and i'm not sure if we could escape and unscape it using javascript.
Add Thank You Quote this message in a reply
Mar. 30, 2009, 07:18 PM
Post: #11
RE: Table Toggle...
(Mar. 30, 2009 05:53 PM)lnminente Wrote:  
(Mar. 30, 2009 01:42 PM)sidki3003 Wrote:  Seemed to me being the amount of data, because now that i've split the cookie string, using $ESC() on each fragment, it works (so far).
If you splitted the cookies, then you maybe removed the ;. After you telling it i went to the test window and i did a $UESC($ESC(a ; b)) , the result is a%20;%20b If i'm right this is bad, it should be "a ; b" again

I don't remember. Anyway, i've just checked that filter again. My current (non-public alpha) version doesn't use $ESC() any more at all. So probably there was a reason...


Quote:There is a worst problem now: we download the content of the original div, and i'm not sure if we could escape and unscape it using javascript.

That depends on the actual tags *and* browser. Nonetheless, it's an issue, and that's where <textarea> comes into play (code then being stored in myTextarea.value, not being rendered). IIRC it's slightly more complex. I think i've also seen this method being used in a "toggle Flash" post by z12, on this forum.
Add Thank You Quote this message in a reply
Mar. 30, 2009, 07:39 PM (This post was last modified: Mar. 30, 2009 07:40 PM by ProxRocks.)
Post: #12
RE: Table Toggle...
(Mar. 30, 2009 07:18 PM)sidki3003 Wrote:  I think i've also seen this method being used in a "toggle Flash" post by z12, on this forum.

correct...
i've been using the method (with off-and-on success) to prevent connections from being made on items not yet toggled on...
which, if memory serves, is only an ie|shell issue...
i seem to recall that Firefox handles that better, don't remember on Opera...
and have done extremely limited testing with Chrome and Iron...
Add Thank You Quote this message in a reply
Mar. 30, 2009, 08:21 PM (This post was last modified: Mar. 30, 2009 08:31 PM by lnminente.)
Post: #13
RE: Table Toggle...
I think to remember FF doesn't download hided flash objects, but hided images are downloaded.
Code:
[Patterns]
Name = "<a offsite+img> Toggle all links with images"
Active = TRUE
URL = "$TYPE(htm)"
Limit = 1100
Match = "(<a\s[^>]++href=$AV(\1)"
        "$INEST(<a,(*(<img\s[^>]++src=$AV(\3)[^>]++>)\0*),</a)</a >"
        ")\8"
        ""
        "$TST(($GET(n)+)=$LST(Count)|*)$SET(n=$GET(i))"
        "$SET(0=$GET(n))"
Replace = "</noscript>"
          "<div id="original_\0" style="display:none">\8</div><div id="my_\0">"
          "<a href="\1" "
          "onclick="javascript:void(document.getElementById('my_\0').innerHTML=document.getElementById('original_\0').innerHTML);return false">"
          "[ImgLink]"
          "</a></div>\r\n"
Add Thank You Quote this message in a reply
Post Reply 


Forum Jump: