“Widget:BMMOLatestUpdate”的版本间的差异

来自Ballance Wiki
跳转至: 导航搜索
第1行: 第1行:
 +
<span class="bmmo-latest-update"></span>
 
<script>
 
<script>
 
fetch("https://dl.bmmo.bcrc.site/download/latest?version-only=true")
 
fetch("https://dl.bmmo.bcrc.site/download/latest?version-only=true")
 
     .then(res => res.json())
 
     .then(res => res.json())
 
     .then(data => {
 
     .then(data => {
         const lang = "<!--{$lang|default:'en'|escape:'html'}-->";
+
         const lang = "<!--{$param1|escape:'html'}-->";
 
         const dateLatest = new Date(data["time"] * 1e3);
 
         const dateLatest = new Date(data["time"] * 1e3);
         document.write(data["version"]);
+
         let text = data["version"];
         document.write('<span style="font-size: 0.88em">');
+
         text += '<span style="font-size: 0.88em">';
 
         if (lang == "zh") {
 
         if (lang == "zh") {
             document.write(`(${dateLatest.toLocaleDateString("zh-SG")},`
+
             text += (`(${dateLatest.toLocaleDateString("zh-SG")},`
 
                 + `${((new Date() - dateLatest) / 1e3 / 86400).toFixed(0)}日前)`);
 
                 + `${((new Date() - dateLatest) / 1e3 / 86400).toFixed(0)}日前)`);
 
         } else {
 
         } else {
             document.write(` (${dateLatest.toLocaleDateString("en-UK", {year: "numeric", month: "long", day: "numeric"})}, `
+
             text += (` (${dateLatest.toLocaleDateString("en-UK", {year: "numeric", month: "long", day: "numeric"})}, `
 
                 + `${((new Date() - dateLatest) / 1e3 / 86400).toFixed(0)} day(s) ago)`);
 
                 + `${((new Date() - dateLatest) / 1e3 / 86400).toFixed(0)} day(s) ago)`);
 
         }
 
         }
         document.write('</span>');
+
         text += '</span>';
 +
        document.querySelectorAll(".bmmo-latest-update").forEach(el => {
 +
            el.innerHTML = text;
 +
        });
 
     });
 
     });
 
</script>
 
</script>

2023年9月3日 (日) 11:10的版本

<script> fetch("https://dl.bmmo.bcrc.site/download/latest?version-only=true")

   .then(res => res.json())
   .then(data => {
       const lang = "";
       const dateLatest = new Date(data["time"] * 1e3);
       let text = data["version"];
       text += '';
       if (lang == "zh") {
           text += (`(${dateLatest.toLocaleDateString("zh-SG")},`
               + `${((new Date() - dateLatest) / 1e3 / 86400).toFixed(0)}日前)`);
       } else {
           text += (` (${dateLatest.toLocaleDateString("en-UK", {year: "numeric", month: "long", day: "numeric"})}, `
               + `${((new Date() - dateLatest) / 1e3 / 86400).toFixed(0)} day(s) ago)`);
       }
       text += '';
       document.querySelectorAll(".bmmo-latest-update").forEach(el => {
           el.innerHTML = text;
       });
   });

</script>