---- in the .js file ----
class JsLib
{
public function Func1 ()
{
document.write("hello");
}
public function Func2 ()
{
document.write("bye");
}
}
--- in html, the .js is included, then ---
<script type="text/javascript>
function Exec()
{
var a = new JsLib();
a.Func1();
a.Func2();
}
</script>
<a href="javascript:Exec();">test</a>
myStuff.doMoreStuff();
function JSS() {
/* Main configuration */
this.sWidth = "640"; // Slideshow dimensions
this.sHeight = "480";
this.Units = "px"; // the dimension units to use, any CSS2-compliant (pt, px, em, %, etc...)
this.Pictures = Array(); // pictures array, see below to populate
this.pShowDelay = 3000; // time of how long the picture is shown, in milliseconds
this.AniDelay = 10; // Delay between each step of alpha, in milliseconds. The lower, the faster
this.DivCssClass = ""; // Set the CSS class of the div container
this.ImgCssClass = ""; // Set the CSS class of the image
this.AniStep = 0.01; // Alpha percentage step
this.OverlayColour = "#000000"; // overlay colour which is faded into
this.InitialOpacity = 1; // Set the initial opacity of the first image
this.debug = true; // turn debugging on or off
this.index = 0; // index of the currently shown pic. Set to 0 for first pic.
/* End of main configuration!! */
this.rnd; // generate a random instance
this.iT; // timer id
this.iT2;
this.delay = false;
this.Opacity;
/* Initialize the slideshow */
this.Init = function() {
/* Place the required initial images here!! */
this.Pictures.push(">@>30 09.jpg"); // add first image
this.Pictures.push("12-O H:>;0 ?>74=> 25G5@><.jpg"); // second image
this.Pictures.push("Latskova_St_.jpg");
//Pictures.push("/images/image2.jpg"); // Template for adding more images!
this.rnd = Math.random().toString().replace(".", ""); //this will generate us a random id we can use
document.write('<div id=\'jss_' + this.rnd + '\' style="background-color: ' + this.OverlayColour + '; width: ' + this.sWidth + this.Units + '; height: ' + this.sHeight + this.Units + ';"');
if (this.DivCssClass != "") document.write(" class=\"" + this.DivCssClass + "\">"); else document.write(">");
document.write('<img id=\'jss_i' + this.rnd + '\' style="float: left; width: ' + this.sWidth + this.Units + '; height: ' + this.sHeight + this.Units + ';" src="' + this.Pictures[this.index] + '"');
if (this.ImgCssClass != "") document.write(" class=\"" + this.ImgCssClass + "\" />"); else document.write(" />");
if (this.debug) {
document.write("<br />O: <span id='debug'>debug</span>");
document.write("<br />I: <span id='debug_index'>debug</span>");
}
document.write('</div>');
if (this.debug) { setInterval("this.Debug()", 50); }
this.Opacity = this.InitialOpacity;
this.PerformFadeOut();
}
/* Adds the picture to the slideshow queue with the specified relative or absolute url */
this.AddPic = function(url) {
this.Pictures.push(url);
}
/* Executed on debug, do not use normally */
this.Debug = function() {
document.getElementById("debug").innerHTML = this.Opacity.toString();
document.getElementById("debug_index").innerHTML = this.index.toString();
return true
}
/* Performs the fading out sequence */
this.PerformFadeOut = function() {
this.iT = setInterval("FadeOut()", this.AniDelay);
}
/* Delays the displayed picture */
this.DelayPic = function() {
if (this.delay) { clearInterval(this.iT2); this.delay = false; this.PerformFadeOut(); } else this.delay = true;
}
/* Fades out one step */
this.FadeOut = function() {
this.Opacity = this.Opacity - this.AniStep;
document.getElementById("jss_i" + this.rnd).style.opacity = this.Opacity;
if (this.Opacity <= 0.1) { clearInterval(this.iT); this.Opacity = 0; this.PerformFadeIn(); }
}
/* Fades in one step */
this.FadeIn = function() {
Opacity = Opacity + AniStep;
document.getElementById("jss_i" + rnd).style.opacity = Opacity;
if (Opacity >= 1.0) { clearInterval(iT); iT2 = setInterval("DelayPic()", parseInt(pShowDelay / 2)); Opacity = 1; }
}
/* Performs fading in sequence */
this.PerformFadeIn = function() {
if (index < Pictures.length - 1) {
index++;
document.getElementById("jss_i" + rnd).setAttribute("src", Pictures[index]);
} else { index = 0; document.getElementById("jss_i" + rnd).setAttribute("src", Pictures[index]); }
iT = setInterval("FadeIn()", AniDelay);
}
}
if (this.debug) { setInterval("this.Debug()", 50); }
/* Performs the fading out sequence */
this.PerformFadeOut = function() {
var self = this;
this.iT = setInterval(function() {
self.FadeOut();
}, this.AniDelay);
}
http://mckoss.com/jscript/object.htm