timeline.js (1759B)
1 /* 2 ***** BEGIN LICENSE BLOCK ***** 3 4 Copyright © 2009 Center for History and New Media 5 George Mason University, Fairfax, Virginia, USA 6 http://zotero.org 7 8 This file is part of Zotero. 9 10 Zotero is free software: you can redistribute it and/or modify 11 it under the terms of the GNU Affero General Public License as published by 12 the Free Software Foundation, either version 3 of the License, or 13 (at your option) any later version. 14 15 Zotero is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU Affero General Public License for more details. 19 20 You should have received a copy of the GNU Affero General Public License 21 along with Zotero. If not, see <http://www.gnu.org/licenses/>. 22 23 ***** END LICENSE BLOCK ***** 24 */ 25 26 27 Zotero.Timeline = { 28 generateXMLDetails: function* (items, dateType) { 29 var escapeXML = Zotero.Utilities.htmlSpecialChars; 30 31 yield '<data>\n'; 32 for (let i=0; i<items.length; i++) { 33 let item = items[i]; 34 var date = item.getField(dateType, true, true); 35 if (date) { 36 let sqlDate = (dateType == 'date') ? Zotero.Date.multipartToSQL(date) : date; 37 sqlDate = sqlDate.replace("-00-", "-01-").replace(/-00$/, "-01"); 38 let content = '<event start="' + Zotero.Date.sqlToDate(sqlDate) + '" '; 39 let title = item.getField('title'); 40 content += 'title="' + (title ? escapeXML(title) : '') + '" '; 41 content += 'icon="' + item.getImageSrc() + '" '; 42 content += 'color="black">'; 43 content += item.id; 44 content += '</event>\n'; 45 yield content; 46 } 47 } 48 yield '</data>'; 49 } 50 };