⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gsnewsbar.js

📁 关于java web开发动态网页的资料
💻 JS
📖 第 1 页 / 共 3 页
字号:
  this.CL_STATUSBOXROOT = "statusBoxRoot_gsnb";  this.CL_STATUSBOX = "statusBox_gsnb";  this.CL_STATUSBOX_ONEITEM = "statusBox_gsnb oneitem_gsnb";  this.CL_STATUSITEMSEP = "statusItemSep_gsnb";  this.CL_STATUSITEM = "statusItem_gsnb";  this.CL_STATUSITEM_SELECTED = "statusItem_gsnb statusItemSelected_gsnb";}GSnewsBar.prototype.getBarBoxClass = function(full) {  var baseClass = full ? this.CL_NEWSBARBOXFULL : this.CL_NEWSBARBOXEMPTY;  if (this.verticalMode) {    baseClass += " " + this.CL_VERTICAL;  } else {    baseClass += " " + this.CL_HORIZONTAL;  }  return baseClass;}GSnewsBar.prototype.buildSuperStructure = function() {  // create the newsBar box  this.removeChildren(this.barRoot);  this.barBox = this.createDiv(null, this.CL_NEWSBARBOX);  this.barRoot.appendChild(this.barBox);  this.innerBox = this.createDiv(null, this.CL_NEWSBARINNERBOX);  this.barBox.appendChild(this.innerBox);  // add in the title, statusBox, resultsBox, and branding  // title  this.titleBox = this.createDiv(this.ST_TITLE, this.CL_TITLEBOX);  this.innerBox.appendChild(this.titleBox);  // optional statusRoot, statusBox  if (this.statusRoot == null) {    this.statusRoot = this.createDiv(null, this.CL_STATUSBOXROOT);    this.innerBox.appendChild(this.statusRoot);  }  this.populateStatusRoot();  // resultsBox  this.resultsBox = this.createDiv(null, this.resultsBoxClass);  this.innerBox.appendChild(this.resultsBox);  if (this.currentResultRoot) {    this.currentResultContainer = this.createDiv(null,                                                 this.CL_RESULTSBOX_EXPANDED);    this.currentResultRoot.appendChild(this.currentResultContainer);  }  // branding  var branding = this.createDiv(null, this.CL_BRANDINGBOX);  this.barBox.appendChild(branding);  var orientation = GSearch.HORIZONTAL_BRANDING;  if (this.verticalMode == false) {    orientation = GSearch.VERTICAL_BRANDING;  }  GSearch.getBranding(branding, orientation);  this.cssSetClass(this.barBox, this.CL_NEWSBARBOXEMPTY);}GSnewsBar.prototype.buildSearchControl = function() {  this.ns = new GnewsSearch();  this.ns.setResultSetSize(this.resultSetSize);  this.ns.setLinkTarget(this.linkTarget);  this.ns.setSearchCompleteCallback(this, GSnewsBar.prototype.searchComplete, [true]);  this.nsBypass = new GnewsSearch();  this.nsBypass.setResultSetSize(this.resultSetSize);  this.nsBypass.setLinkTarget(this.linkTarget);  this.nsBypass.setSearchCompleteCallback(this, GSnewsBar.prototype.searchComplete, [false]);}GSnewsBar.prototype.execute = function(query) {  if (this.verticalMode == false) {    this.clearFadeTimer();    this.resetAutoExecuteListItems([query]);  } else {    this.populateStatusRoot();    this.nsBypass.execute(query);  }}GSnewsBar.prototype.executeInternal = function(query) {  this.ns.execute(query);}GSnewsBar.prototype.clearAllResults = function() {  this.cssSetClass(this.barBox, this.CL_NEWSBARBOXEMPTY);}GSnewsBar.prototype.searchComplete = function(fromListItem) {  var ns;  var cacheResults = false;  var currentListItem = null;  if (fromListItem) {    currentListItem = this.executeList[this.currentIndex];    if (currentListItem.cacheCount == 0) {      cacheResults = true;      currentListItem.results = new Array();    }    ns = this.ns;  } else {    ns = this.nsBypass;  }  if ( ns.results && ns.results.length > 0) {    this.cssSetClass(this.barBox, this.getBarBoxClass(true));    this.removeChildren(this.resultsBox);    if (!this.verticalMode) {      // for horizontal mode, nuke the old results      // and reset currentResultIndex      this.results = new Array();      this.currentResult = 0;    }    // iterate over the results and capture the .html node    // and append into the resultBox, OR just capture so that    // we can fade it in/out    for (var i = 0; i < ns.results.length; i++) {      // if we are listItem based search, then cache results      if (cacheResults) {        currentListItem.cacheCount = 1;        currentListItem.results.push(GSnewsBar.cloneObject(ns.results[i]));        // reset error count based on sucessful search        currentListItem.errorCount = 0;      }      var res = ns.results[i];      if (this.verticalMode) {        var resultDiv = this.createDiv(null, this.CL_RESULTDIV);        var node = res.html.cloneNode(true);        this.resultsBox.appendChild(resultDiv);        resultDiv.appendChild(node);      } else {        this.results[i] = res;      }    }    // start the fadein, fadeout sequence    if (!this.verticalMode) {      this.linkContainer = this.createDiv(null, this.linkContainerClass);      this.resultsBox.appendChild(this.linkContainer);      this.link = document.createElement("a");      this.link.target = this.linkTarget;      this.snippet = this.createSpan("&nbsp;", this.CL_SNIPPET);      this.setHorizontalResultContent(                        this.results[this.currentResult]);      this.setOpacity(this.linkContainer, 0);      this.linkContainer.appendChild(this.snippet);      this.linkContainer.appendChild(this.link);      this.fadeOpacity = 0;      this.fadeIn();    }  } else {    // no results, mark the container as empty    this.cssSetClass(this.barBox, this.getBarBoxClass(true));    // retry another search expression    if ( this.executeList.length == 1 ||         this.cycleTime == GSnewsBar.CYCLE_TIME_MANUAL ) {      if (this.retries > 1) {        // we failed the default query. Don't let this get caught        // in a failure loop        if (this.testForDefaultQuery()) {          // stop the timers...          this.clearCycleTimer();          this.clearFadeTimer();          // clear the status area          if (this.statusRoot) {            this.removeChildren(this.statusRoot);          }          return;        } else {          this.resetAutoExecuteListItems([GSnewsBar.DEFAULT_QUERY]);          this.retries = 0;        }      } else {        this.totalFailures++;        this.retries++;      }      this.switchToListItem(0);    } else {      // this really means that this is a list item based search      // that should have worked and if it had worked would have      // produced results that we cache. in this case though, we      // got no results so mark this, and if we get too many on      // this term, throw away the search term      if (cacheResults) {        this.totalFailures++;        currentListItem.errorCount++;        // if we are getting excessive errors from this entry        // then reset the list without this entry        if (ns.completionStatus == 200) {          currentListItem.errorCount = GSnewsBar.MAX_ERROR_COUNT + 1;        }        if (currentListItem.errorCount > GSnewsBar.MAX_ERROR_COUNT) {          var newList = new Array();          for (var i=0; i<this.executeList.length; i++) {            if (this.executeList[i].errorCount <= GSnewsBar.MAX_ERROR_COUNT) {              newList.push(this.executeList[i].query);            }          }          if (newList.length == 0) {            newList.push(GSnewsBar.DEFAULT_QUERY);          }          this.resetAutoExecuteListItems(newList);        }      }      this.cycleTimeout();    }  }}GSnewsBar.prototype.setHorizontalResultContent = function(result) {  var url = result.unescapedUrl;  var linkString = result.titleNoFormatting;  var snippet = result.publisher + "&nbsp;-&nbsp; ";  this.link.href = url;  this.link.innerHTML = linkString;  this.snippet.innerHTML = snippet;  if (this.currentResultContainer) {    this.removeChildren(this.currentResultContainer);    var div = this.createDiv(null, this.CL_RESULTDIV);    var node = result.html.cloneNode(true);    div.appendChild(node);    this.currentResultContainer.appendChild(div);  }}GSnewsBar.prototype.clearCycleTimer = function() {  if (this.cycleTimer) {    clearTimeout(this.cycleTimer);    this.cycleTimer = null;  }}GSnewsBar.prototype.clearFadeTimer = function() {  if (this.fadeTimer) {    clearTimeout(this.fadeTimer);    this.fadeTimer = null;  }}GSnewsBar.prototype.setMouseIn = function() {  this.mouseInResultArea = true;}GSnewsBar.prototype.setMouseOut = function() {  this.mouseInResultArea = false;  if (this.mouseOutCallFade) {    this.fadeOut();  }}GSnewsBar.prototype.cycleTimeout = function() {  // select a new news topic  // execute a search  // restart the timer  if ( this.executeList.length == 1 ||       this.cycleTime == GSnewsBar.CYCLE_TIME_MANUAL ) {    this.switchToListItem(0);  } else {    var index = 0;    if (this.cycleMode == GSnewsBar.CYCLE_MODE_RANDOM) {      var max = this.executeList.length - 1;      index = Math.round(max * Math.random());    } else if (this.cycleMode == GSnewsBar.CYCLE_MODE_LINEAR){      index = this.cycleNext;      this.cycleNext++;      if (this.cycleNext >= this.executeList.length) {        this.cycleNext = 0;      }    }    this.switchToListItem(index);    if (this.verticalMode) {      this.clearCycleTimer();      this.cycleTimer = setTimeout(this.cycleTimeClosure, this.cycleTime);    }  }}GSnewsBar.prototype.fadeIn = function() {  if (this.ieMode) {    // IE is very broken on the fade in/out    // it ends up failing miserably on IE6 with cleartype on (well documented)    // and on IE7, ends up turning off font-smoothing. So, on IE we do not    // do the fade effect.    this.fadeTimer = setTimeout(this.fadeOutCallback, this.cycleTime);  } else {    this.fadeOpacity = Math.min(this.fadeOpacity + this.fadeIncrement /                                 this.fadeTime, 1);    var fadeOpacity = this.fadeOpacity;    // this trick prevents shifting on firefox/windows    if (fadeOpacity >= 1 && this.shortOpacityMode) {      fadeOpacity = 0.9999999;    }    this.setOpacity(this.linkContainer, fadeOpacity);    if (this.fadeOpacity < 1) {      this.fadeTimer = setTimeout(this.fadeInCallback, this.fadeIncrement);    } else {      this.fadeTimer = setTimeout(this.fadeOutCallback, this.cycleTime);    }  }}GSnewsBar.prototype.fadeOut = function() {  if (this.mouseInResultArea) {    this.mouseOutCallFade = true;    return;  }  // see above  if (this.ieMode) {    this.fadeOpacity = 0;  } else {    this.mouseOutCallFade = false;    this.fadeOpacity = Math.max(this.fadeOpacity - this.fadeIncrement /                                 this.fadeTime, 0);    this.setOpacity(this.linkContainer, this.fadeOpacity);    if (this.fadeOpacity > 1) {      this.fadeOpacity = 1;    }  }  if (this.fadeOpacity > 0) {    this.fadeTimer = window.setTimeout(this.fadeOutCallback, this.fadeIncrement);  } else {    if (this.currentResult+1 < this.results.length) {      this.currentResult++;      this.setHorizontalResultContent(this.results[this.currentResult]);      this.fadeIn();    } else {      this.cycleTimeout();    }  }}/** * Autoexecute List Item Support*/GSnewsBar.prototype.newListItem = function(q) {  var listItem = new Object();  listItem.node = null;  listItem.query = q;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -