diff --git a/config/_default/params.toml b/config/_default/params.toml index fae6296..2c5ec5c 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -1,6 +1,6 @@ [main] - aosAssetsVersion = "4.0.1" - jctAssetsVersion = "4.0.1" + aosAssetsVersion = "4.0.2" + jctAssetsVersion = "4.0.2" feedbackButton = "Send us feedback" alert = "The information provided by the Journal Checker Tool represents cOAlition S’s current understanding in relation to the policies of the journals contained within it. We will endeavour to keep it up to date and accurate, but we do not accept any liability in relation to any errors or omissions." comingSoon = "Coming Soon" diff --git a/static/js/detailed_results.js b/static/js/detailed_results.js index ed0e928..ed69873 100644 --- a/static/js/detailed_results.js +++ b/static/js/detailed_results.js @@ -220,7 +220,7 @@ jct._yourQuery = (q) => { } } - let issns = jct.chosen.journal.issn.join(", "); + let issns = jct.chosen.journal.issns.join(", "); let publisher = jct.chosen.journal.publisher !== undefined ? jct.chosen.journal.publisher : jct.lang.explain.your_query.publisher_not_known; let journal = jct.lang.explain.your_query.journal_title_unknown; diff --git a/static/js/jct.js b/static/js/jct.js index c53064e..b119170 100644 --- a/static/js/jct.js +++ b/static/js/jct.js @@ -784,6 +784,25 @@ jct.d.toggle_detailed_results = () => { } } +jct.suggest_prepare = (txt, stop_words) => { + txt = txt.toLowerCase().trim(); + for (let sw of stop_words) { + let fullThing = new RegExp("^" + sw + "$"); + let atEnd = new RegExp(" " + sw + "$"); + let atStart = new RegExp("^" + sw + " "); + let inMiddle = new RegExp(" " + sw + " "); + + txt = txt.replace(fullThing, "").replace(atEnd, "").replace(atStart, "").replace(inMiddle, " ") + } + while (true) { + if (!(txt.includes(" "))) { + break + } + txt.replace(" ", " ") + } + return txt +} + ////////////////////////////////////////////////////////// // Initialisation @@ -836,13 +855,13 @@ jct.setup = (manageUrl=true) => { autocomplete: "off" }, options : function(text, callback) { + let effectiveTextLength = text.length; let pattern = /[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9xX]/; - if (pattern.test(text)) { - text = text.toUpperCase(); - } else { - text = text.toLowerCase().replace(' of','').replace('the ',''); + if (!pattern.test(text)) { + let effective_text = jct.suggest_prepare(text, ["of", "the", "and", "journa", "journal"]) + effectiveTextLength = effective_text.length; } - if (text.length > 1) { + if (effectiveTextLength >= 3) { let ourcb = (xhr) => { let js = JSON.parse(xhr.response); callback(js.data); @@ -852,7 +871,7 @@ jct.setup = (manageUrl=true) => { }, optionsTemplate : function(obj) { let t = obj.title; - let issns = obj.issn.join(", "); + let issns = obj.issns.join(", "); let publisher = obj.publisher; let frag = ""; @@ -871,7 +890,7 @@ jct.setup = (manageUrl=true) => { }, selectedTemplate : function(obj) { let t = obj.title; - let issns = obj.issn; + let issns = obj.issns; let publisher = obj.publisher; let frag = ""; @@ -967,8 +986,9 @@ jct.setup = (manageUrl=true) => { autocomplete: "off" }, options : function(text, callback) { - text = text.toLowerCase().replace(' of','').replace('the ',''); - if (text.length > 1) { + let effective_text = jct.suggest_prepare(text, ["of", "the", "and", "universi", "universit", "university"]) + let effectiveTextLength = effective_text.length; + if (effectiveTextLength >= 3) { let ourcb = (xhr) => { let js = JSON.parse(xhr.response); callback(js.data); diff --git a/static/js/jct_plugin.js b/static/js/jct_plugin.js index 627a151..cefb660 100644 --- a/static/js/jct_plugin.js +++ b/static/js/jct_plugin.js @@ -1122,6 +1122,21 @@ jct.d.toggle_detailed_results = () => { } } +jct.suggest_prepare = (txt, stop_words) => { + txt = txt.toLowerCase().trim(); + for (let sw of stop_words) { + // FIXME: need to make the second and third only replace at the start and the end + txt = txt.replace(" " + sw + " ", " ").replace(sw + " ", "").replace(" " + sw, "") + } + while (true) { + if (!(txt.includes(" "))) { + break + } + txt.replace(" ", " ") + } + return txt +} + ////////////////////////////////////////////////////////// // Initialisation @@ -1174,23 +1189,26 @@ jct.setup = (manageUrl=true) => { autocomplete: "off" }, options : function(text, callback) { + let effectiveTextLength = text.length; let pattern = /[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9xX]/; - if (pattern.test(text)) { - text = text.toUpperCase(); - } else { - text = text.toLowerCase().replace(' of','').replace('the ',''); + if (!pattern.test(text)) { + // let effective_text = text.toLowerCase().replace(' of','').replace('the ',''); + let effective_text = jct.suggest_prepare(text, ["of", "the", "and", "journa", "journal"]) + effectiveTextLength = effective_text.length + // text = text.toLowerCase().replace(' of','').replace('the ',''); } - if (text.length > 1) { + if (effectiveTextLength > 3) { let ourcb = (xhr) => { let js = JSON.parse(xhr.response); callback(js.data); } + // jct.jx('suggest/journal/'+text, false, ourcb); jct.jx('suggest/journal/'+text, false, ourcb); } }, optionsTemplate : function(obj) { let t = obj.title; - let issns = obj.issn.join(", "); + let issns = obj.issns.join(", "); let publisher = obj.publisher; let frag = ""; @@ -1209,7 +1227,7 @@ jct.setup = (manageUrl=true) => { }, selectedTemplate : function(obj) { let t = obj.title; - let issns = obj.issn; + let issns = obj.issns; let publisher = obj.publisher; let frag = ""; @@ -1305,7 +1323,7 @@ jct.setup = (manageUrl=true) => { autocomplete: "off" }, options : function(text, callback) { - text = text.toLowerCase().replace(' of','').replace('the ',''); + text = text.toLowerCase(); //.replace(' of','').replace('the ',''); if (text.length > 1) { let ourcb = (xhr) => { let js = JSON.parse(xhr.response);