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 Thẻ: Đã bị lùi lại |
Không có tóm lược sửa đổi |
||
| (không hiển thị 23 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()'); | ||
} | } | ||
| Dòng 40: | Dòng 40: | ||
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++) { | |||
for (var i = 0; i < mb.length; i++) { | |||
console.log(i); | console.log(i); | ||
if (mb[i].title == "Do TNTV tự phục dựng.") | if (mb[i].title == "Do TNTV tự phục dựng.") | ||
{ | { | ||
mb[i | 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 107: | 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' }; | ||
} | } | ||
} | } | ||
| Dòng 135: | Dòng 125: | ||
if (mutations[0].type === 'childList') { | if (mutations[0].type === 'childList') { | ||
setTimeout(function() { | setTimeout(function() { | ||
if (document.querySelector('.drawer').querySelector('sup').innerText | 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 | 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'; | ||
} | } | ||
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); | }, 500); | ||
} | } | ||
| Dòng 150: | 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 156: | 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(' + | 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(' ')) + ' ' + 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(' ')) + ' ' + 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(' ')) + ' ' + 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(' ')) + ' ' + entry[entry.length-1].slice(entry[entry.length-1].lastIndexOf(' ') + 1) + '</span>'; | ||
} | } | ||
} | } | ||
| Dòng 174: | Dòng 170: | ||
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 > dl[i].clientWidth/2) {dd[j].style.setProperty('min-width','100%'); dd[j].style.setProperty('column-span','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 >= | 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(' > ','<con> > </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)" | |||
} | } | ||