Free javascript Hosting


testlib.js

Uploaded on Nov 05 2009 18:39 by sgallagherstarr

function loadjscssfile(filename, filetype)
{
if (filetype=='js')
{ /* if filename is a external JavaScript file */
var fileref=document.createElement('script');

fileref.setAttribute('type','text/javascript');
fileref.setAttribute('src', filename);
console.debug("loaded source %s of type %s", filename, filetype);
} else
if (filetype=='css')
{ /* if filename is an external CSS file */
var fileref=document.createElement('link');
fileref.setAttribute('rel','stylesheet');
fileref.setAttribute('type', 'text/css');
fileref.setAttribute('href', filename);
}
if (typeof fileref!='undefined')
{
document.getElementsByTagName('head')[0].appendChild(fileref);
}
}

/* first things first - load up jQuery from the google api hosting service */
loadjscssfile('http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js', 'js');
jQuery.noConflict();
console.debug("jQuery is in.");

/* once that's loaded, load up the worldcat.org stuff */
$(document).ready(function()
{
console.debug("ready function is ... ready");
/* do stuff when DOM is ready */
loadjscssfile('http://www.worldcat.org/wcpa/rel20091011/html/searchapi.js', 'js');
/* dynamically load and add the worldcat.org .js file */
var params = new Object();

params['source'] = 'platform';
params['ai']= 'Northwest_sagallagherstarr';
params['lang'] = 'en';
params['host'] = 'www.worldcat.org';
params['version'] = '1.0';
/* Optional customization, remove if you do not need */ /*
params['title'] = 'Find items in libraries near you'; // override
branding title */ /* Call WorldCat to display search box */
/* the next line won't work until after the necessary elements have been added to the document via jQuery */
/* WCLSearch.display(params, 'wc_searchbox'); */
});

Back to list