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

📄 nshelperappdlg.js

📁 从国外的站点上淘的个人财务管理系统.开源.
💻 JS
📖 第 1 页 / 共 3 页
字号:
        },        onStateChange: function( aWebProgress, aRequest, aStateFlags, aStatus ) {        },        onLocationChange: function( aWebProgress, aRequest, aLocation ) {        },        onSecurityChange: function( aWebProgress, aRequest, state ) {        }    },    // initDialog:  Fill various dialog fields with initial content.    initDialog : function() {      // Put file name in window title.      var suggestedFileName = this.mLauncher.suggestedFileName;      // Some URIs do not implement nsIURL, so we can't just QI.      var url   = this.mLauncher.source;      var fname = "";      this.mSourcePath = url.prePath;      try {          url = url.QueryInterface( Components.interfaces.nsIURL );          // A url, use file name from it.          fname = url.fileName;          this.mSourcePath += url.directory;      } catch (ex) {          // A generic uri, use path.          fname = url.path;          this.mSourcePath += url.path;      }      if (suggestedFileName)        fname = suggestedFileName;            var displayName = fname.replace(/ +/g, " ");      this.mTitle = this.dialogElement("strings").getFormattedString("title", [displayName]);      this.mDialog.document.title = this.mTitle;      // Put content type, filename and location into intro.      this.initIntro(url, fname, displayName);      var iconString = "moz-icon://" + fname + "?size=16&contentType=" + this.mLauncher.MIMEInfo.MIMEType;      this.dialogElement("contentTypeImage").setAttribute("src", iconString);      // if always-save and is-executable and no-handler      // then set up simple ui      var mimeType = this.mLauncher.MIMEInfo.MIMEType;      var shouldntRememberChoice = (mimeType == "application/octet-stream" ||                                     mimeType == "application/x-msdownload" ||                                    this.mLauncher.targetFile.isExecutable());      if (shouldntRememberChoice && !this.openWithDefaultOK()) {        // hide featured choice         this.mDialog.document.getElementById("normalBox").collapsed = true;        // show basic choice         this.mDialog.document.getElementById("basicBox").collapsed = false;        // change button labels        this.mDialog.document.documentElement.getButton("accept").label = this.dialogElement("strings").getString("unknownAccept.label");        this.mDialog.document.documentElement.getButton("cancel").label = this.dialogElement("strings").getString("unknownCancel.label");        // hide other handler        this.mDialog.document.getElementById("openHandler").collapsed = true;        // set save as the selected option        this.dialogElement("mode").selectedItem = this.dialogElement("save");      }      else {        this.initAppAndSaveToDiskValues();        // Initialize "always ask me" box. This should always be disabled        // and set to true for the ambiguous type application/octet-stream.        // We don't also check for application/x-msdownload here since we        // want users to be able to autodownload .exe files.         var rememberChoice = this.dialogElement("rememberChoice");//@line 471 "/c/builds/1813/mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in"        if (shouldntRememberChoice) {          rememberChoice.checked = false;          rememberChoice.disabled = true;        }        else {          rememberChoice.checked = !this.mLauncher.MIMEInfo.alwaysAskBeforeHandling;        }        this.toggleRememberChoice(rememberChoice);        // XXXben - menulist won't init properly, hack.         var openHandler = this.dialogElement("openHandler");        openHandler.parentNode.removeChild(openHandler);        var openHandlerBox = this.dialogElement("openHandlerBox");        openHandlerBox.appendChild(openHandler);      }      this.mDialog.setTimeout("dialog.postShowCallback()", 0);            this.mDialog.document.documentElement.getButton("accept").disabled = true;      const nsITimer = Components.interfaces.nsITimer;      this._timer = Components.classes["@mozilla.org/timer;1"]                              .createInstance(nsITimer);      this._timer.initWithCallback(this, 250, nsITimer.TYPE_ONE_SHOT);    },        _timer: null,    notify: function (aTimer) {      try { // The user may have already canceled the dialog.        if (!this._blurred)          this.mDialog.document.documentElement.getButton('accept').disabled = false;      } catch (ex) {}      this._delayExpired = true;      this._timer = null; // the timer won't release us, so we have to release it    },        postShowCallback: function () {      this.mDialog.sizeToContent();      // Set initial focus      this.dialogElement("mode").focus();    },    // initIntro:    initIntro: function(url, filename, displayname) {        this.dialogElement( "location" ).value = displayname;        this.dialogElement( "location" ).setAttribute("realname", filename);        this.dialogElement( "location" ).setAttribute("tooltiptext", displayname);        // if mSourcePath is a local file, then let's use the pretty path name instead of an ugly        // url...        var pathString = this.mSourcePath;        try         {          var fileURL = url.QueryInterface(Components.interfaces.nsIFileURL);          if (fileURL)          {            var fileObject = fileURL.file;            if (fileObject)            {              var parentObject = fileObject.parent;              if (parentObject)              {                pathString = parentObject.path;              }            }          }        } catch(ex) {}        if (pathString == this.mSourcePath)        {          // wasn't a fileURL          var tmpurl = url.clone(); // don't want to change the real url          try {            tmpurl.userPass = "";          } catch (ex) {}          pathString = tmpurl.prePath;        }        // Set the location text, which is separate from the intro text so it can be cropped        var location = this.dialogElement( "source" );        location.value = pathString;        location.setAttribute("tooltiptext", this.mSourcePath);                // Show the type of file.         var type = this.dialogElement("type");        var mimeInfo = this.mLauncher.MIMEInfo;                // 1. Try to use the pretty description of the type, if one is available.        var typeString = mimeInfo.description;                if (typeString == "") {          // 2. If there is none, use the extension to identify the file, e.g. "ZIP file"          var primaryExtension = "";          try {            primaryExtension = mimeInfo.primaryExtension;          }          catch (ex) {          }          if (primaryExtension != "")            typeString = primaryExtension.toUpperCase() + " file";          // 3. If we can't even do that, just give up and show the MIME type.           else            typeString = mimeInfo.MIMEType;        }                type.value = typeString;    },        _blurred: false,    _delayExpired: false,     onBlur: function(aEvent) {      if (aEvent.target != this.mDialog.document)        return;      this._blurred = true;      this.mDialog.document.documentElement.getButton("accept").disabled = true;    },        onFocus: function(aEvent) {      if (aEvent.target != this.mDialog.document)        return;      this._blurred = false;      if (this._delayExpired) {        var script = "document.documentElement.getButton('accept').disabled = false";        this.mDialog.setTimeout(script, 250);      }    },    // Returns true if opening the default application makes sense.    openWithDefaultOK: function() {        var result;        // The checking is different on Windows...//@line 604 "/c/builds/1813/mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in"        // Windows presents some special cases.        // We need to prevent use of "system default" when the file is        // executable (so the user doesn't launch nasty programs downloaded        // from the web), and, enable use of "system default" if it isn't        // executable (because we will prompt the user for the default app        // in that case).                // Need to get temporary file and check for executable-ness.        var tmpFile = this.mLauncher.targetFile;                //  Default is Ok if the file isn't executable (and vice-versa).        return !tmpFile.isExecutable();//@line 622 "/c/builds/1813/mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in"    },        // Set "default" application description field.    initDefaultApp: function() {      // Use description, if we can get one.      var desc = this.mLauncher.MIMEInfo.defaultDescription;      if (desc) {        var defaultApp = this.dialogElement("strings").getFormattedString("defaultApp", [desc]);        this.dialogElement("defaultHandler").label = defaultApp;      }      else {        this.dialogElement("modeDeck").setAttribute("selectedIndex", "1");        // Hide the default handler item too, in case the user picks a         // custom handler at a later date which triggers the menulist to show.        this.dialogElement("defaultHandler").hidden = true;      }    },    // getPath:    getPath: function (aFile) {//@line 645 "/c/builds/1813/mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in"      return aFile.path;//@line 647 "/c/builds/1813/mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in"    },    // initAppAndSaveToDiskValues:    initAppAndSaveToDiskValues: function() {      var modeGroup = this.dialogElement("mode");      // We don't let users open .exe files or random binary data directly       // from the browser at the moment because of security concerns.       var openWithDefaultOK = this.openWithDefaultOK();      var mimeType = this.mLauncher.MIMEInfo.MIMEType;      if (this.mLauncher.targetFile.isExecutable() || (          (mimeType == "application/octet-stream" ||           mimeType == "application/x-msdownload") &&            !openWithDefaultOK)) {        this.dialogElement("open").disabled = true;        var openHandler = this.dialogElement("openHandler");        openHandler.disabled = true;        openHandler.selectedItem = null;        modeGroup.selectedItem = this.dialogElement("save");        return;      }          // Fill in helper app info, if there is any.      this.chosenApp = this.mLauncher.MIMEInfo.preferredApplicationHandler;      // Initialize "default application" field.      this.initDefaultApp();      var otherHandler = this.dialogElement("otherHandler");                    // Fill application name textbox.      if (this.chosenApp && this.chosenApp.path) {        otherHandler.setAttribute("path", this.getPath(this.chosenApp));        otherHandler.label = this.chosenApp.leafName;        otherHandler.hidden = false;      }      var useDefault = this.dialogElement("useSystemDefault");      var openHandler = this.dialogElement("openHandler");      openHandler.selectedIndex = 0;      if (this.mLauncher.MIMEInfo.preferredAction == this.nsIMIMEInfo.useSystemDefault) {        // Open (using system default).        modeGroup.selectedItem = this.dialogElement("open");      } else if (this.mLauncher.MIMEInfo.preferredAction == this.nsIMIMEInfo.useHelperApp) {        // Open with given helper app.        modeGroup.selectedItem = this.dialogElement("open");        openHandler.selectedIndex = 1;      } else {        // Save to disk.        modeGroup.selectedItem = this.dialogElement("save");      }            // If we don't have a "default app" then disable that choice.      if (!openWithDefaultOK) {        var useDefault = this.dialogElement("defaultHandler");        var isSelected = useDefault.selected;                // Disable that choice.        useDefault.hidden = true;        // If that's the default, then switch to "save to disk."        if (isSelected) {          openHandler.selectedIndex = 1;          modeGroup.selectedItem = this.dialogElement("save");        }      }            // otherHandler is always disabled on Mac//@line 718 "/c/builds/1813/mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in"      otherHandler.nextSibling.hidden = otherHandler.nextSibling.nextSibling.hidden = false;//@line 720 "/c/builds/1813/mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in"      this.updateOKButton();    },    // Returns the user-selected application    helperAppChoice: function() {      return this.chosenApp;    },        get saveToDisk() {      return this.dialogElement("save").selected;    },        get useOtherHandler() {

⌨️ 快捷键说明

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