SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot virginiamonkeys's Avatar
    Join Date
    Jun 2003
    Location
    Stafford, Virginia, USA
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help formatting this output to 1 column (kinda)

    I "stole" this script from www.24fun.com and want to format this to fit one column. I can see the HTML embedded within this script, but can't seem to alter this from 2 columns to 1 column of counting. (I know it's not technically 1 or 2 columns.) If you run this, you will see what I mean.

    I entered stats from a government site. It's not done, but these are here in the meantime.

    Can I get a hand formatting this?




    Code:
    <script>
    // CREDITS:
    // Realtime Death Counter 2.01
    // By Peter Gehrig
    // Copyright (c) 2003 Peter Gehrig. All rights reserved.
    // Permission given to use the script provided that this notice remains as is.
    // Additional scripts can be found at http://www.24fun.com
    // info@24fun.com
    // 10/6/2003
    // The script is based on statistics by World Health Organisation
    
    // IMPORTANT:
    // If you add this script to a script-library or script-archive
    // you have to add a highly visible link to
    // http://www.24fun.com on the webpage
    // where this script will be featured
    
    var cause=new Array()
    
    // delete or add new crimes like this: 
    // cause[x]="crime|number of incidents per year"
    cause[0]="<strong>All Criminal Offenses in USA</strong>|11877218"
    cause[1]="<strong>Violent Crime</strong>|1426325"
    cause[2]="Murder and Nonnegligent Manslaughter|16204"
    cause[3]="Forcible Rape|95136"
    cause[4]="Robbery|420637"
    cause[5]="Aggravated Assault|894348"
    cause[6]="<strong>Property Crime Total</strong>|10450893"
    cause[7]="Burglary|2151875"
    cause[8]="Larceny-Theft|7052922"
    cause[9]="Motor Vehicle Theft|1246096"
    cause[10]="<strong>All Criminal Offenses in Virginia</strong>|229039"
    cause[11]="<strong>Violent Crime</strong>|21256"
    cause[12]="Murder and Nonnegligent Manslaughter|388"
    cause[13]="Forcible Rape|1839"
    cause[14]="Robbery|6961"
    cause[15]="Aggravated Assault|12068"
    cause[16]="<strong>Property Crime Total</strong>|207783"
    cause[17]="Burglary|31757"
    cause[18]="Larceny-Theft|157548"
    cause[19]="Motor Vehicle Theft|18478"
    
    
    
    // font
    var thisfont="Arial"
    
    // font-size
    var thissize=9
    
    // font-color
    var thiscolor="black"
    
    
    // font of title
    var titlefont="Arial"
    
    // font-size of title
    var titlesize=9
    
    // font-color
    var titlecolor="#DDF526"
    
    
    // backgroundcolor title
    var titlebg="#000000"
    
    // backgroundcolor death counter
    var bg="#DDF526"
    
    
    // do not edit below this line
    var t = 0
    var enterTime = new Date()
    var enterTime = Math.floor(enterTime.getTime()/1000)
    var secyear=31536000
    var rowflag=false
    var i_causes=0
    
    if (document.getElementById) {
    	initdisplay()
    }
    
    function initdisplay() {
    	document.write('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 bgcolor="'+bg+'">')
    	document.write('<tr valign=top>')
    	document.write('<td colspan=4 style="font-family:'+titlefont+';font-size:'+titlesize+'pt;color:'+titlecolor+';background-color:'+titlebg+'" 
    
    id="titlecell" align=center>')
    	document.write('&nbsp;&nbsp;Realtime Death counter: Deaths within the last 0 seconds')
    	document.write('</td></tr>')
    	
    	document.write('<tr valign=top>')
    	document.write('<td colspan=2>')
    	document.write('&nbsp;')
    	document.write('</td></tr>')
    	document.write('<tr valign=top>')
    	document.write('<td><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>')
    	for (i=0; i<=(cause.length)/2; i++) {
    		var content=cause[i].split("|")
    		document.write('<tr valign=top>')
    		document.write('<td align=right id="cell'+i+'" style="font-family:'+thisfont+';font-size:'+thissize+'pt;color:'+thiscolor+'">')
    		document.write('empty')
    		document.write('</td>')
    		document.write('<td>')
    		document.write('&nbsp;&nbsp;')
    		document.write('</td>')
    		document.write('<td align=left style="font-family:'+thisfont+';font-size:'+thissize+'pt;color:'+thiscolor+'">')
    		document.write(content[0]+" ")
    		document.write('</td>')
    		document.write('</tr>')
    		i_causes++
    	}			
    	document.write('</TABLE></td>')
    	document.write('<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>')
    	document.write('<td><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>')
    	for (i=i_causes; i<=cause.length-1; i++) {
    		var content=cause[i].split("|")
    		document.write('<tr valign=top>')
    		document.write('<td align=right id="cell'+i+'" style="font-family:'+thisfont+';font-size:'+thissize+'pt;color:'+thiscolor+'">')
    		document.write('empty')
    		document.write('</td>')
    		document.write('<td>')
    		document.write('&nbsp;&nbsp;')
    		document.write('</td>')
    		document.write('<td align=left style="font-family:'+thisfont+';font-size:'+thissize+'pt;color:'+thiscolor+'">')
    		document.write(content[0]+" ")
    		document.write('</td>')
    		document.write('</tr>')
    	}			
    	document.write('</TABLE></td></TABLE>')
    }
    
    function docounter() {
    	var now = new Date()
    	var now=Math.floor((now.getTime()/1000))
    	var hereSince = now - enterTime
    	for (i=0; i<=cause.length-1; i++) {
    		var content=cause[i].split("|")
    		content[1]=Math.floor(content[1]/secyear*hereSince)
        	document.getElementById('cell'+i).innerHTML=content[1]
        	document.getElementById('titlecell').innerHTML="&nbsp;&nbsp;Realtime Death counter: Deaths within the last "+hereSince+" seconds"
    	}	
    	var setT = setTimeout("docounter()",1000)		
    }
    
    
    function showNr(zahlProSec,hereSi,gifNa) {
    
    	var zahlSince = ""+Math.floor(hereSi*zahlProSec) 
    	var rechtsPos = 9 -	zahlSince.length-1
    
    	for (i=0; i<= zahlSince.length-1; i++) {
    		document.images[gifNa+(i+rechtsPos)].src = "z"+zahlSince.charAt(i)+".gif"
    	}
    }
    
    if (document.getElementById) {
    	window.onload=docounter
    }
    </script>

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:

    function initdisplay() {
        
    document.write('<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 bgcolor="'+bg+'">')
        
    document.write('<tr valign=top>')
        
    document.write('<td colspan=4 style="font-family:'+titlefont+';font-size:'+titlesize+'pt;color:'+titlecolor+';background-color:'+titlebg+'" id="titlecell" align=center>')
        
    document.write('&nbsp;&nbsp;Realtime Death counter: Deaths within the last 0 seconds')
        
    document.write('</td></tr>')

        
    document.write('<tr valign=top>')
        
    document.write('<td colspan=2>')
        
    document.write('&nbsp;')
        
    document.write('</td></tr>')
        
    document.write('<tr valign=top>')
        
    document.write('<td><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>')
        for (
    i=0i<=cause.length-1i++) {
            var 
    content=cause[i].split("|")
            
    document.write('<tr valign=top>')
            
    document.write('<td align=right id="cell'+i+'" style="font-family:'+thisfont+';font-size:'+thissize+'pt;color:'+thiscolor+'">')
            
    document.write('empty')
            
    document.write('</td>')
            
    document.write('<td>')
            
    document.write('&nbsp;&nbsp;')
            
    document.write('</td>')
            
    document.write('<td align=left style="font-family:'+thisfont+';font-size:'+thissize+'pt;color:'+thiscolor+'">')
            
    document.write(content[0]+" ")
            
    document.write('</td>')
            
    document.write('</tr>')
            
    i_causes++
        }
        
    document.write('</TABLE></td>')
        
    document.write('<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>')


  3. #3
    SitePoint Zealot virginiamonkeys's Avatar
    Join Date
    Jun 2003
    Location
    Stafford, Virginia, USA
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent! Thank you.


Bookmarks

Posting Permissions

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