Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2005
    Location
    Florida, USA
    Posts
    527
    Tokens
    0

    Default A few JavaScripts for you!

    Hey I have decided to make a tutoral or tips for all the people who need some help for their websites.So I am making a post saying some of the Scripts I know and use.So I really hope it helps all of you.Also,I hope it gets stickied...Here are the codes.Were ever you see "Change Me" you may put waht ever you want in it.This is my first tutoral.

    Close window button-
    Simply put this below the <head> section of your page.
    Code:
    <form>
    <input type="button" value="Close Window" onClick="window.close()">
    </form>
    
    <a href="javascript:window.close()">Change Me</a>

    Slowly come together...status bar-
    Put this in <body>
    Code:
    <SCRIPT LANGUAGE="JavaScript">
    
    
    // set speed of banner (pause in milliseconds between addition of new character)
    var speed = 10 
    
    // decrease value to increase speed (must be positive)
    // set pause between completion of message and beginning of following message
    var pause = 1500 
    
    // increase value to increase pause
    // set initial values
    var timerID = null
    var bannerRunning = false
    
    // create array
    var ar = new Array()
    
    // assign the strings to the array's elements
    ar[0] = "Change Me"
    ar[1] = "Change Me"
    ar[2] = "Change Me"
    ar[3] = "Change me"
    
    // assign index of current message
    var message = 0
    
    // empty string initialization
    var state = ""
    
    // no value is currently being displayed
    clearState()
    
    // stop the banner if it is currently running
    function stopBanner() {	
    	// if banner is currently running	
    	if (bannerRunning)		
    	// stop the banner		
    	clearTimeout(timerID)	
    	// timer is now stopped	
    	timerRunning = false
    }
    
    // start the banner
    function startBanner() {	
    	// make sure the banner is stopped	
    	stopBanner()	
    	// start the banner from the current position	
    	showBanner()
    }
    
    // assign state a string of "0" characters of the length of the current message
    function clearState() {	
    	// initialize to empty string	
    	state = ""	
    	// create string of same length containing 0 digits	
    	for (var i = 0; i < ar[message].length; ++i) {		
    		state += "0"	
    	}
    }
    
    // display the current message
    function showBanner() {	
    	// if the current message is done	
    	if (getString()) {		
    		// increment message		
    		message++		
    		// if new message is out of range wrap around to first message		
    	if (ar.length <= message)			
    		message = 0		
    		// new message is first displayed as empty string		
    		clearState()		
    		// display next character after pause milliseconds		
    		timerID = setTimeout("showBanner()", pause)	
    	} 
    	else {		
    		// initialize to empty string		
    		var str = ""		
    		// built string to be displayed (only character selected thus far are displayed)		
    	for (var j = 0; j < state.length; ++j) {			
    		str += (state.charAt(j) == "1") ? ar[message].charAt(j) : "     "		
    	}		
    	// partial string is placed in status bar		
    	window.status = str		
    	// add another character after speed milliseconds		
    	timerID = setTimeout("showBanner()", speed)	
    	}
    }
    
    function getString() {	
    	// set variable to true (it will stay true unless proven otherwise)	
    	var full = true	
    	// set variable to false if a free space is found in string (a not-displayed char)	
    	for (var j = 0; j < state.length; ++j) {		
    		// if character at index j of current message has not been placed in displayed string		
    		if (state.charAt(j) == 0)			
    		full = false	
    	}	
    	// return true immediately if no space found (avoid infinitive loop later)	
    	if (full) return true	
    	// search for random until free space found (braoken up via break statement)	
    	while (1) {		
    		// a random number (between 0 and state.length - 1 == message.length - 1)		
    		var num = getRandom(ar[message].length)		
    		// if free space found break infinitive loop		
    	if (state.charAt(num) == "0")			
    		break	
    	}	
    	// replace the 0 character with 1 character at place found	
    	state = state.substring(0, num) + "1" + state.substring(num + 1, state.length)	
    	// return false because the string was not full (free space was found)	
    	return false
    }
    
    function getRandom(max) {	
    	// create instance of current date	
    	var now = new Date()		
    	// create a random number (good generator)	
    	var num = now.getTime() * now.getSeconds() * Math.random()	
    	// cut random number to value between 0 and max - 1, inclusive	
    	return num % max
    }
    startBanner()
    // -->
    </SCRIPT>
    Auto Refresh-
    put this in below <head>
    Code:
    <script>
    <!--
    
    
    
    //enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
    var limit="Time Here"
    
    if (document.images){
    var parselimit=limit.split(":")
    parselimit=parselimit[0]*60+parselimit[1]*1
    }
    function beginrefresh(){
    if (!document.images)
    return
    if (parselimit==1)
    window.location.reload()
    else{ 
    parselimit-=1
    curmin=Math.floor(parselimit/60)
    cursec=parselimit%60
    if (curmin!=0)
    Minutes" minutes and "Seconds Here" seconds left until page refresh!"
    else
    curtime=cursec+" seconds left until page refresh!"
    window.status=curtime
    setTimeout("beginrefresh()",1000)
    }
    }
    
    window.onload=beginrefresh
    //-->
    </script>
    Random Picture-
    Under <body>
    Code:
    <script language="JavaScript">
    <!--
    
    
    
    function random_imglink(){
    var myimages=new Array()
    //specify random images below. You can have as many as you wish
    myimages[1]="image1.gif"
    myimages[2]="image2.gif"
    myimages[3]="image3.gif"
    myimages[4]="image4.gif"
    myimages[5]="image5.gif"
    myimages[6]="image6.gif"
    
    var ry=Math.floor(Math.random()*myimages.length)
    if (ry==0)
    ry=1
    document.write('<img src="'+myimages[ry]+'" border=0>')
    }
    random_imglink()
    //-->
    </script>
    
    <p align="center"><font face="arial" size="-2">This free script provided by</font><br>
    <font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript
    Kit</a></font></p>
    Login and Password protected-
    Under <body>
    Code:
    <script language="javascript">
    <!--//
    /*This Script allows people to enter by using a form that asks for a
    UserID and Password*/
    function pasuser(form) {
    if (form.id.value=="JavaScript") { 
    if (form.pass.value=="Kit") {              
    location="What site?" 
    } else {
    alert("Invalid Password")
    }
    } else {  alert("Invalid UserID")
    }
    }
    //-->
    </script>
    
    <center>
    <table bgcolor="white" cellpadding="12" border="1">
    <tr><td colspan="2"><center><h1><i><b>Login
    Area</b></i></h1></center></td></tr>
    <tr><td><h1><i><b>UserID:</b></i></h1></td><td><form name="Change Me"><input
    name="id" type="text"></td></tr>
    <tr><td><h1><i><b>Password:</b></i></h1></td><td><input name="pass"
    type="Change Me"></td></tr>
    <tr><td><center><input type="button" value="Login"
    onClick="pasuser(this.form)"></center></td><td><center><br><input
    type="Reset"></form></td></tr></table></center>
    Random PassWord-
    Under <body>
    Code:
    <script>
    
    
    
    var keylist="abcdefghijklmnopqrstuvwxyz123456789"
    var temp=''
    
    function generatepass(plength){
    temp=''
    for (i=0;i<plength;i++)
    temp+=keylist.charAt(Math.floor(Math.random()*keylist.length))
    return temp
    }
    
    function populateform(enterlength){
    document.pgenerate.output.value=generatepass(enterlength)
    }
    </script>
    
    <form name="pgenerate">
    <input type="text" size=18 name="output">
    <input type="button" value="Generate Password" onClick="populateform(this.form.thelength.value)"><br>
    <b>Password Length:</b> <input type="text" name="thelength" size=3 value="7">
    </form>
    I really hope this works and helps all of you guys that need help.Thank You.
    Last edited by dani342us; 12-06-2005 at 08:52 PM.
    Even Though We May Be From Different Places, Speak In Different Tounges, Our Hearts
    Still Beats As One.



  2. #2
    Join Date
    Apr 2005
    Posts
    2,444
    Tokens
    0

    Latest Awards:

    Default

    Thanks Dani-These heped me!

  3. #3
    JoeComins Guest

    Default

    it seems that you have only copied these off a site and added the quote codes. This is not really makeing a tutorial as it isn't your work

  4. #4
    Join Date
    Feb 2005
    Location
    Florida, USA
    Posts
    527
    Tokens
    0

    Default hey

    You dont haveto to make your own script or stuff to make a tutoral,yes I did get if off a site but it is just to help people who need some help with theyr websites.
    Even Though We May Be From Different Places, Speak In Different Tounges, Our Hearts
    Still Beats As One.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •