www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit e32e6aa2f549065f9b841132bfe97f7d63015ce4
parent f8a5ddc0476aa7d38ed86a71c209549a7b8013e9
Author: Dan Stillman <dstillman@zotero.org>
Date:   Mon,  6 Oct 2008 21:43:16 +0000

Fix csledit and cslpreview with new styles architecture -- dependent styles will not be displayed


Diffstat:
Mchrome/content/zotero/tools/csledit.xul | 12++++++++----
Mchrome/content/zotero/tools/cslpreview.xul | 39++++++++++++++++++---------------------
2 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/chrome/content/zotero/tools/csledit.xul b/chrome/content/zotero/tools/csledit.xul @@ -53,9 +53,12 @@ return; } - var csls = Zotero.DB.query("SELECT title, cslID FROM csl ORDER BY title"); - for (var i=0; i<csls.length; i++) { - cslList.appendItem(csls[i].title, csls[i].cslID); + var styles = Zotero.Styles.getAll(); + for each(var style in styles) { + if (style.source) { + continue; + } + var item = cslList.appendItem(style.title, style.styleID); } var pageList = document.getElementById('zotero-csl-page-type'); var locators = Zotero.CSL.Global.getLocatorStrings(); @@ -85,7 +88,8 @@ function loadCSL(cslID) { var editor = document.getElementById('zotero-csl-editor') - editor.value = Zotero.DB.valueQuery("SELECT csl FROM csl WHERE cslID=?", cslID); + var style = Zotero.Styles.get(cslID); + editor.value = Zotero.File.getContents(style.file); editor.doCommand(); document.getElementById('zotero-csl-list').value = cslID; } diff --git a/chrome/content/zotero/tools/cslpreview.xul b/chrome/content/zotero/tools/cslpreview.xul @@ -66,14 +66,17 @@ progressWin.show(); progressWin.startCloseTimer(); var f = function() { - var csls = Zotero.DB.query("SELECT title, csl FROM csl ORDER BY title"); + var styles = Zotero.Styles.getAll(); // XXX needs its own string really for the title! var str = '<html><head><title></title></head><body><h1>Citation/Bibliography list<h1>'; - for (var i=0; i<csls.length; i++) { - Zotero.debug("Generate Bib for " + csls[i].title); - var cite = generateBibliography(csls[i].csl); + for each(var style in styles) { + if (style.source) { + continue; + } + Zotero.debug("Generate Bib for " + style.title); + var cite = generateBibliography(style); if (cite) { - str += '<hr><h2>' + csls[i].title + '</h2>'; + str += '<hr><h2>' + style.title + '</h2>'; str += cite; } } @@ -85,7 +88,7 @@ setTimeout(f, 100); } - function generateBibliography(str) { + function generateBibliography(style) { var iframe = document.getElementById('zotero-csl-preview-box'); var items = mainWindow.ZoteroPane.getSelectedItems(); @@ -93,25 +96,19 @@ iframe.contentDocument.documentElement.innerHTML = '<html><head><title></title></head><body><p style="color: red">No references selected in Zotero.</p></body></html>'; return ''; } - var csl; - if (str.indexOf("<defaults") != -1) { - return "Old-style CSLs are no longer supported."; - } - else { - csl = new Zotero.CSL(str); - } + var authordate = document.getElementById("format-author-date"); var numeric = document.getElementById("format-numeric"); - Zotero.debug("style class is " + csl.class); - if (document.getElementById("format-note").checked == false && csl.class == "note") { + Zotero.debug("style class is " + style.class); + if (document.getElementById("format-note").checked == false && style.class == "note") { Zotero.debug("CSL IGNORE NOTE one"); return ''; } - if (document.getElementById("format-in-text").checked == false && csl.class == "in-text") { + if (document.getElementById("format-in-text").checked == false && style.class == "in-text") { Zotero.debug("CSL IGNORE IN-TEXT one"); return ''; } - var xmlinfo = csl._csl.info; + var xmlinfo = style.csl._csl.info; var terms = new Object(); for each(var cat in xmlinfo.category.@term) { Zotero.debug("TERM is " + cat.toString()); @@ -125,14 +122,14 @@ Zotero.debug("CSL IGNORE this AD"); return ''; } - var itemSet = csl.createItemSet(items); + var itemSet = style.csl.createItemSet(items); // Generate multiple citations - var citation = csl.createCitation(itemSet.items); - var citations = csl.formatCitation(citation, "HTML"); + var citation = style.csl.createCitation(itemSet.items); + var citations = style.csl.formatCitation(citation, "HTML"); // Generate bibliography - var bibliography = '<p>' + csl.formatBibliography(itemSet, "HTML"); + var bibliography = '<p>' + style.csl.formatBibliography(itemSet, "HTML"); return '<div style="white-space: pre-wrap">' + citations + bibliography + '</div>'; }