Skip to content

Commit e2ebded

Browse files
committed
- Show "Seed article: " in corresponding rows in Second Table (currently still called "Incoming Suggestions", name should be updated to "All Cited")
- Add column "#" showing "Number in custom list", corresponding to original order in Zotero (works through "numberInSourceReferences") - "listOfDOIs" for Recreate network in web LCN now simply uses listOfKeys.map (instead of .reduce) to include gaps, which will keep numberInSourceReferences correct in web LCN - Add customListOfReferences, which allows linkToShareAppendix to work properly also in web LCN.
1 parent 250ef59 commit e2ebded

File tree

2 files changed

+24
-33
lines changed

2 files changed

+24
-33
lines changed

index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ <h2 class="title is-4">{{ getString('input-articles.header', currentGraph.seedAr
255255
<template v-else>
256256
{{ getString('input-articles.info.open-external', 'Local Citation Network') }}
257257
<b-tooltip dashed multilined position="is-bottom" type="is-dark"
258-
:label="getString('input-articles.info.open-external.tooltip', listOfIds.length)">
259-
<a @click="e => { e.preventDefault(); openUrl('https://LocalCitationNetwork.github.io/?listOfIds=' + listOfIds.join(',')) }">
258+
:label="getString('input-articles.info.open-external.tooltip', currentGraph.source?.customListOfReferences?.length)">
259+
<a @click="e => { e.preventDefault(); openUrl('https://LocalCitationNetwork.github.io/?listOfIds=' + currentGraph.source?.customListOfReferences.join(',')) }">
260260
&#8618
261261
</a>
262262
</b-tooltip>
@@ -366,8 +366,8 @@ <h4 class="title is-6">Reference contexts in source article, {{ currentGraph.sou
366366
<b-table-column :label="getString('table.column.title.label')" v-slot="props">
367367
<!-- id is for scrolling to row when network node is clicked -->
368368
<span :id="props.row.id" :class="{ retracted: props.row.isRetracted }">
369+
{{ (props.row.id === currentGraph.source?.id) ? 'Source: ' : '' }}
369370
<template v-if="currentGraph.API !== 'Zotero Cita'">
370-
{{ (props.row.id === currentGraph.source?.id) ? 'Source: ' : '' }}
371371
<a v-if="articleLink(props.row)" :href="articleLink(props.row)" target="_blank" v-html="formatTags(props.row.title) || props.row.doi || props.row.id"></a>
372372
<span v-else v-html="formatTags(props.row.title) || props.row.doi || props.row.id"></span>
373373
</template>
@@ -627,8 +627,8 @@ <h4 class="title is-6">Abstract</h4>
627627
<b-table-column :label="getString('table.column.title.label')" v-slot="props">
628628
<!-- id is for scrolling to row when network node is clicked -->
629629
<span :id="props.row.id" :class="{ retracted: props.row.isRetracted }">
630+
{{ (props.row.id === currentGraph.source?.id) ? 'Source: ' : (seedArticlesIds.includes(props.row.id) ? 'Seed Article: ' : '') }}
630631
<template v-if="currentGraph.API !== 'Zotero Cita'">
631-
{{ (props.row.id === currentGraph.source?.id) ? 'Source: ' : '' }}
632632
<a v-if="articleLink(props.row)" :href="articleLink(props.row)" target="_blank" v-html="formatTags(props.row.title) || props.row.doi || props.row.id"></a>
633633
<span v-else v-html="formatTags(props.row.title) || props.row.doi || props.row.id"></span>
634634
</template>

index.js

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const {
6464
saveFile
6565
} = window.arguments[0] || {};
6666

67-
function cita (itemKeys, responseFunction) {
67+
function citaWrapper (itemKeys, responseFunction) {
6868
return new Promise((resolve) => {
6969
resolve(itemKeys.map((itemId) => itemMap.get(itemId)));
7070
}).then((data) => responseFunction(data));
@@ -1176,21 +1176,18 @@ const vm = new Vue({
11761176
},
11771177
linkToShareAppendix: function () {
11781178
let appendix = '?API=' + encodeURIComponent(this.currentGraph.API)
1179+
appendix += '&name=' + encodeURIComponent(this.currentGraph.tabLabel)
11791180
if (this.currentGraph.source.id) {
11801181
appendix += '&source=' + (this.currentGraph.source.doi ? this.currentGraph.source.doi : this.currentGraph.source.id)
1181-
if (this.currentGraph.source.customListOfReferences) {
1182-
appendix += '&listOfIds=' + this.currentGraph.source.customListOfReferences.join(',')
1183-
}
1184-
if (this.currentGraph.bookmarkletURL) {
1185-
appendix += '&bookmarkletURL=' + this.currentGraph.bookmarkletURL
1186-
}
1187-
} else {
1188-
appendix += '&name=' + encodeURIComponent(this.currentGraph.tabLabel) + '&listOfIds=' + this.currentGraph.source.references.join(',')
11891182
}
1183+
if (this.currentGraph.bookmarkletURL) {
1184+
appendix += '&bookmarkletURL=' + this.currentGraph.bookmarkletURL
1185+
}
1186+
appendix += '&listOfIds=' + (this.currentGraph.source.customListOfReferences ? this.currentGraph.source.customListOfReferences : this.currentGraph.source.references).join(',')
11901187
return appendix
11911188
},
11921189
showNumberInSourceReferences: function () {
1193-
return this.currentGraph.API !== 'Zotero Cita' && (this.currentGraph.API === 'Crossref' || (this.currentGraph.source.customListOfReferences !== undefined) || !this.currentGraph.source.id)
1190+
return this.currentGraph.API === 'Crossref' || (this.currentGraph.source.customListOfReferences !== undefined) || !this.currentGraph.source.id
11941191
},
11951192
exportArticlesArray: function () {
11961193
return this.exportArticles.map(x => this[x]).flat()
@@ -1494,15 +1491,10 @@ const vm = new Vue({
14941491
// In case of file scanning, isLoading has not yet been set by setNewSource
14951492
this.isLoading = true
14961493

1497-
if (this.API === 'Zotero Cita') {
1498-
// some commands below seem to be blocking execution
1499-
// set a short delay to let window finish loading before them
1500-
// using window's load event doesn't work
1501-
//await new Promise((resolve) => setTimeout(() => resolve(), 500)) // introduced by diegolh back in 2021, doesn't seem to be necessary anymore as of 01/2025
1502-
} else {
1494+
if (this.API !== 'Zotero Cita') {
15031495
this.$buefy.toast.open({
15041496
message: 'New query sent to ' + this.API + '.<br>This may take a while, depending on the number of references and API workload.',
1505-
duration: 4000,
1497+
duration: 6000,
15061498
queue: false
15071499
})
15081500
}
@@ -1858,7 +1850,7 @@ const vm = new Vue({
18581850
} else if (API === 'Crossref') {
18591851
return crossrefWrapper(ids, responseFunction, phase)
18601852
} else if (API === 'Zotero Cita') {
1861-
return cita(ids, responseFunction)
1853+
return citaWrapper(ids, responseFunction)
18621854
} else {
18631855
return this.errorMessage("Undefined API '" + API + "'. Must be one of 'OpenAlex', 'Semantic Scholar', 'OpenCitations', 'Crossref'.")
18641856
}
@@ -1874,7 +1866,9 @@ const vm = new Vue({
18741866
} else if (API === 'Crossref') {
18751867
articles = crossrefResponseToArticleArray(data)
18761868
} else if (this.API === 'Zotero Cita') {
1877-
articles = data // TODO or return data as by diegolh?
1869+
// Add numberInSourceReferences so that "#" column in Seed Articles table shows order just like in Zotero (which can be sorted differently than LCN, e.g. by "Date Added")
1870+
const articlesIds = data.map(article => article.id)
1871+
articles = data.map(article => { if (article.numberInSourceReferences === undefined) article.numberInSourceReferences = articlesIds.indexOf(article.id)+1; return article; })
18781872
}
18791873
// Remove duplicates - important for de-duplication of All References / All Citations (in the sense of proper duplicates within one category (not in the sense of "de-duplicated against Seed Articles and Cited"), can be duplicated mostly with S2 but also to lesser extent with OA), rarely also needed for other calls, e.g. for S2 in references of 10.1111/J.1461-0248.2009.01285.X, eebf363bc78ca7bc16a32fa339004d0ad43aa618 came up twice
18801874
articles = articles.reduce((articlesKeep, article) => {
@@ -2248,16 +2242,13 @@ const vm = new Vue({
22482242
this.retrieveCitedArticles = Infinity
22492243
this.retrieveCitingArticles = 0
22502244

2251-
this.listOfIds = listOfKeys.reduce(
2252-
(dois, key) => {
2253-
const doi = itemMap.get(key).doi
2254-
if (doi) dois.push(doi)
2255-
return dois
2256-
}, []
2257-
)
2258-
this.listName = 'Zotero Cita ' + (new Date().toLocaleString('en-CA', {hour12: false}).replace(", ", " ").substr(0,16)) // Add datetime (YYYY-MM-DD HH:MM) so that the graph's tabLabel becoms more unique and multiple Cita JSON files can be opened at the same time
2259-
2260-
this.createNewNetwork({ references: listOfKeys, citations: [] })
2245+
// Tab name: Add datetime (YYYY-MM-DD HH:MM) so that the graph's tabLabel becoms more unique and multiple Cita JSON files can be opened at the same time
2246+
this.listName = 'Zotero Cita ' + (new Date().toLocaleString('en-CA', {hour12: false}).replace(", ", " ").substr(0,16))
2247+
2248+
// This list of DOIs is for "Recreate network"
2249+
const listOfDOIs = listOfKeys.map(key => itemMap.get(key).doi)
2250+
2251+
this.createNewNetwork({ references: listOfKeys, customListOfReferences: listOfDOIs, citations: [] })
22612252
}
22622253

22632254
// Linked to FAQ?

0 commit comments

Comments
 (0)