Khác biệt giữa bản sửa đổi của “MediaWiki:Mobile.js”

Không có tóm lược sửa đổi
Không có tóm lược sửa đổi
 
(không hiển thị 44 phiên bản ở giữa của cùng người dùng)
Dòng 18: Dòng 18:
     document.body.appendChild(mfpopup);
     document.body.appendChild(mfpopup);
}
}
for (i = 0; i < mf.length; i++) {
for (var i = 0; i < mf.length; i++) {
   mf[i].setAttribute('onclick','missingfont()');
   mf[i].setAttribute('onclick','missingfont()');
}
}
function maybe() {
function maybe(e) {
     event.stopPropagation();
     event.stopPropagation();
     if ( document.querySelector('.missing.message.popup') != null ) {
     if ( document.querySelector('.missing.message.popup') != null ) {
Dòng 29: Dòng 29:
         document.querySelector('.maybe.message.popup').remove();
         document.querySelector('.maybe.message.popup').remove();
     }
     }
     const mbpopup = document. createElement('span');
     const mbpopup = document.createElement('span');
     mbpopup.innerHTML = '<span class="drawer drawer-container__drawer position-fixed text references-drawer visible">Có thể. Không có dẫn chứng chắc chắn.</span>';
     if (e=="x")
      {
        mbpopup.innerHTML = '<span class="drawer drawer-container__drawer position-fixed text references-drawer visible">Do TNTV tự phục dựng.</span>';
      }
      else
      {
        mbpopup.innerHTML = '<span class="drawer drawer-container__drawer position-fixed text references-drawer visible">Có thể. Không có dẫn chứng chắc chắn.</span>';
      }
     mbpopup.setAttribute('class','maybe message popup');
     mbpopup.setAttribute('class','maybe message popup');
     document.body.appendChild(mbpopup);
     document.body.appendChild(mbpopup);
}
}
for (i = 0; i < mb.length; i++) {
 
   mb[i].setAttribute('onclick','maybe()');
for (var i = 0; i < mb.length; i++) {
   console.log(i);
  if (mb[i].title == "Do TNTV tự phục dựng.")
      {
        mb[i].setAttribute('onclick','maybe("x")')
      }
  if (mb[i].title == "Có thể. Không có dẫn chứng chắc chắn.")
      {
        mb[i].setAttribute('onclick','maybe()')
      }
}
}


Dòng 41: Dòng 57:
     event.stopPropagation();
     event.stopPropagation();
     if (a.getElementsByClassName('ttzoom')[0].style.visibility == 'hidden') {
     if (a.getElementsByClassName('ttzoom')[0].style.visibility == 'hidden') {
        for ( var i = 0; i < ht.length; i++ ) {
          ht[i].getElementsByClassName('ttzoom')[0].style.visibility = 'hidden';
          ht[i].getElementsByClassName('ttzoom')[0].style.opacity = '0';
        }
        for ( var i = 0; i < hc.length; i++ ) {
          hc[i].getElementsByClassName('ttzoom')[0].style.visibility = 'hidden';
          hc[i].getElementsByClassName('ttzoom')[0].style.opacity = '0';
        }
         a.getElementsByClassName('ttzoom')[0].style.visibility = 'visible';
         a.getElementsByClassName('ttzoom')[0].style.visibility = 'visible';
         a.getElementsByClassName('ttzoom')[0].style.opacity = '1';
         a.getElementsByClassName('ttzoom')[0].style.opacity = '1';
Dòng 81: Dòng 105:
     for ( var i = 0; i < rt.length; i++ ) {
     for ( var i = 0; i < rt.length; i++ ) {
         if ( rt[i].innerText == '' ) { rt[i].style.display = 'none' };
         if ( rt[i].innerText == '' ) { rt[i].style.display = 'none' };
    }
}
var zoom = document.getElementsByClassName('ttzoom');
for ( var i = 0; i < zoom.length; i++ ) {
    if ( zoom[i].getBoundingClientRect().right > document.documentElement.clientWidth ) {
        zoom[i].style.left = 'unset';
        zoom[i].style.right = '100%';
     }
     }
}
}
Dòng 106: Dòng 122:
options = {childList: true}, observer = new MutationObserver(onChanged);
options = {childList: true}, observer = new MutationObserver(onChanged);
function onChanged(mutations) {
function onChanged(mutations) {
// for (var mutation of mutations) {
//     for (var mutation of mutations) {
if (mutations[0].type === 'childList') {
        if (mutations[0].type === 'childList') {
setTimeout(function() {  
            setTimeout(function() {  
if (document.querySelector('.drawer').querySelector('sup').innerText == '[a]') {
                if (document.querySelector('.drawer').querySelector('sup').innerText.search(/\[[a-z]\]/) == 0) {
document.querySelector('.references-drawer__title').innerText = 'Ghi chú';
                document.querySelector('.references-drawer__title').innerText = 'Ghi chú';
}
                }
if (document.querySelector('.drawer').querySelector('sup').innerText == '[cg1]') {
                if (document.querySelector('.drawer').querySelector('sup').innerText.includes('[cg')) {
document.querySelector('.references-drawer__title').innerText = 'Từ cùng gốc';
                document.querySelector('.references-drawer__title').innerText = 'Từ cùng gốc';
}  
                }
}, 500);
                if (document.querySelector('.drawer').querySelector('sup').innerText.includes('[fc')) {
}
                document.querySelector('.references-drawer__title').innerText = 'Từ cùng gốc giả';
// }
                }
                if (document.querySelector('.drawer').querySelector('sup').innerText.search(/\[[1-9]\]/) == 0) {
                document.querySelector('.references-drawer__title').innerText = 'Nguồn tham khảo';
                }
            }, 500);
        }
//     }
}
}


