JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 4th, 2001, 10:20 AM
Maglight Maglight is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 67 Maglight User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
Question Parsing Dreamweaver-JavaScript through a perl script - buggy?

Hi,

i'm using a simple script what reads a html-template and parses it to the browser.

I do have a test-template like this:

Code:
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" onLoad="MM_preloadImages('b_o_home_01-over.gif')">
<p><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','b_o_home_01-over.gif',1)"><img name="Image1" border="0" src="b_o_home_01.gif" width="120" height="15"></a></p>
<p>[%Message]</p>
</body>
</html>


My perlscript uses the following routines:

Code:

sub ReadTemplate {
    my $msg  =  shift @_;
    my $file =  shift @_;
    $file    =~ s#\.\./##g;
    $file    =~ s/[^\w-\.]//g;
    $file    = $basepath . $file;
    open(FILE, "$template") or Error('$!");
    my @lines = (<FILE>);
    close(FILE)or Error($!");
    return @lines;
}

sub ParseText {
    my ($line, $key, $value, $sub);
    foreach $line (@_)
        {
        while (($key => $value) = each %FORM)
            { $line =~ s/\[$key\]/$value/ig }
        while (($key => $value) = each %ENV)
            { $line =~ s/\[\%$key\]/$value/ig }
        $line =~ s/\[[^<](.)*?[^>]\]//g;
        }
    foreach $line (@_)
        {
        while ($line =~ /\[<((.)*?)>\]/)
            {
            $sub = $1;
            $sub =~ s/[^\d\+\*\/\-%\.x<>\(\)]//g;
            $sub = eval $sub;
            $sub = sprintf ("%.2f", $sub); 
            $line =~ s/\[<(.)*?>\]/$sub/
            }
        }
    return @_;
}

sub Output { 
     print "$content_type@_\n" 
}


If i parse this template through my script i'll get errors on moving the mouse over the image ...

Any idea how i could change this so that those damned Dreamweaver-Code is displayed correctly?

Thanks for your help.

Reply With Quote
  #2  
Old July 4th, 2001, 12:47 PM
footinmouth footinmouth is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: North Vancouver, BC, Canada
Posts: 44 footinmouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
Hmmmmm.....

Try putting the script in an external file.

at the top of the web page put :

<script language="javascript" src="YourScript.js"></script>

That way perl will not look into the file and change any code.

Hope this helps.
__________________
Thanks

Foot in Mouth ver 1.2.5 Onion

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Parsing Dreamweaver-JavaScript through a perl script - buggy?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap