1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
//
// floatingcode.pike, This a Roxen Module
//
// (C)Copyright 1999, Xavier Beaudouin <kiwi@oav.net>
//
// This code is (c) 1997-1999 Xavier BEAUDOUIN and can be used, modified
// redistributed freely under the terms of the GNU General Public License,
// version 2.
// This code comes on a AS-IS basis, with NO WARRANTY OF ANY KIND, either
// implicit or explicit. Use at your own risk.
// You can modifiy this code as you wish, but in this case please
// - state that you changed the code in the modified version
// - do not remove my name and email from it
// - send me a cope of the modified version or a path, so that I can
// include it in the 'official' release.
// If you find this code useful, please email me, send pizza, postcard or
// anything that can definitely boost my ege ;-)
//
// For risks and side-effects please read the code or ask your local unix
// or roxen guru ;-)
//
// Version this module
string cvs_version = "$Id: floatingcode.pike,v 1.4 1999/06/15 20:44:12 kiwi Exp $";
// Tell Roxen that this module is threadsafe. That is there is no
// request specific data in global variables.
#include <module.h>
inherit "module";
array register_module()
{
return ({ MODULE_PARSER,
"Floating Code",
("This module add a new RXML container <float>...</float>.<br>"
"The code inside the container then is moved left to right on the top<br>"
"layer using HTML4 layers with Netscape 4.x or compatibles browers.<br>"
"With this type of code you can add floating banner and so on ;-)<br>"
"<br><b>Syntax:</b><br>"
"<ul><b><float></b> some RXML code here <b></float></b><br><br>"
"This will scroll left to right the RXML code included.</ul><br>"
"<b>Options of this tag :</b><br>"
"<ul><b>help</b>: This give you this text.<br>"
"<b>inverse</b>: This give you a right to left scrolling !</ul>"
""),
0, 1
});
}
//
string floatingcode(string tag_name, mapping argument, string contents, object id, mapping defines)
{
string retval="";
string layernb = sprintf("%d",random(1000));
if (argument->help) return register_module()[2]; // To complete the <float help> tag !
// If the browser doesn't support netscape_javascript we don't show the
// Layer code ;-))
if (!id->supports->netscape_javascript) return "";
// BLAM BLAM BLAM... Please Shoot me...
// MSIE Doesn't support LAYER like Netscape ;-(
// Please does someone add some support for such browser ;-(((
// MSIE 5.0 support it ? Really, I'm not sure about this...
if (id->supports->msie) return "";
retval += "<LAYER NAME=\"layMobile"+layernb+"\"><div ID=\"obj_"+layernb+"\" CLASS=\"obj"+layernb+"\">\n\n";
retval += contents;
retval += "\n\n</DIV></LAYER>"
"<script language=\"JavaScript\">\n\n"
"var speedb=0;\n"
"var isNS = (navigator.appName == \"Netscape\" && parseInt(navigator.appVersion) >= 4);\n"
"var div1 = (isNS) ? document.layers[\"layMobile"+layernb+"\"] : document.all.obj_"+layernb+".style;\n"
"var objet;\n"
"objet = div1;\n";
// This JavaScript function move the object....
retval += "function placeObj(i,px,py) {\n"
"if (isNS)\n"
"{ objet.moveTo(px,py); }\n"
"else\n"
"{ objet.left=px; object.top=py; }\n"
"}\n";
// This JavaScript function set the visible tag of the object...
retval += "function voirObj(i) { objet.visibility=\"visible\"; }\n";
// This JavaScript function set the invisible tag of the object...
retval += "function cacheObj(i) { objet.visibility=\"hidden\"; }\n";
// This JavaScript function scroll the object...
retval += "function scroller(min,max,pos) { "
"if(pos<min){pos=max};if(pos>max){pos=min};placeObj(0,";
if (!argument->inverse) retval+="-"; // This setup for inverse version of floating code
retval += "pos,100);pos-=2;"
"tempo=window.setTimeout('scroller('+min+','+max+','+pos+')',1); }";
// The rest of the programm...
retval += "voirObj(0); scroller(-(screen.width+150),screen.width/2,50);\n"
"</script>";
// That's all for the script !!!
return retval;
}
// This is nessesay for the MODULE_PARSER here....
mapping query_container_callers() { return (["float":floatingcode,]); }
|