www

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

commit 3918adf21a2990b87be746602862b42577d59d44
parent 68e7849fcf37145b52eb55f3419baa8f4139cceb
Author: Aurimas Vinckevicius <aurimas.dev@gmail.com>
Date:   Thu, 19 Feb 2015 04:36:52 -0600

Hyphenate ISBN when writing to DB
Only hyphenate if we're very confident that it's a list of unhyphenated ISBNs

Diffstat:
Mchrome/content/zotero/xpcom/data/item.js | 18++++++++++++++++++
1 file changed, 18 insertions(+), 0 deletions(-)

diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js @@ -821,6 +821,24 @@ Zotero.Item.prototype.setField = function(field, value, loadIn) { value = value.replace(/[\r\n]+/g, " ");; } + if (fieldID == Zotero.ItemFields.getID('ISBN')) { + // Hyphenate ISBNs, but only if everything is in expected format and valid + let isbns = ('' + value).trim().split(/\s*[,;]\s*|\s+/), + newISBNs = '', + failed = false; + for (let i=0; i<isbns.length; i++) { + let isbn = Zotero.Utilities.Internal.hyphenateISBN(isbns[i]); + if (!isbn) { + failed = true; + break; + } + + newISBNs += ' ' + isbn; + } + + if (!failed) value = newISBNs.substr(1); + } + if (!loadIn) { // Save date field as multipart date // TEMP - filingDate