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

📄 feeditem.js

📁 现在很火的邮件客户端软件thunderbird的源码
💻 JS
📖 第 1 页 / 共 2 页
字号:
# -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-# ***** BEGIN LICENSE BLOCK *****# Version: MPL 1.1/GPL 2.0/LGPL 2.1## The contents of this file are subject to the Mozilla Public License Version# 1.1 (the "License"); you may not use this file except in compliance with# the License. You may obtain a copy of the License at# http://www.mozilla.org/MPL/## Software distributed under the License is distributed on an "AS IS" basis,# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License# for the specific language governing rights and limitations under the# License.## The Original Code is an RSS Feed Item## The Initial Developer of the Original Code is# The Mozilla Foundation.# Portions created by the Initial Developer are Copyright (C) 2004# the Initial Developer. All Rights Reserved.## Contributor(s):## Alternatively, the contents of this file may be used under the terms of# either the GNU General Public License Version 2 or later (the "GPL"), or# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),# in which case the provisions of the GPL or the LGPL are applicable instead# of those above. If you wish to allow use of your version of this file only# under the terms of either the GPL or the LGPL, and not to allow others to# use your version of this file under the terms of the MPL, indicate your# decision by deleting the provisions above and replace them with the notice# and other provisions required by the GPL or the LGPL. If you do not delete# the provisions above, a recipient may use your version of this file under# the terms of any one of the MPL, the GPL or the LGPL.## ***** END LICENSE BLOCK ***** */// Handy conversion values.const HOURS_TO_MINUTES = 60;const MINUTES_TO_SECONDS = 60;const SECONDS_TO_MILLISECONDS = 1000;const MINUTES_TO_MILLISECONDS = MINUTES_TO_SECONDS * SECONDS_TO_MILLISECONDS;const HOURS_TO_MILLISECONDS = HOURS_TO_MINUTES * MINUTES_TO_MILLISECONDS;const MSG_FLAG_NEW      = 0x10000;const ENCLOSURE_BOUNDARY_PREFIX = "--------------";  // 14 dashesconst ENCLOSURE_HEADER_BOUNDARY_PREFIX = "------------"; // 12 dashesconst MESSAGE_TEMPLATE = "\n\<html>\n\  <head>\n\    <title>%TITLE%</title>\n\    <base href=\"%BASE%\">\n\    <style type=\"text/css\">\n\      %STYLE%\n\    </style>\n\  </head>\n\  <body>\n\    %CONTENT_TEMPLATE%\n\  </body>\n\</html>\n\";const REMOTE_CONTENT_TEMPLATE = "\n\    <iframe id =\"_mailrssiframe\" src=\"%URL%\">\n\      %DESCRIPTION%\n\    </iframe>\n\";const REMOTE_STYLE = "\n\      body {\n\        margin: 0;\n\        border: none;\n\        padding: 0;\n\      }\n\      iframe {\n\        position: fixed;\n\        top: 0;\n\        left: 0;\n\        width: 100%;\n\        height: 100%;\n\        border: none;\n\      }\n\";// Unlike remote content, which is locked within a fixed position iframe,// local content goes is positioned according to the normal rules of flow.// The problem with this is that the message pane itself provides a scrollbar// if necessary, and that scrollbar appears next to the toolbar as well as// the content being scrolled.  The solution is to lock local content within// a fixed position div and set its overflow property to auto so that the div// itself provides the scrollbar.  Unfortunately we can't do that because of// Mozilla bug 97283, which makes it hard to scroll an auto overflow div.const LOCAL_CONTENT_TEMPLATE = "\n\      %CONTENT%\n\";// no local style overrides at this timeconst LOCAL_STYLE = "\n";function FeedItem() {  this.mDate = new Date().toString();  this.mUnicodeConverter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]                          .createInstance(Components.interfaces.nsIScriptableUnicodeConverter);}FeedItem.prototype = {  isStoredWithId: false, // we currently only do this for IETF Atom. RSS2 with GUIDs should do this as well.  xmlContentBase: null, // only for IETF Atom  id: null,  feed: null,  description: null,  content: null,  enclosure: null,  // we currently only support one enclosure per feed item...  title: "(no subject)",  // TO DO: this needs to be localized  author: "anonymous",  mURL: null,  characterSet: "",  get url()  {    return this.mURL;  },  set url(aVal)  {    var uri = Components.classes["@mozilla.org/network/standard-url;1"].getService(Components.interfaces["nsIStandardURL"]);    uri.init(1, 80, aVal, null, null);    var uri = uri.QueryInterface(Components.interfaces.nsIURI);    this.mURL = uri.spec;  },  get date()  {    return this.mDate;  },  set date (aVal)  {    this.mDate = aVal;  },  get identity ()  {    return this.feed.name + ": " + this.title + " (" + this.id + ")"  },  get messageID()  {    var messageID = this.id || this.mURL || this.title;    // Escape occurrences of message ID meta characters <, >, and @.    messageID.replace(/</g, "%3C");    messageID.replace(/>/g, "%3E");    messageID.replace(/@/g, "%40");    messageID = messageID + "@" + "localhost.localdomain";    return messageID;  },  get itemUniqueURI()  {    var theURI;    if(this.isStoredWithId && this.id)      theURI = "urn:" + this.id;    else      theURI = this.mURL || ("urn:" + this.id);    return theURI;  },  get contentBase()  {    if(this.xmlContentBase)      return this.xmlContentBase    else      return this.mURL;  },  store: function()   {    this.mUnicodeConverter.charset = this.characterSet;    if (this.isStored())       debug(this.identity + " already stored; ignoring");    else if (this.content)     {      debug(this.identity + " has content; storing");      var content = MESSAGE_TEMPLATE;      content = content.replace(/%CONTENT_TEMPLATE%/, LOCAL_CONTENT_TEMPLATE);      content = content.replace(/%STYLE%/, LOCAL_STYLE);      content = content.replace(/%TITLE%/, this.title);      content = content.replace(/%BASE%/, this.contentBase);       content = content.replace(/%URL%/g, this.mURL);      content = content.replace(/%CONTENT%/, this.content);      this.content = content; // XXX store it elsewhere, f.e. this.page      this.writeToFolder();    }    else if (this.feed.quickMode)     {      debug(this.identity + " in quick mode; storing");      this.content = this.description || this.title;      var content = MESSAGE_TEMPLATE;      content = content.replace(/%CONTENT_TEMPLATE%/, LOCAL_CONTENT_TEMPLATE);      content = content.replace(/%STYLE%/, LOCAL_STYLE);      content = content.replace(/%BASE%/, this.contentBase);       content = content.replace(/%TITLE%/, this.title);      content = content.replace(/%URL%/g, this.mURL);      content = content.replace(/%CONTENT%/, this.content);      this.content = content; // XXX store it elsewhere, f.e. this.page      this.writeToFolder();    }     else     {      //debug(this.identity + " needs content; downloading");      debug(this.identity + " needs content; creating and storing");      var content = MESSAGE_TEMPLATE;      content = content.replace(/%CONTENT_TEMPLATE%/, REMOTE_CONTENT_TEMPLATE);      content = content.replace(/%STYLE%/, REMOTE_STYLE);      content = content.replace(/%TITLE%/, this.title);      content = content.replace(/%BASE%/, this.contentBase);       content = content.replace(/%URL%/g, this.mURL);      content = content.replace(/%DESCRIPTION%/, this.description || this.title);      this.content = content; // XXX store it elsewhere, f.e. this.page      this.writeToFolder();    }  },  isStored: function()  {    // Checks to see if the item has already been stored in its feed's message folder.    debug(this.identity + " checking to see if stored");    var server = this.feed.server;    var folder = this.feed.folder;    if (!folder)     {      debug(this.feed.name + " folder doesn't exist; creating");		  debug("creating " + this.feed.name + "as child of " + server.rootMsgFolder + "\n");      server.rootMsgFolder.createSubfolder(this.feed.name, null /* supposed to be a msg window */);      folder = server.rootMsgFolder.FindSubFolder(this.feed.name);

⌨️ 快捷键说明

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