<commit_before>/*
    ***** BEGIN LICENSE BLOCK *****
    
    Copyright © 2006–2013 Center for History and New Media
                     George Mason University, Fairfax, Virginia, USA
                     http://zotero.org
    
    This file is part of Zotero.
    
    Zotero is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    Zotero is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.
    
    You should have received a copy of the GNU Affero General Public License
    along with Zotero.  If not, see <http://www.gnu.org/licenses/>.
    
    ***** END LICENSE BLOCK *****
*/

"use strict";

Zotero_Preferences.Cite = {
	init: function () {
		this.updateWordProcessorInstructions();
		this.refreshStylesList();
	},
	
	
	/**
	 * Determines if there are word processors, and if not, enables no word processor message
	 */
	updateWordProcessorInstructions: function () {
		if(document.getElementById("wordProcessors").childNodes.length == 2) {
			document.getElementById("wordProcessors-noWordProcessorPluginsInstalled").hidden = undefined;
		}
		if(Zotero.isStandalone) {
			document.getElementById("wordProcessors-getWordProcessorPlugins").hidden = true;
		}
	},
	
	
	/**
	 * Refreshes the list of styles in the styles pane
	 * @param {String} cslID Style to select
	 */
	refreshStylesList: function (cslID) {
		Zotero.debug("Refreshing styles list");
		
		var treechildren = document.getElementById('styleManager-rows');
		while (treechildren.hasChildNodes()) {
			treechildren.removeChild(treechildren.firstChild);
		}
		
		var styles = Zotero.Styles.getVisible();
		
		var selectIndex = false;
		var i = 0;
		for each(var style in styles) {
			var treeitem = document.createElement('treeitem');
			var treerow = document.createElement('treerow');
			var titleCell = document.createElement('treecell');
			var updatedCell = document.createElement('treecell');
			var cslCell = document.createElement('treecell');
			
			if (style.updated) {
				var updatedDate = Zotero.Date.formatDate(Zotero.Date.strToDate(style.updated), true);
			}
			else {
				var updatedDate = '';
			}
			
			treeitem.setAttribute('id', 'zotero-csl-' + style.styleID);
			titleCell.setAttribute('label', style.title);
			updatedCell.setAttribute('label', updatedDate);
			// if not EN
			if(style.type == "csl") {
				cslCell.setAttribute('src', 'chrome://zotero/skin/tick.png');
			}
			
			treerow.appendChild(titleCell);
			treerow.appendChild(updatedCell);
			treerow.appendChild(cslCell);
			treeitem.appendChild(treerow);
			treechildren.appendChild(treeitem);
			
			if (cslID == style.styleID) {
				document.getElementById('styleManager').view.selection.select(i);
			}
			i++;
		}
	},
	
	
	/**
	 * Adds a new style to the style pane
	 **/
	addStyle: function () {	
		const nsIFilePicker = Components.interfaces.nsIFilePicker;
		var fp = Components.classes["@mozilla.org/filepicker;1"]
				.createInstance(nsIFilePicker);
		fp.init(window, Zotero.getString("zotero.preferences.styles.addStyle"), nsIFilePicker.modeOpen);
		
		fp.appendFilter("CSL Style", "*.csl");
		fp.appendFilter("ENS Style", "*.ens");<commit_msg>Remove remaining ENS style code<commit_after>/*
    ***** BEGIN LICENSE BLOCK *****
    
    Copyright © 2006–2013 Center for History and New Media
                     George Mason University, Fairfax, Virginia, USA
                     http://zotero.org
    
    This file is part of Zotero.
    
    Zotero is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    Zotero is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.
    
    You should have received a copy of the GNU Affero General Public License
    along with Zotero.  If not, see <http://www.gnu.org/licenses/>.
    
    ***** END LICENSE BLOCK *****
*/

"use strict";

Zotero_Preferences.Cite = {
	init: function () {
		this.updateWordProcessorInstructions();
		this.refreshStylesList();
	},
	
	
	/**
	 * Determines if there are word processors, and if not, enables no word processor message
	 */
	updateWordProcessorInstructions: function () {
		if(document.getElementById("wordProcessors").childNodes.length == 2) {
			document.getElementById("wordProcessors-noWordProcessorPluginsInstalled").hidden = undefined;
		}
		if(Zotero.isStandalone) {
			document.getElementById("wordProcessors-getWordProcessorPlugins").hidden = true;
		}
	},
	
	
	/**
	 * Refreshes the list of styles in the styles pane
	 * @param {String} cslID Style to select
	 */
	refreshStylesList: function (cslID) {
		Zotero.debug("Refreshing styles list");
		
		var treechildren = document.getElementById('styleManager-rows');
		while (treechildren.hasChildNodes()) {
			treechildren.removeChild(treechildren.firstChild);
		}
		
		var styles = Zotero.Styles.getVisible();
		
		var selectIndex = false;
		var i = 0;
		for each(var style in styles) {
			var treeitem = document.createElement('treeitem');
			var treerow = document.createElement('treerow');
			var titleCell = document.createElement('treecell');
			var updatedCell = document.createElement('treecell');
			var cslCell = document.createElement('treecell');
			
			if (style.updated) {
				var updatedDate = Zotero.Date.formatDate(Zotero.Date.strToDate(style.updated), true);
			}
			else {
				var updatedDate = '';
			}
			
			treeitem.setAttribute('id', 'zotero-csl-' + style.styleID);
			titleCell.setAttribute('label', style.title);
			updatedCell.setAttribute('label', updatedDate);
			// if not EN
			if(style.type == "csl") {
				cslCell.setAttribute('src', 'chrome://zotero/skin/tick.png');
			}
			
			treerow.appendChild(titleCell);
			treerow.appendChild(updatedCell);
			treerow.appendChild(cslCell);
			treeitem.appendChild(treerow);
			treechildren.appendChild(treeitem);
			
			if (cslID == style.styleID) {
				document.getElementById('styleManager').view.selection.select(i);
			}
			i++;
		}
	},
	
	
	/**
	 * Adds a new style to the style pane
	 **/
	addStyle: function () {	
		const nsIFilePicker = Components.interfaces.nsIFilePicker;
		var fp = Components.classes["@mozilla.org/filepicker;1"]
				.createInstance(nsIFilePicker);
		fp.init(window, Zotero.getString("zotero.preferences.styles.addStyle"), nsIFilePicker.modeOpen);
		
		fp.appendFilter("CSL Style", "*.csl");
{'fraction_non_alphanumeric': 0.11451913429840906, 'fraction_numerical': 0.003439873871291386, 'mean_word_length': 3.54296875, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5931615', 'n_tokens_mistral': 2317, 'n_tokens_neox': 2029, 'n_words': 546}