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

📄 nssidebar.js

📁 firefox的html解析器 本程序实现了想数据库中添加多媒体文件和文件说明
💻 JS
📖 第 1 页 / 共 2 页
字号:
                           this.rdf.GetLiteral("true"),                           true);    this.datasource.Unassert(this.rdf.GetResource(this.resource),                             this.rdf.GetResource(this.nc + "refresh"),                             this.rdf.GetLiteral("true"));    /* Write the modified panels out. */    this.datasource.QueryInterface(nsIRDFRemoteDataSource).Flush();}/* decorate prototype to provide ``class'' methods and property accessors */nsSidebar.prototype.addSearchEngine =function (engineURL, iconURL, suggestedTitle, suggestedCategory){    debug("addSearchEngine(" + engineURL + ", " + iconURL + ", " +          suggestedCategory + ", " + suggestedTitle + ")");    try    {        // make sure using HTTP or HTTPS and refering to a .src file        // for the engine.        if (! /^https?:\/\/.+\.src$/i.test(engineURL))            throw "Unsupported search engine URL";        // make sure using HTTP or HTTPS and refering to a        // .gif/.jpg/.jpeg/.png file for the icon.        if (! /^https?:\/\/.+\.(gif|jpg|jpeg|png)$/i.test(iconURL))            throw "Unsupported search icon URL";    }    catch(ex)    {        debug(ex);        this.promptService.alert(null, "Error", "Failed to add the search engine.");        throw Components.results.NS_ERROR_INVALID_ARG;    }    var titleMessage, dialogMessage;    try {        var stringBundle = srGetStrBundle("chrome://communicator/locale/sidebar/sidebar.properties");        var brandStringBundle = srGetStrBundle("chrome://branding/locale/brand.properties");        if (stringBundle) {            sidebarName = brandStringBundle.GetStringFromName("sidebarName");            titleMessage = stringBundle.GetStringFromName("addEngineConfirmTitle");            dialogMessage = stringBundle.GetStringFromName("addEngineConfirmMessage");            dialogMessage = dialogMessage.replace(/%title%/, suggestedTitle);            dialogMessage = dialogMessage.replace(/%category%/, suggestedCategory);            dialogMessage = dialogMessage.replace(/%url%/, engineURL);            dialogMessage = dialogMessage.replace(/#/g, "\n");            dialogMessage = dialogMessage.replace(/%name%/, sidebarName);        }    }    catch (e) {        titleMessage = "Add Search Engine";        dialogMessage = "Add the following search engine?\n\nName: " + suggestedTitle;        dialogMessage += "\nSearch Category: " + suggestedCategory;        dialogMessage += "\nSource: " + engineURL;    }    var rv = this.promptService.confirm(null, titleMessage, dialogMessage);    if (!rv)        return;    var internetSearch = Components.classes[NETSEARCH_CONTRACTID].getService();    if (internetSearch)        internetSearch = internetSearch.QueryInterface(nsIInternetSearchService);    if (internetSearch)    {        internetSearch.AddSearchEngine(engineURL, iconURL, suggestedTitle,                                       suggestedCategory);    }}// property of nsIClassInfonsSidebar.prototype.flags = nsIClassInfo.DOM_OBJECT;// property of nsIClassInfonsSidebar.prototype.classDescription = "Sidebar";// method of nsIClassInfonsSidebar.prototype.getInterfaces = function(count) {    var interfaceList = [nsISidebar, nsIClassInfo];    count.value = interfaceList.length;    return interfaceList;}// method of nsIClassInfonsSidebar.prototype.getHelperForLanguage = function(count) {return null;}nsSidebar.prototype.QueryInterface =function (iid) {    if (iid.equals(nsISidebar) ||        iid.equals(nsIClassInfo) ||        iid.equals(nsISupports))        return this;    Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE;    return null;}var sidebarModule = new Object();sidebarModule.registerSelf =function (compMgr, fileSpec, location, type){    debug("registering (all right -- a JavaScript module!)");    compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);    compMgr.registerFactoryLocation(SIDEBAR_CID,                                    "Sidebar JS Component",                                    SIDEBAR_CONTRACTID,                                    fileSpec,                                    location,                                    type);    const CATMAN_CONTRACTID = "@mozilla.org/categorymanager;1";    const nsICategoryManager = Components.interfaces.nsICategoryManager;    var catman = Components.classes[CATMAN_CONTRACTID].                            getService(nsICategoryManager);    const JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY = "JavaScript global property";    catman.addCategoryEntry(JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY,                            "sidebar",                            SIDEBAR_CONTRACTID,                            true,                            true);}sidebarModule.getClassObject =function (compMgr, cid, iid) {    if (!cid.equals(SIDEBAR_CID))        throw Components.results.NS_ERROR_NO_INTERFACE;    if (!iid.equals(Components.interfaces.nsIFactory))        throw Components.results.NS_ERROR_NOT_IMPLEMENTED;    return sidebarFactory;}sidebarModule.canUnload =function(compMgr){    debug("Unloading component.");    return true;}/* factory object */var sidebarFactory = new Object();sidebarFactory.createInstance =function (outer, iid) {    debug("CI: " + iid);    if (outer != null)        throw Components.results.NS_ERROR_NO_AGGREGATION;    return (new nsSidebar()).QueryInterface(iid);}/* entrypoint */function NSGetModule(compMgr, fileSpec) {    return sidebarModule;}/* static functions */if (DEBUG)    debug = function (s) { dump("-*- sidebar component: " + s + "\n"); }else    debug = function (s) {}function getSidebarDatasourceURI(panels_file_id){    try    {        /* use the fileLocator to look in the profile directory         * to find 'panels.rdf', which is the         * database of the user's currently selected panels. */        var directory_service = Components.classes[DIR_SERV_CONTRACTID].getService(Components.interfaces.nsIProperties);        /* if <profile>/panels.rdf doesn't exist, get will copy         *bin/defaults/profile/panels.rdf to <profile>/panels.rdf */        var sidebar_file = directory_service.get(panels_file_id, Components.interfaces.nsIFile);        if (!sidebar_file.exists())        {            /* this should not happen, as GetFileLocation() should copy             * defaults/panels.rdf to the users profile directory */            debug("sidebar file does not exist");            return null;        }        var io_service = Components.classes[IO_SERV_CONTRACTID].getService(Components.interfaces.nsIIOService);        var file_handler = io_service.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);        var sidebar_uri = file_handler.getURLSpecFromFile(sidebar_file);        debug("sidebar uri is " + sidebar_uri);        return sidebar_uri;    }    catch (ex)    {        /* this should not happen */        debug("caught " + ex + " getting sidebar datasource uri");        return null;    }}var strBundleService = null;function srGetStrBundle(path){   var strBundle = null;   if (!strBundleService) {       try {          strBundleService =          Components.classes["@mozilla.org/intl/stringbundle;1"].getService();          strBundleService =          strBundleService.QueryInterface(Components.interfaces.nsIStringBundleService);       } catch (ex) {          dump("\n--** strBundleService failed: " + ex + "\n");          return null;      }   }   strBundle = strBundleService.createBundle(path);   if (!strBundle) {       dump("\n--** strBundle createInstance failed **--\n");   }   return strBundle;}

⌨️ 快捷键说明

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