Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P8820
Fixed User:FelixReimann/taxobox.js
Active
Public
Actions
Authored by
•
alaa_wmde
on Jul 29 2019, 10:32 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F29901257: raw.txt
Jul 29 2019, 10:32 PM
2019-07-29 22:32:08 (UTC+0)
Subscribers
None
/* <nowiki>
*
* taxobox.js by [[User:FelixReimann]] with help from [[User:Ricordisamoa]]
* based on [[User:Ricordisamoa/Wikispecies.js]]
*/
$
(
document
).
ready
(
function
(){
mw
.
hook
(
'wikibase.entityPage.entityLoaded'
).
add
(
function
(
entity
)
{
// only on entities, not properties or other namespaces
if
(
mw
.
config
.
get
(
'wgNamespaceNumber'
)
!=
0
)
return
;
if
(
mw
.
config
.
get
(
'wgAction'
)
!=
'view'
)
return
;
if
(
typeof
entity
.
claims
==
'undefined'
)
return
;
if
(
Object
.
keys
(
entity
.
claims
).
indexOf
(
'P225'
)
!=
-
1
){
// 'taxon name' is present
var
language
=
mw
.
user
.
options
.
get
(
'language'
);
var
count
=
5
;
if
(
mw
.
config
.
get
(
'taxoboxCount'
))
{
count
=
mw
.
config
.
get
(
'taxoboxCount'
);
}
var
template
=
'<div class="wikibase-taxobox">{{Taxobox|qid='
+
wgPageName
+
'|count='
+
count
+
'|lang='
+
language
+
'}}<div class="wikibase-taxobox-references" style="clear:right;"><references/></div></div>'
;
// https://www.wikidata.org/w/api.php?action=parse&text={{Taxobox|qid=Q36146}}&prop=text&contentmodel=wikitext&format=jsonfm
$
.
getJSON
(
mw
.
util
.
wikiScript
(
'api'
),
{
action
:
'parse'
,
format
:
'json'
,
text
:
template
,
contentmodel
:
'wikitext'
,
prop
:
'text'
},
function
(
data
){
var
text
=
data
.
parse
.
text
;
$
(
'.wikibase-sitelinkgrouplistview'
).
append
(
text
[
'*'
]);
// TODO insert text
});
}
}
);
});
//</nowiki>
Event Timeline
•
alaa_wmde
created this paste.
Jul 29 2019, 10:32 PM
2019-07-29 22:32:08 (UTC+0)
•
alaa_wmde
changed the edit policy from "All Users" to "
Trusted-Contributors
(Project)".
Jul 29 2019, 10:41 PM
2019-07-29 22:41:05 (UTC+0)
Log In to Comment