Author Topic: Help required with IF-THEN filter  (Read 1742 times)

Jor

  • Sr. Member
  • ****
  • Posts: 421
    • ICQ Messenger - 10401286
    • AOL Instant Messenger - jor otf
    • Yahoo Instant Messenger - jor_otf
    • View Profile
    • http://members.outpost10f.com/~jor/
    • Email
Help required with IF-THEN filter
« on: August 21, 2002, 07:08:52 PM »
A site-specific filter I'm working on doesn't seem to work completely, even though it does work in the test fields.

I can't give out a test URl, as the site is password protected, but hopefully you'll be able to help me by looking at the source

Filter:
Name = "Add Missing [Foo] Javascript"
Active = TRUE
URL = "www.foo.com"
Limit = 512
Match = "(<script *src="/javascripts.js" *</script> </head>"
        "$SET(1=</head>)|"
        "</style> </head>$SET(0=</style>
)$SET(1=(</head>
)))"
Replace = ""
          "<script language="JavaScript" src="/fw_menu.js" "
          "type="text/javascript"></script>
"
          "<script language="JavaScript" src="/menu.js" "
          "type="text/javascript"></script>
"
          "<script language="JavaScript" src="/javascripts.js" "
          "type="text/javascript"></script>
"
          "1
$STOP()"


What this filter does, is add two or three required JS files, if they are missing. The first part always works (adding two more if only one is found), the second one only works in the test field.

This is the HTML that should match for #2 (And does, in the test view):
<head>
<style>
TD {font-size: 10pt;}
BODY {font-size: 10pt; font-family: Arial; color: FFFF80;}
</style>
</head>
<body bgcolor=black text=white link=FFFF80 vlink=FFFF80 alink=FFFF80>
<div style="text-align: center;">


Note: the source document is missing its <html> tag, but that shouldn't matter, right?

Edited by - Jor on 21 Aug 2002  20:16:55
 

sidki3003

  • Sr. Member
  • ****
  • Posts: 476
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Help required with IF-THEN filter
« Reply #1 on: August 21, 2002, 08:05:32 PM »
I would try it with a bounds filter like so:

Name = "Add Missing [Foo] Javascript"
Active = TRUE
Multi = that depends
URL = "www.foo.com"
Bounds = "<head*</head>"
Limit = that depends
Match = "1<script *src="/javascripts.js" *</script>2
        "|"
        "1(</head>)2"
Replace = "1"
          "<script language="JavaScript" src="/fw_menu.js" "
          "type="text/javascript"></script>
"
          "<script language="JavaScript" src="/menu.js" "
          "type="text/javascript"></script>
"
          "<script language="JavaScript" src="/javascripts.js" "
          "type="text/javascript"></script>
"
          "2
$STOP()"


 
 

Jor

  • Sr. Member
  • ****
  • Posts: 421
    • ICQ Messenger - 10401286
    • AOL Instant Messenger - jor otf
    • Yahoo Instant Messenger - jor_otf
    • View Profile
    • http://members.outpost10f.com/~jor/
    • Email
Help required with IF-THEN filter
« Reply #2 on: August 21, 2002, 08:50:15 PM »
Thanks my friend

Another working filter!
Only thing I altered is Bounds = "$NEST(<head,</head>)"


Edited by - Jor on 21 Aug 2002  21:52:43