Dòng 124: Dòng 146:
//Line-break arrows
//Line-break arrows
var entries = document.querySelector('ol').querySelectorAll('li');
var entries = document.querySelector('ol').querySelectorAll('li');
for (i = 0; i < entries.length; i++) {
for (var i = 0; i < entries.length; i++) {
   if (entries[i].innerHTML.match(/> →/g) != null) {
   if (entries[i].innerHTML.match(/> →/g) != null) {
     var entry = entries[i].innerHTML.split('> →');
     var entry = entries[i].innerHTML.split('> →');
Dòng 130: Dòng 152:
     entries[i].innerHTML += entry[0] + 'b>';
     entries[i].innerHTML += entry[0] + 'b>';
     for (j = 1; j < entry.length - 1; j++) {
     for (j = 1; j < entry.length - 1; j++) {
       entries[i].innerHTML += '<br><span style="display:inline-block;margin-left:calc(' + (j+1) + 'em + 0.5ch);text-indent: calc(-1em - 0.5ch)">' + '→' + entry[j] + '></span>';
       entries[i].innerHTML += '<br><span style="display:inline-block;margin-left:calc(' + j + 'em + 0.5ch);text-indent: calc(-1em - 0.5ch)">' + '→' + entry[j] + '></span>';
     }
     }
     if (entry[entry.length-1].search('dl') > -1 && entry[entry.length-1].split('<dl')[0].slice(0,entry[entry.length-1].split('<dl')[0].lastIndexOf(' ')).slice(entry[entry.length-1].split('<dl')[0].slice(0,entry[entry.length-1].split('<dl')[0].lastIndexOf(' ')).length-2) != '<a') {
     if (entry[entry.length-1].search('dl') > -1 && entry[entry.length-1].split('<dl')[0].slice(0,entry[entry.length-1].split('<dl')[0].lastIndexOf(' ')).slice(entry[entry.length-1].split('<dl')[0].slice(0,entry[entry.length-1].split('<dl')[0].lastIndexOf(' ')).length-2) != '<a') {
       entries[i].innerHTML += '<br><span style="display:inline-block;margin-left:calc(' + entry.length + 'em + 0.5ch);text-indent: calc(-1em - 0.5ch)">' + '→' + entry[entry.length-1].split('<dl')[0].slice(0,entry[entry.length-1].split('<dl')[0].lastIndexOf(' ')) + '&nbsp;' + entry[entry.length-1].split('<dl')[0].slice(entry[entry.length-1].split('<dl')[0].lastIndexOf(' ')+1) + '</span><dl' + entry[entry.length-1].split('<dl')[1];
       entries[i].innerHTML += '<br><span style="display:inline-block;margin-left:calc(' + (entry.length-1) + 'em + 0.5ch);text-indent: calc(-1em - 0.5ch)">' + '→' + entry[entry.length-1].split('<dl')[0].slice(0,entry[entry.length-1].split('<dl')[0].lastIndexOf(' ')) + '&nbsp;' + entry[entry.length-1].split('<dl')[0].slice(entry[entry.length-1].split('<dl')[0].lastIndexOf(' ')+1) + '</span><dl' + entry[entry.length-1].split('<dl')[1];
     } else {
     } else {
       entries[i].innerHTML += '<br><span style="display:inline-block;margin-left:calc(' + entry.length + 'em + 0.5ch);text-indent: calc(-1em - 0.5ch)">' + '→' + entry[entry.length-1].slice(0,entry[entry.length-1].lastIndexOf(' ')) + '&nbsp;' + entry[entry.length-1].slice(entry[entry.length-1].lastIndexOf(' ') + 1) + '</span>';
       entries[i].innerHTML += '<br><span style="display:inline-block;margin-left:calc(' + (entry.length-1) + 'em + 0.5ch);text-indent: calc(-1em - 0.5ch)">' + '→' + entry[entry.length-1].slice(0,entry[entry.length-1].lastIndexOf(' ')) + '&nbsp;' + entry[entry.length-1].slice(entry[entry.length-1].lastIndexOf(' ') + 1) + '</span>';
     }
     }
   }
   }
Dòng 147: Dòng 169:
     var dd = dl[i].getElementsByTagName('dd');
     var dd = dl[i].getElementsByTagName('dd');
     for (j = 0; j < dd.length; j++) {
     for (j = 0; j < dd.length; j++) {
         if (dd[j].innerText != '\n') { cnt++; } else { cnt = 0; dd[j].style.columnSpan = 'all'; dd[j-1].style.columnSpan = 'all'; }
         if (dd[j].innerText != '\n') { cnt++; } else { cnt = 0; dd[j].style.columnSpan = 'all'; dd[j-1].style.columnSpan = 'all'; };
        if (dd[j].clientWidth + parseFloat(window.getComputedStyle(dd[0])['marginLeft']) > dl[i].clientWidth/2) {dd[j].style.setProperty('min-width','100%'); dd[j].style.setProperty('column-span','all')}
     }
     }
     if (cnt >= 6) { dl[i].style.columns = 2 }
     if (cnt >= 4) { dl[i].style.columns = 2 }
}
 
// Word connectors
 
if (window.location.href.indexOf('MediaWiki') == -1) {
    document.getElementById('mw-content-text').innerHTML = document.getElementById('mw-content-text').innerHTML.replaceAll(' &gt; ','<con> &gt; </con>').replaceAll(' ~ ','<con> ~ </con>').replaceAll('→ ','<arrow>↳ </arrow>');
}
 
// Highlight entry
if (window.location.href.includes('#entry')) {
    document.getElementById(window.location.href.substring(window.location.href.indexOf('#')+1,window.location.href.length)).parentElement.style.background = "rgba(255,222,100,0.4)"
}
}