MediaWiki:Gadget-GlossaryGraph.js: Difference between revisions
Jump to navigation
Jump to search
AdminIsidore (talk | contribs) No edit summary |
AdminIsidore (talk | contribs) No edit summary |
||
| Line 11: | Line 11: | ||
// Extract term (e.g., "Dictum" from "Lingua:Dictum") | // Extract term (e.g., "Dictum" from "Lingua:Dictum") | ||
var term = pageTitle.split(':').pop(); | var term = pageTitle.split(':').pop().toLowerCase(); | ||
// Query | // Query all glossary entries | ||
var smwQuery = encodeURIComponent('[[Category:Glossary Entries]] | var smwQuery = encodeURIComponent('[[Category:Glossary Entries]]|?Glossary-Term|?Glossary-Definition|limit=50'); | ||
new mw.Api().get({ | new mw.Api().get({ | ||
action: 'ask', | action: 'ask', | ||
| Line 24: | Line 24: | ||
for (var page in results) { | for (var page in results) { | ||
if (results.hasOwnProperty(page) && page !== pageTitle) { | if (results.hasOwnProperty(page) && page !== pageTitle) { | ||
var | var definitions = results[page].printouts['Glossary-Definition'] || []; | ||
if (definitions.length > 0 && definitions.some(function(def) { | |||
return def.toLowerCase().indexOf(term) !== -1; | |||
return def.toLowerCase().indexOf(term | |||
})) { | })) { | ||
links.push({ title: page }); | links.push({ title: page }); | ||