var country = ""; (function () { function NewsBox(container, opt_options) { this.linkTarget = google.search.Search.LINK_TARGET_BLANK; this.horizontalMode = true; this.successCount = 0; this.headerTitle = null; this.currentResult = null; // create the search object this.news = new google.search.NewsSearch(); this.news.setNoHtmlGeneration(); this.news.setSearchCompleteCallback(this, NewsBox.prototype.searchComplete, [null]); this.news.setResultSetSize(google.search.Search.LARGE_RESULTSET); if (opt_options) { if (opt_options.linkTarget) { this.linkTarget = opt_options.linkTarget; } } // now build out the containers if (typeof container == "string") { container = document.getElementById(container); } this.container = container; this.buildContainers(); } // expose the object window.NewsBox = NewsBox; NewsBox.prototype.loadNewsBox = function(query, title) { this.headerTitle = title; this.news.execute(query); } NewsBox.prototype.searchComplete = function() { this.clearResults(); if (this.news.results && this.news.results.length > 0) { this.header.innerHTML = this.headerTitle; if (this.successCount == 0) { google.search.Search.getBranding(this.footer); this.successCount++; } for (var i=0; i 1) { // grab the last location and use that, but only if there // is meat to the location? var lastLocation = ", " + locationArray[locationArray.length - 1]; div = this.createDiv(lastLocation, "nbx-location"); expando.appendChild(div); } // published date var pubDate = new Date(res.publishedDate); div = this.createDiv(" - " + this.news.formatToRelativeDate(pubDate), "nbx-date"); expando.appendChild(div); // snippet div = this.createDiv(null, "nbx-snippet-wrapper"); var span = this.createSpan(res.content, "nbx-snippet"); var moreLink = this.createLink(res.unescapedUrl, "MORE", this.linkTarget, "nbx-morelink", true); div.appendChild(span); div.appendChild(moreLink); expando.appendChild(div); this.results.appendChild(root); } NewsBox.prototype.twiddle = function(element) { var cl = element.className; if (cl.search(/nbx-minimized/) != -1) { // conditionally close the current item if (this.currentResult) { this.cssSetClass(this.currentResult, "nbx-result nbx-minimized"); } this.currentResult = element; this.cssSetClass(element, "nbx-result nbx-maximized"); } else { // the current result is being closed this.cssSetClass(element, "nbx-result nbx-minimized"); this.currentResult = null; } } /** * Build out the various containers... * *
* * 0..n * *