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

📄 gsnewsbar.js

📁 关于java web开发动态网页的资料
💻 JS
📖 第 1 页 / 共 3 页
字号:
function GSnewsBar(barRoot, options) {  // IE fadein/fadeout is disabled  // On IE6, when clear type is enabled, you MUST set a background color on  // the element being tweaked. This is totally impractical. If you dont do this  // the fonts look terrible/unreadable  //  // On IE7, they "fixed" the bug, but they did it by disable font smoothing so  // once again, the results are terrible. Fix is to just don't do this on IE  this.br_AgentContains_cache_ = {};  if (this.br_IsIE()) {    this.startupDelay = 50;    this.ieMode = true;  } else {    this.startupDelay = 0;    this.ieMode = false;  }  this.CL_RESULTDIV = "resultDiv_gsnb";  this.CL_RESULTDIV_BOLD = "resultDiv_gsnb resultDivBold_gsnb";  // FF on win/mac has an interesting issue as well. As soon as opacity hits  // 100%, the font size seems to change by a pixel or so for many fonts.  // net result: visible jiggle. The "fix" is to never let ffwin/mac hit 100%...  this.linkContainerClass = this.CL_RESULTDIV;  if (this.br_IsNav() && (this.br_IsWin() || this.br_IsMac()) ) {    if (this.br_IsMac()) {      this.linkContainerClass = this.CL_RESULTDIV_BOLD;    }    this.shortOpacityMode = true;  } else {    this.shortOpacityMode = false;  }  this.setGlobals();  this.processArguments(barRoot, options);  this.adjustGlobals();  this.buildSuperStructure();  this.buildSearchControl();  // build handlers for mousein/mouseout watchers  // on this.resultsBox  if ( !this.verticalMode ) {    this.resultsBox.onmouseover = this.methodClosure(this,                                            GSnewsBar.prototype.setMouseIn,                                            [null]);    this.resultsBox.onmouseout = this.methodClosure(this,                                            GSnewsBar.prototype.setMouseOut,                                            [null]);    if (this.currentResultRoot) {      this.currentResultRoot.onmouseover = this.methodClosure(this,                                              GSnewsBar.prototype.setMouseIn,                                              [null]);      this.currentResultRoot.onmouseout = this.methodClosure(this,                                              GSnewsBar.prototype.setMouseOut,                                              [null]);    }  }  // ie does not like this mode, so defer load on IE  if (this.ieMode || this.startupDelay != 0) {    var bootCompleteClosure = this.methodClosure(this,                                                 GSnewsBar.prototype.bootComplete,                                                 [null]);    setTimeout(bootCompleteClosure, this.startupDelay);  } else {    this.bootComplete();  }}GSnewsBar.prototype.bootComplete = function() {  // if we have an auto execute list, then start it up  if (this.autoExecuteMode) {    this.cycleTimeClosure = this.methodClosure(this,                                               GSnewsBar.prototype.cycleTimeout,                                               [null]);    // if there is only a single item in the execute list, then    // disable autoExecuteMode...    if ( this.executeList.length == 1 ||         this.cycleTime == GSnewsBar.CYCLE_TIME_MANUAL ) {      this.switchToListItem(0);    } else {      this.cycleTimeout();    }  }}// cycle time for selecting a news setGSnewsBar.CYCLE_TIME_EXTRA_SHORT = 3000;GSnewsBar.CYCLE_TIME_SHORT = 10000;GSnewsBar.CYCLE_TIME_MEDIUM = 15000;GSnewsBar.CYCLE_TIME_LONG = 30000;GSnewsBar.CYCLE_TIME_MANUAL = 3000000;GSnewsBar.ONE_SECOND = 1000;GSnewsBar.THREE_SECONDS = 3000;GSnewsBar.FIVE_SECONDS = 5000;GSnewsBar.TEN_SECONDS = 10000;// cycle modeGSnewsBar.CYCLE_MODE_RANDOM = 1;GSnewsBar.CYCLE_MODE_LINEAR = 2;GSnewsBar.MAX_CACHE_LIFETIME = 50;GSnewsBar.MIN_CACHE_LIFETIME = 1;GSnewsBar.DEFAULT_CACHE_LIFETIME = 1;GSnewsBar.MAX_ERROR_COUNT = 1;GSnewsBar.DEFAULT_QUERY = "Google";GSnewsBar.MIN_STARTUP_DELAY = 50;GSnewsBar.MAX_STARTUP_DELAY = 2000;// result styleGSnewsBar.RESULT_STYLE_EXPANDED = 1;GSnewsBar.RESULT_STYLE_COMPRESSED = 2;GSnewsBar.prototype.processArguments = function(barRoot, opt_options) {  this.totalFailures = 0;  this.retries = 0;  this.barRoot = barRoot;  this.statusRoot = null;  this.autoExecuteMode = false;  this.executeList = new Array();  this.cycleTime = GSnewsBar.CYCLE_TIME_MANUAL;  this.cycleMode = GSnewsBar.CYCLE_MODE_LINEAR;  this.cycleNext = 0;  this.cycleTimer = null;  this.verticalMode = true;  this.fadeTimer = null;  this.mouseInResultArea = false;  this.mouseOutCallFade = false;  this.linkTarget = GSearch.LINK_TARGET_SELF;  this.currentResultRoot = null;  this.currentResultContainer = null;  this.cacheLifetime = GSnewsBar.DEFAULT_CACHE_LIFETIME;  this.fadeIncrement = 10;  this.fadeTime = 400;  this.fadeInCallback = GSnewsBar.methodCallback(this,                                                 GSnewsBar.prototype.fadeIn);  this.fadeOutCallback = GSnewsBar.methodCallback(this,                                                  GSnewsBar.prototype.fadeOut);  this.fadeOpacity = 0;  // set defaults that are changable via options  this.resultSetSize = GSearch.SMALL_RESULTSET;  this.ST_TITLE = "In the news";  this.resultsBoxClass = this.CL_RESULTSBOX_EXPANDED;  this.verticalMode = true;  if (opt_options) {    // horizontal    if (opt_options.horizontal && opt_options.horizontal == true ) {      this.verticalMode = false;    } else {      this.verticalMode = true;    }    // option.largetResultSet    if (opt_options.largeResultSet && opt_options.largeResultSet == true ) {      this.resultSetSize = GSearch.LARGE_RESULTSET;    } else {      this.resultSetSize = GSearch.SMALL_RESULTSET;    }    // option.resultStyle    if (opt_options.resultStyle) {      if (opt_options.resultStyle == GSnewsBar.RESULT_STYLE_EXPANDED) {        this.resultsBoxClass = this.CL_RESULTSBOX_EXPANDED;      } else if (opt_options.resultStyle == GSnewsBar.RESULT_STYLE_COMPRESSED) {        this.resultsBoxClass = this.CL_RESULTSBOX_COMPRESSED;      }    }    if (opt_options.linkTarget) {      this.linkTarget = opt_options.linkTarget;    }    // if currentResult is specified AND we are in horizontal mode,    // then pick it up.    if (opt_options.currentResult && !this.verticalMode) {      this.currentResultRoot = opt_options.currentResult;      this.removeChildren(this.currentResultRoot);    }    if (opt_options.title) {      this.ST_TITLE = opt_options.title;    }    // startupDelay    if (opt_options.startupDelay &&        opt_options.startupDelay >= GSnewsBar.MIN_STARTUP_DELAY &&        opt_options.startupDelay <= GSnewsBar.MAX_STARTUP_DELAY) {      this.startupDelay = opt_options.startupDelay;    }    // cacheLifetime    if (opt_options.cacheLifetime &&        opt_options.cacheLifetime >= GSnewsBar.MIN_CACHE_LIFETIME &&        opt_options.cacheLifetime <= GSnewsBar.MAX_CACHE_LIFETIME ) {      this.cacheLifetime = opt_options.cacheLifetime;    }    // the auto execute list contains    // 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 == GSnewsBar.CYCLE_TIME_EXTRA_SHORT ||            cycleTime == GSnewsBar.CYCLE_TIME_SHORT ||            cycleTime == GSnewsBar.CYCLE_TIME_MEDIUM ||            cycleTime == GSnewsBar.CYCLE_TIME_LONG ||            cycleTime == GSnewsBar.CYCLE_TIME_MANUAL ) {          this.cycleTime = cycleTime;        }      }      // in vertical mode, cycleTime says how long      // between new searches. In horizontal mode,      // it's how long to keep a result up      if (!this.verticalMode) {        switch (this.cycleTime) {        case GSnewsBar.CYCLE_TIME_EXTRA_SHORT:        case GSnewsBar.CYCLE_TIME_SHORT:          this.cycleTime = GSnewsBar.THREE_SECONDS;          break;        case GSnewsBar.CYCLE_TIME_MEDIUM:        case GSnewsBar.CYCLE_TIME_MANUAL:          this.cycleTime = GSnewsBar.FIVE_SECONDS;          break;        case GSnewsBar.CYCLE_TIME_LONG:          this.cycleTime = GSnewsBar.TEN_SECONDS;          break;        }        if (this.ieMode) {          // since we are not fading in/out, lengthen the cycleTime by 1s          this.cycleTime += GSnewsBar.ONE_SECOND;        }      }      if (opt_options.autoExecuteList.cycleMode) {        var cycleMode = opt_options.autoExecuteList.cycleMode;        if (cycleMode == GSnewsBar.CYCLE_MODE_RANDOM ||            cycleMode == GSnewsBar.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++) {          this.executeList.push(            this.newListItem(opt_options.autoExecuteList.executeList[i]));        }        this.autoExecuteMode = true;        this.currentIndex = 0;        if (opt_options.autoExecuteList.statusRoot) {          this.statusRoot = opt_options.autoExecuteList.statusRoot;        }      }    }    // horizontal mode MUST use autoExecute...    if (!this.verticalMode && this.autoExecuteMode == false) {      this.autoExecuteMode = true;      this.currentIndex = 0;      this.cycleTime = GSnewsBar.THREE_SECONDS;      this.executeList.push(this.newListItem(GSnewsBar.DEFAULT_QUERY));    }  }}GSnewsBar.prototype.testForDefaultQuery = function() {  if (this.executeList.length == 1 &&      this.executeList[0].query == GSnewsBar.DEFAULT_QUERY) {    return true;  } else {    return false;  }}GSnewsBar.prototype.resetAutoExecuteListItems = function(newList) {  if (this.autoExecuteMode && newList.length > 0) {    // stop the timers...    this.clearCycleTimer();    this.clearFadeTimer();    // 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();    }  }}GSnewsBar.prototype.adjustGlobals = function() {  // horizontal mode changes certain globals...  // - results are always compressed  if (this.verticalMode == false) {    this.resultsBoxClass = this.CL_RESULTSBOX_COMPRESSED;  }}GSnewsBar.prototype.setGlobals = function() {  // superstructure boxes  this.CL_NEWSBARBOX = "newsBarBox_gsnb";  this.CL_NEWSBARBOXFULL = "newsBarBox_gsnb full_gsnb";  this.CL_NEWSBARBOXEMPTY = "newsBarBox_gsnb empty_gsnb";  this.CL_NEWSBARINNERBOX = "newsBarInnerBox_gsnb";  this.CL_VERTICAL = "vertical_gsnb";  this.CL_HORIZONTAL = "horizontal_gsnb";  // title  this.CL_TITLEBOX = "titleBox_gsnb";  // results  this.CL_RESULTSBOX_EXPANDED = "resultsBox_gsnb expanded_gsnb";  this.CL_RESULTSBOX_COMPRESSED = "resultsBox_gsnb compressed_gsnb";  this.CL_BRANDINGBOX = "brandingBox_gsnb";  this.CL_SNIPPET = "snippet_gsnb";  // status

⌨️ 快捷键说明

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