Файл: upload/assets/_gftunebar.js
Строк: 738
<?php
/**
* Copyright (c) 2008 Google Inc.
*
* You are free to copy and use this sample.
* License can be found here: http://code.google.com/apis/ajaxsearch/faq/#license
*/
function GFtuneBar(barRoot, options) {
this.processArguments(barRoot, options);
this.setGlobals();
this.buildSuperStructure();
// if we have an auto execute list, then start it up
if (this.autoExecuteMode) {
this.cycleTimeClosure = this.methodClosure(this, GFtuneBar.prototype.cycleTimeout, [null]);
// if there is only a single item in the execute list, then
// disable autoExecuteMode...
if ( this.executeList.length == 1) {
this.switchToListItem(0);
} else {
this.cycleTimeout();
}
}
}
// feeds
GFtuneBar.FEED_NEW_RELEASES = "nr_all";
GFtuneBar.FEED_NEW_RELEASES_ALTERNATIVE = "nr_alt";
GFtuneBar.FEED_NEW_RELEASES_CHILDREN = "nr_chi";
GFtuneBar.FEED_NEW_RELEASES_CLASSICAL = "nr_cla";
GFtuneBar.FEED_NEW_RELEASES_COUNTRY = "nr_cou";
GFtuneBar.FEED_NEW_RELEASES_DANCE = "nr_dan";
GFtuneBar.FEED_NEW_RELEASES_ELECTRONIC = "nr_ele";
GFtuneBar.FEED_NEW_RELEASES_HIPHOP = "nr_rap";
GFtuneBar.FEED_TOP_SONGS = "ts_all";
GFtuneBar.FEED_TOP_SONGS_ALTERNATIVE = "ts_alt";
GFtuneBar.FEED_TOP_SONGS_CHILDREN = "ts_chi";
GFtuneBar.FEED_TOP_SONGS_CLASSICAL = "ts_cla";
GFtuneBar.FEED_TOP_SONGS_COUNTRY = "ts_cou";
GFtuneBar.FEED_TOP_SONGS_DANCE = "ts_dan";
GFtuneBar.FEED_TOP_SONGS_ELECTRONIC = "ts_ele";
GFtuneBar.FEED_TOP_SONGS_HIPHOP = "ts_rap";
GFtuneBar.FEED_TOP_ALBUMS = "ta_all";
GFtuneBar.FEED_TOP_ALBUMS_ALTERNATIVE = "ta_alt";
GFtuneBar.FEED_TOP_ALBUMS_CHILDREN = "ta_chi";
GFtuneBar.FEED_TOP_ALBUMS_CLASSICAL = "ta_cla";
GFtuneBar.FEED_TOP_ALBUMS_COUNTRY = "ta_cou";
GFtuneBar.FEED_TOP_ALBUMS_DANCE = "ta_dan";
GFtuneBar.FEED_TOP_ALBUMS_ELECTRONIC = "ta_ele";
GFtuneBar.FEED_TOP_ALBUMS_HIPHOP = "ta_rap";
GFtuneBar.feedMap = {
"nr_all" : {
name : "New Releases",
url : "http://itunes.apple.com/us/rss/topfreeapplications/limit=10/xml",
sort : false
},
"nr_alt" : {
name : "New Releases - Alternative",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/newreleases/limit=10/genre=20/rss.xml",
sort : false
},
"nr_chi" : {
name : "New Releases - Children",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/newreleases/limit=10/genre=4/rss.xml",
sort : false
},
"nr_cla" : {
name : "New Releases - Classical",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/newreleases/limit=10/genre=5/rss.xml",
sort : false
},
"nr_cou" : {
name : "New Releases - Country",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/newreleases/limit=10/genre=6/rss.xml",
sort : false
},
"nr_dan" : {
name : "New Releases - Dance",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/newreleases/limit=10/genre=17/rss.xml",
sort : false
},
"nr_ele" : {
name : "New Releases - Electronic",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/newreleases/limit=10/genre=7/rss.xml",
sort : false
},
"nr_rap" : {
name : "New Releases - Hip Hop/Rap",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/newreleases/limit=10/genre=18/rss.xml",
sort : false
},
"ts_all" : {
name : "Top Songs",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topsongs/limit=10/rss.xml",
sort : true
},
"ts_alt" : {
name : "Top Songs - Alternative",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topsongs/limit=10/genre=20/rss.xml",
sort : true
},
"ts_chi" : {
name : "Top Songs - Children",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topsongs/limit=10/genre=4/rss.xml",
sort : true
},
"ts_cla" : {
name : "Top Songs - Classical",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topsongs/limit=10/genre=5/rss.xml",
sort : true
},
"ts_cou" : {
name : "Top Songs - Country",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topsongs/limit=10/genre=6/rss.xml",
sort : true
},
"ts_dan" : {
name : "Top Songs - Dance",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topsongs/limit=10/genre=17/rss.xml",
sort : true
},
"ts_ele" : {
name : "Top Songs - Electronic",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topsongs/limit=10/genre=7/rss.xml",
sort : true
},
"ts_rap" : {
name : "Top Songs - Hip Hop/Rap",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topsongs/limit=10/genre=18/rss.xml",
sort : true
},
"ta_all" : {
name : "Top Albums",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topalbums/limit=10/rss.xml",
sort : true
},
"ta_alt" : {
name : "Top Albums - Alternative",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topalbums/limit=10/genre=20/rss.xml",
sort : true
},
"ta_chi" : {
name : "Top Albums - Children",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topalbums/limit=10/genre=4/rss.xml",
sort : true
},
"ta_cla" : {
name : "Top Albums - Classical",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topalbums/limit=10/genre=5/rss.xml",
sort : true
},
"ta_cou" : {
name : "Top Albums - Country",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topalbums/limit=10/genre=6/rss.xml",
sort : true
},
"ta_dan" : {
name : "Top Albums - Dance",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topalbums/limit=10/genre=17/rss.xml",
sort : true
},
"ta_ele" : {
name : "Top Albums - Electronic",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topalbums/limit=10/genre=7/rss.xml",
sort : true
},
"ta_rap" : {
name : "Top Albums - Hip Hop/Rap",
url : "http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wpa/MRSS/topalbums/limit=10/genre=18/rss.xml",
sort : true
}
};
GFtuneBar.MAX_RESULTS = 10;
// cycle time for selecting a feed
GFtuneBar.CYCLE_TIME_EXTRA_SHORT = 3000;
GFtuneBar.CYCLE_TIME_SHORT = 10000;
GFtuneBar.CYCLE_TIME_MEDIUM = 15000;
GFtuneBar.CYCLE_TIME_LONG = 30000;
// cycle mode
GFtuneBar.CYCLE_MODE_RANDOM = 1;
GFtuneBar.CYCLE_MODE_LINEAR = 2;
GFtuneBar.MAX_CACHE_LIFETIME = 50;
GFtuneBar.MIN_CACHE_LIFETIME = 4;
GFtuneBar.DEFAULT_CACHE_LIFETIME = 16;
GFtuneBar.MAX_ERROR_COUNT = 4;
GFtuneBar.THUMBNAILS_SMALL = 53;
GFtuneBar.THUMBNAILS_MEDIUM = 60;
GFtuneBar.THUMBNAILS_LARGE = 100;
GFtuneBar.prototype.processArguments = function(barRoot, opt_options) {
this.CL_RESULTDIV_SMALL = "resultDiv_gftb smallResultDiv_gftb";
this.CL_RESULTDIV_MEDIUM = "resultDiv_gftb mediumResultDiv_gftb";
this.CL_RESULTDIV_LARGE = "resultDiv_gftb largeResultDiv_gftb";
this.barRoot = barRoot;
this.statusRoot = null;
this.verticalMode = true;
this.thumbSize = GFtuneBar.THUMBNAILS_LARGE;
this.resultClass = this.CL_RESULTDIV_LARGE;
this.autoExecuteMode = false;
this.executeList = new Array();
this.cycleTime = GFtuneBar.CYCLE_TIME_MEDIUM;
this.cycleMode = GFtuneBar.CYCLE_MODE_RANDOM;
this.cycleNext = 0;
this.cycleTimer = null;
this.cacheLifetime = GFtuneBar.DEFAULT_CACHE_LIFETIME;
this.linkTarget = "_self";
this.numResults = 4;
if (opt_options) {
// .numResults
if (opt_options.numResults) {
this.numResults = Math.min(opt_options.numResults, GFtuneBar.MAX_RESULTS);
}
if (opt_options.horizontal && opt_options.horizontal == true ) {
this.verticalMode = false;
} else {
this.verticalMode = true;
}
if (opt_options.thumbnailSize) {
if (opt_options.thumbnailSize == GFtuneBar.THUMBNAILS_MEDIUM ) {
this.thumbSize = GFtuneBar.THUMBNAILS_MEDIUM;
this.resultClass = this.CL_RESULTDIV_MEDIUM;
} else if ( opt_options.thumbnailSize == GFtuneBar.THUMBNAILS_SMALL ) {
this.thumbSize = GFtuneBar.THUMBNAILS_SMALL;
this.resultClass = this.CL_RESULTDIV_SMALL;
} else if ( opt_options.thumbnailSize == GFtuneBar.THUMBNAILS_LARGE ) {
this.thumbSize = GFtuneBar.THUMBNAILS_LARGE;
this.resultClass = this.CL_RESULTDIV_LARGE;
} else {
this.thumbSize = GFtuneBar.THUMBNAILS_MEDIUM;
}
}
// linkTarget
if (opt_options.linkTarget) {
this.linkTarget = opt_options.linkTarget;
}
// a cycleTime value, a cycleMode value, and an array
// of searchExpressions
if (opt_options.autoExecuteList) {
// if specified and valid, then use it, otherwise
// use default set above
if (opt_options.autoExecuteList.cycleTime) {
var cycleTime = opt_options.autoExecuteList.cycleTime;
if (cycleTime == GFtuneBar.CYCLE_TIME_EXTRA_SHORT ||
cycleTime == GFtuneBar.CYCLE_TIME_SHORT ||
cycleTime == GFtuneBar.CYCLE_TIME_MEDIUM ||
cycleTime == GFtuneBar.CYCLE_TIME_LONG ) {
this.cycleTime = cycleTime;
}
}
if (opt_options.autoExecuteList.cycleMode) {
var cycleMode = opt_options.autoExecuteList.cycleMode;
if (cycleMode == GFtuneBar.CYCLE_MODE_RANDOM ||
cycleMode == GFtuneBar.CYCLE_MODE_LINEAR) {
this.cycleMode = cycleMode;
}
}
// now grab the list...
if (opt_options.autoExecuteList.executeList &&
opt_options.autoExecuteList.executeList.length > 0 ) {
// grab from the list
for (var i=0; i < opt_options.autoExecuteList.executeList.length; i++) {
if (GFtuneBar.feedMap[opt_options.autoExecuteList.executeList[i]]) {
this.executeList.push(
this.newListItem(opt_options.autoExecuteList.executeList[i]));
}
}
if (this.executeList.length > 0) {
this.autoExecuteMode = true;
this.currentIndex = 0;
if (opt_options.autoExecuteList.statusRoot) {
this.statusRoot = opt_options.autoExecuteList.statusRoot;
}
}
}
}
}
}
GFtuneBar.prototype.resetAutoExecuteListItems = function(newList) {
if (this.autoExecuteMode && newList.length > 0) {
// stop the timer...
if (this.cycleTimer) {
clearTimeout(this.cycleTimer);
this.cycleTimer = null;
}
// clear the status area
if (this.statusRoot) {
this.removeChildren(this.statusRoot);
}
// nuke the old list
this.executeList = new Array();
// build the new list
for (var i=0; i < newList.length; i++) {
this.executeList.push(this.newListItem(newList[i]));
}
this.currentIndex = 0;
if (this.statusRoot) {
this.populateStatusRoot();
}
if ( this.executeList.length == 1) {
this.switchToListItem(0);
} else {
this.cycleTimeout();
}
}
}
GFtuneBar.prototype.setGlobals = function() {
this.br_AgentContains_cache_ = {};
// subserstructure boxes
this.CL_TUNEBARBOX = "tuneBarBox_gftb";
this.CL_TUNEBARBOXFULL = "tuneBarBox_gftb full_gftb";
this.CL_TUNEBARBOXEMPTY = "tuneBarBox_gftb empty_gftb";
// major app states
this.CL_ACTIVE = "active_gftb";
// results
this.CL_RESULTSBOX = "resultsBox_gftb";
this.CL_COPYRIGHT = "copyright_gftb";
this.CL_RESULTTABLE_VERTICAL = "resultTable_gftb vertical_gftb";
this.CL_RESULTTABLE_HORIZONTAL = "resultTable_gftb horizontal_gftb";
this.CL_RESULTCELL = "resultCell_gftb";
// status
this.CL_STATUSBOX = "statusBox_gftb";
this.CL_STATUSITEM = "statusItem_gftb";
this.CL_STATUSITEM_SELECTED = "statusItem_gftb statusItemSelected_gftb";
}
GFtuneBar.prototype.buildSuperStructure = function() {
// create the TUNEBAR box
this.removeChildren(this.barRoot);
this.barBox = this.createDiv(null, this.CL_TUNEBARBOX);
this.barRoot.appendChild(this.barBox);
// add results box and branding box
this.resultsBox = this.createDiv(null, this.CL_RESULTSBOX);
this.barBox.appendChild(this.resultsBox);
this.cssSetClass(this.barBox, this.CL_TUNEBARBOXEMPTY);
// clear and optionally populate the status area
if (this.statusRoot) {
this.populateStatusRoot();
}
}
GFtuneBar.prototype.clearAllResults = function() {
this.cssSetClass(this.barBox, this.CL_TUNEBARBOXEMPTY);
}
GFtuneBar.prototype.loadComplete = function(listItem) {
var results = null;
if (listItem.rawResults.error) {
listItem.errorCount++;
listItem.errorCount = GFtuneBar.MAX_ERROR_COUNT + 1;
listItem = null;
} else {
// populate cache
listItem.results = new Array();
listItem.cacheCount = 1;
listItem.errorCount = 0;
for (var i = 0; i < listItem.rawResults.feed.entries.length; i++) {
this.annotateEntry(listItem.rawResults.feed.entries[i]);
}
// sort if needed
if (listItem.map.sort) {
listItem.rawResults.feed.entries.sort(GFtuneBar.rankSorter);
}
// now trim the array...
if (listItem.rawResults.feed.entries.length > this.numResults) {
listItem.rawResults.feed.entries.length = this.numResults;
}
var copyrightElement = listItem.rawResults.xmlDocument.getElementsByTagName("copyright");
if (copyrightElement && copyrightElement.length > 0) {
listItem.rawResults.gftb_branding =
this.createDiv(copyrightElement[0].firstChild.nodeValue,
this.CL_COPYRIGHT);
}
}
this.processResults(listItem);
}
GFtuneBar.rankSorter = function(a, b) {
return a._gftb_rank - b._gftb_rank;
}
GFtuneBar.prototype.annotateEntry = function(entry) {
// grab the thumbnail
var coverNodes = google.feeds.getElementsByTagNameNS(
entry.xmlNode,"http://phobos.apple.com/rss/1.0/modules/itms/", "coverArt");
if (coverNodes) {
for (var cn=0; cn < coverNodes.length; cn++) {
var cnode = coverNodes[cn];
var link = cnode.firstChild.nodeValue;
for (var ai=0; ai < cnode.attributes.length; ai++) {
if (cnode.attributes[ai].nodeName == "height") {
var height = cnode.attributes[ai].nodeValue;
if (height == this.thumbSize) {
entry._gftb_thumbnailUrl = link;
}
}
}
}
}
// grab the rank
var rankNodes = google.feeds.getElementsByTagNameNS(
entry.xmlNode,"http://phobos.apple.com/rss/1.0/modules/itms/", "rank");
if (rankNodes && rankNodes.length > 0) {
entry._gftb_rank = parseInt(rankNodes[0].firstChild.nodeValue);
} else {
entry._gftb_rank = 0;
}
if (!entry._gftb_thumbnailUrl) {
// create
alert("no thmb, create generic html");
}
// title, link are already set, so now just create the html node
// for this entry and bind to _gftb_
var img = this.createImage(entry._gftb_thumbnailUrl, this.thumbSize,
this.thumbSize, null);
var div = this.createDiv(null, this.resultClass);
var anode = this.createClickLink(img, entry.link, null,
entry.title.replace(/^d*./,""));
div.appendChild(anode);
entry._gftb_html = div;
}
GFtuneBar.prototype.processResults = function(listItem) {
if ( listItem && listItem.rawResults.feed.entries.length) {
this.cssSetClass(this.barBox, this.CL_TUNEBARBOXFULL);
this.removeChildren(this.resultsBox);
var cell;
var table;
var row = null;
if (this.verticalMode) {
table = this.createTable(this.CL_RESULTTABLE_VERTICAL);
} else {
table = this.createTable(this.CL_RESULTTABLE_HORIZONTAL);
}
table.setAttribute("align", "center");
for (var i = 0; i < listItem.rawResults.feed.entries.length; i++) {
var res = listItem.rawResults.feed.entries[i];
var html = res._gftb_html.cloneNode(true);
// create a new row for each result when in vertical mode
// otherwise, jam everything into a single row.
if (this.verticalMode) {
row = this.createTableRow(table);
} else {
if (row == null) {
row = this.createTableRow(table);
}
}
cell = this.createTableCell(row, this.CL_RESULTCELL);
cell.setAttribute("align", "center");
cell.appendChild(html);
}
if (listItem.rawResults.gftb_branding) {
// now add in the branding...
row = this.createTableRow(table);
var brandingOrientation;
if (this.verticalMode) {
cell = this.createTableCell(row, this.CL_RESULTCELL);
} else {
cell = this.createTableCell(row, this.CL_RESULTCELL);
if (this.br_IsIE()) {
cell.setAttribute("colSpan", listItem.rawResults.feed.entries.length);
} else {
cell.setAttribute("colspan", listItem.rawResults.feed.entries.length);
}
}
cell.appendChild(listItem.rawResults.gftb_branding.cloneNode(true));
}
this.resultsBox.appendChild(table);
} else {
this.cssSetClass(this.barBox, this.CL_TUNEBARBOXEMPTY);
}
}
GFtuneBar.prototype.clearTimer = function() {
if (this.cycleTimer) {
clearTimeout(this.cycleTimer);
this.cycleTimer = null;
}
}
GFtuneBar.prototype.cycleTimeout = function() {
// select a new feed
// execute a search
// restart the timer
if ( this.player == null ) {
// if there is only a single item in the execute list,
// run it
if ( this.executeList.length == 1) {
this.switchToListItem(0);
} else {
var index = 0;
if (this.cycleMode == GFtuneBar.CYCLE_MODE_RANDOM) {
var max = this.executeList.length - 1;
index = Math.round(max * Math.random());
} else if (this.cycleMode == GFtuneBar.CYCLE_MODE_LINEAR){
index = this.cycleNext;
this.cycleNext++;
if (this.cycleNext >= this.executeList.length) {
this.cycleNext = 0;
}
}
this.switchToListItem(index);
this.clearTimer();
this.cycleTimer = setTimeout(this.cycleTimeClosure, this.cycleTime);
}
}
}
/**
* Autoexecute List Item Support
*/
GFtuneBar.prototype.newListItem = function(feedId) {
var listItem = new Object();
var id;
if (GFtuneBar.feedMap[feedId]) {
id = feedId;
} else {
id = GFtuneBar.FEED_NEW_RELEASES;
}
listItem.map = GFtuneBar.feedMap[id];
listItem.feed = new google.feeds.Feed(listItem.map.url);
listItem.feed.setResultFormat(google.feeds.Feed.MIXED_FORMAT);
listItem.feed.setNumEntries(GFtuneBar.MAX_RESULTS);
listItem.node = null;
listItem.results = new Array();
listItem.errorCount = 0;
listItem.cacheCount = 0;
return listItem;
}
GFtuneBar.prototype.switchToListItem = function(i) {
// reset selcted class of previous item
// note, first time through this sets
// node 0
if (this.executeList[this.currentIndex].node) {
this.cssSetClass(this.executeList[this.currentIndex].node,
this.CL_STATUSITEM);
}
this.currentIndex = i;
if (this.executeList[this.currentIndex].node) {
this.cssSetClass(this.executeList[this.currentIndex].node,
this.CL_STATUSITEM_SELECTED);
}
var queryTerm = this.executeList[this.currentIndex].query;
var cacheResults = false;
var currentListItem = null;
currentListItem = this.executeList[this.currentIndex];
// if the error count of an item has reached max, reset query term
if (currentListItem.errorCount > GFtuneBar.MAX_ERROR_COUNT) {
currentListItem.errorCount = 0;
currentListItem.map = GFtuneBar.feedMap[GFtuneBar.FEED_NEW_RELEASES];
}
// if the listItem has no cached results, OR if
// we have used the cached results several times
// already, initiate a real search
if (currentListItem.cacheCount == 0 ||
currentListItem.cacheCount > this.cacheLifetime ) {
currentListItem.cacheCount = 0;
var thisObj = this;
currentListItem.feed.load(
function(results) {
currentListItem.rawResults = results;
thisObj.loadComplete(currentListItem);
}
);
} else {
currentListItem.cacheCount++;
this.processResults(currentListItem);
}
}
GFtuneBar.prototype.populateStatusRoot = function() {
this.removeChildren(this.statusRoot);
this.statusBox = this.createDiv(null, this.CL_STATUSBOX);
this.statusRoot.appendChild(this.statusBox);
if ( this.executeList.length > 0) {
for (var i=0; i < this.executeList.length; i++ ) {
var listItem = this.executeList[i];
var displayTerm = listItem.map.name;
var div = this.createDiv(displayTerm, this.CL_STATUSITEM);
// add click handler...
div.onclick = this.methodClosure(this,
GFtuneBar.prototype.switchToListItem,
[i] );
listItem.node = div;
this.statusBox.appendChild(div);
this.statusBox.appendChild(document.createTextNode(" "));
}
}
}
/**
* Static Helper Method
*/
GFtuneBar.methodCallback = function(object, method) {
return function() {
return method.apply(object, arguments);
}
}
/**
* Class methods
*/
GFtuneBar.prototype.methodClosure = function(object, method, opt_argArray) {
return function() {
return method.apply(object, opt_argArray);
}
}
GFtuneBar.prototype.createDiv = function(opt_text, opt_className) {
var el = document.createElement("div");
if (opt_text) {
el.innerHTML = opt_text;
}
if (opt_className) { el.className = opt_className; }
return el;
}
GFtuneBar.prototype.removeChildren = function(parent) {
while (parent.firstChild) {
parent.removeChild(parent.firstChild);
}
}
GFtuneBar.prototype.removeChild = function(parent, child) {
parent.removeChild(child);
}
GFtuneBar.prototype.cssSetClass = function(el, className) {
el.className = className;
}
GFtuneBar.prototype.createTable = function(opt_className) {
var el = document.createElement("table");
if (opt_className) { el.className = opt_className; }
return el;
}
GFtuneBar.prototype.createTableRow = function(table, opt_className) {
var tr = table.insertRow(-1);
if (opt_className) { tr.className = opt_className; }
return tr;
}
GFtuneBar.prototype.createTableCell = function(tr, opt_className) {
var td = tr.insertCell(-1);
if (opt_className) { td.className = opt_className; }
return td;
}
GFtuneBar.prototype.createDivLink = function(href, text, opt_target, opt_className) {
var div = this.createDiv(null, opt_className);
var el = document.createElement("a");
el.href = href;
el.appendChild(document.createTextNode(text));
if (opt_className) {
el.className = opt_className;
}
if (opt_target) {
el.target = opt_target;
}
div.appendChild(el);
return div;
}
GFtuneBar.prototype.createClickLink = function(node, opt_href,
opt_className, opt_tooltip) {
var el = document.createElement("a");
if (opt_href) {
el.href = opt_href;
el.target = this.linkTarget;
} else {
el.href = "_nolink_";
}
el.appendChild(node);
if (opt_className) {
el.className = opt_className;
}
if (opt_tooltip) {
el.title = opt_tooltip;
}
return el;
}
GFtuneBar.prototype.createImage = function(src, opt_w, opt_h, opt_className) {
var el = document.createElement("img");
el.src = src;
if (opt_w) { el.width = opt_w; }
if (opt_h) { el.height = opt_h; }
if (opt_className) { el.className = opt_className; }
return el;
}
GFtuneBar.prototype.getNodeWidth = function(node) {
return node.offsetWidth;
}
GFtuneBar.prototype.br_AgentContains_ = function(str) {
if (str in this.br_AgentContains_cache_) {
return this.br_AgentContains_cache_[str];
}
return this.br_AgentContains_cache_[str] =
(navigator.userAgent.toLowerCase().indexOf(str) != -1);
}
GFtuneBar.prototype.br_IsIE = function() {
return this.br_AgentContains_('msie');
}
GFtuneBar.prototype.br_IsKonqueror = function() {
return this.br_AgentContains_('konqueror');
}
GFtuneBar.prototype.br_IsOpera = function() {
return this.br_AgentContains_('opera');
}
GFtuneBar.prototype.br_IsSafari = function() {
return this.br_AgentContains_('safari') || this.br_IsKonqueror();
}
GFtuneBar.prototype.br_IsNav = function() {
return !this.br_IsIE() &&
!this.br_IsSafari() &&
this.br_AgentContains_('mozilla');
}
GFtuneBar.prototype.br_IsWin = function() {
return this.br_AgentContains_('win');
}
?>