SKIP navigation
Buildit
Buildit

This page's main content:

buildit documentation

random squares.advanced topic

If you don't already have it, (right-click this link and save link as 'square_rnd.js' [yoursite/js/square_rnd.js]). Open up the file and you should see something like this (do not cut and paste from this page):

<!--
function square_rnd(){
var squareimg=new Array()
squareimg[1]="http://www.unomaha.edu/img/rnd/square/01.jpg"
squareimg[2]="http://www.unomaha.edu/img/rnd/square/02.jpg"
squareimg[3]="http://www.unomaha.edu/img/rnd/square/03.jpg"

var squarelink=new Array()
squarelink[1]="http://www.unomaha.edu/viewbook/index.php"
squarelink[2]="http://www.unomaha.edu/viewbook/index.php"
squarelink[3]="http://www.unomaha.edu/viewbook/index.php"

var ry=Math.floor(Math.random()*squareimg.length)
if (ry==0)
ry=1
document.write('<a href="'+squarelink[ry]+'" title="Viewbook image"><img alt="Random Viewbook image" src="'+squareimg[ry]+'" style="border:none;" /></a>') }
//-->

Now, for each image you saved, as outlined under 'inside.>Graphics>Squares', Edit the lines that look like this: (do not cut and paste from this page)

squareimg[1]="http://www.unomaha.edu/img/rnd/square/01.jpg"

Add a line for each image. Then add a corresponding line for each image in the next section of the code that looks like this (do not cut and paste from this page):

squarelink[1]="http://www.unomaha.edu/viewbook/index.php"

That line indicates the link for the specified random image. Now edit the following line with some sort of meaningful description in the 'title' and 'alt' areas of the following section: (do not cut and paste from this page):

document.write('<a href="'+rectlink[ry]+'" title="Viewbook image"><img alt="Random Viewbook image" src="'+rectimg[ry]+'" style="border:none;" /></a>')

Now just save your edited javascript. Any pages that use this script will have to link to it. Here's how. You will need to point to the javascript in the <head> of the document(s). That would look like this (do not cut and paste from this page):

<!-- Codebase:UNOv001//XXX_XX_XXX -->
<?php require("/var/www/html/inc/styles_xxx.inc"); ?>
<link rel="stylesheet" href="http://www.unomaha.edu/css/palette_xxx.css" type="text/css" />
<link rel="stylesheet" href="http://www.unomaha.edu/css/xxxprint.css" type="text/css" media="print" />

<script type="text/javascript" src="http://www.unomaha.edu/js/base.js"></script>
<script type="text/javascript" src="http://www.unomaha.edu/yoursite/js/square_rnd.js"></script>
</head>

The code to call the randomized squares for placement atop the menu above, would look like this (do not cut and paste from this page):

<div class="bod_top_square"><script type="text/javascript">square_rnd()</script></div>
<?php require("./inc/buildit_inside.inc"); ?>