FANDOM


  • Hi, can anyone help me how do I place real time coronavirus stats on the sidebar? I know how to place templates that get transcluded on the sidebar but I don't know how to place coronavirus stats on it. Can anyone help?

    Code for placing template on sidebar: https://evil-nun.fandom.com/vi/MediaWiki:Wikia.js

    Sidebar template: https://evil-nun.fandom.com/vi/Template:Sidebar

      Loading editor
    • Where would you be getting your real-time stats from. Do they have an RSS/ATOM feed or iframe element you can insert?

        Loading editor
    • Same question as above. 

        Loading editor
    • I'm getting it from an API endpoint. https://corona.lmao.ninja/all

        Loading editor
    • Finally! A site/program that uses the array form of JSON instead of the object form with keys you need to get with Object.keys. This actually has nothing to do with your question; I am just excited to finally find a site/program that does things in this more efficient manner.

      To address your question, there is a way you can do it but it would require custom JS. Custom JS needs staff approval before it can be used. I'll see what I can do and post it here.

        Loading editor
    • As I suspected, Fandom prevents the data request because it is an external server. I know neither if cross-domain requests are possible/allowed nor, assuming they are, how to make one. If you really feel like you need this, you can try asking on the dev wiki. They have users who are more experiences with JS and stuff.

        Loading editor
    • How reliable and accurate is this site? I question the validity of a site what has "lmao" in its url…

        Loading editor
    • Also, what's the point of tracking this? Unless you've got a corona or global pandemic related wiki, it's kinda pointless.

        Loading editor
    • Andrewds1021#5
      A site/program that uses the array form of JSON instead of the object form with keys you need to get with Object.keys.

      finally! site that uses json object instead of json object :D it has no difference from mw api, or youtube api, or google api.

      me personally would not write such script (even for specialized wikis, because wiki about pandemic can keep they data fresh by hands of their editors). such widgets serves the only one purpose: create a panic.

        Loading editor
    • example

      How would you extract information about the page from this result without needing to extract the object keys?

        Loading editor
    • incorrect example. you trying to compare simple object with 3 fields against generic object that serves as a container for whole endpoint. it's like say "library is bloated, single paper is much convenient to use". sure, in their base, both library and paper serves as items that contains some data, but there is some difference.

      the query object might contain different data, depending on the request. check this one. that's why the response has strict hierarchy: it supposed to return any (and all) requested data, regardless of structure of the data. unlike pre-defined 3 values.

        Loading editor
    • I guess I am still not being clear enough. I understand that the whole JSON is for the entire endpoint. I am looking specifically at:

      "pages":{"969648":{"pageid":969648,"ns":2,"title":"User:Andrewds1021"}}
      

      If I have the id to access the page data, why would I need the results to return the id? If I don't know the id, how would I access the page data; other than using a method that extract the keys (ex. Object.keys and for-in)?

        Loading editor
    • if you already have pageid, you can access the page via pages[id]. it might be not the main purpose: it's just logically to have {id1={data1}, id2={data2}}. i would create such collection, and i would not ask myself "why i do use id={data} instead of array [data1, data2]", unless it has performance issues.

      if you don't have pageid, then, well, deal with it :)

      it is common situation for arrays and other collections: if you need some specific element and you don't know exact position (or direct pointer to) of the element, you have to enumerate elements. i'd ask you whether you know other ways, but it would be unfair: we are enumerating elements again and again for purpose.

        Loading editor
    • A FANDOM user
        Loading editor
Give Kudos to this message
You've given this message Kudos!
See who gave Kudos to this message
Community content is available under CC-BY-SA unless otherwise noted.