User:FINNER/common.js

/* FINNER/Test10 START */ function Countdown(seedDate, loopTime, loopUnit, delayTime, delayUnit, dateFormat, dateLabels, separators) { const oneYear = 31536000000, oneMonth = oneYear / 12, oneDay    = oneYear / 365; const oneHour = 3600000,    oneMinute = 60000,        oneSecond = 1000; var count = document.getElementsByClassName("custom-countdown"); for (var k = 0; k < count.length; k++) {   var now = new Date; var i = 0, loopConv = 0, delayConv = 0; var nextDate = new Date(seedDate[k].innerHTML); if (isNaN(delayTime[k].innerHTML)) delayTime[k].innerHTML = 0; switch (loopUnit[k].innerHTML) { case 'Y': loopConv = loopTime[k].innerHTML * oneYear; break; case 'M': loopConv = loopTime[k].innerHTML * oneMonth; break; case 'D': loopConv = loopTime[k].innerHTML * oneDay; break; case 'h': loopConv = loopTime[k].innerHTML * oneHour; break; case 'm': loopConv = loopTime[k].innerHTML * oneMinute; break; case 's': loopConv = loopTime[k].innerHTML * oneSecond; break; }   switch (delayUnit[k].innerHTML) { case 'Y': delayConv = delayTime[k].innerHTML * oneYear; break; case 'M': delayConv = delayTime[k].innerHTML * oneMonth; break; case 'D': delayConv = delayTime[k].innerHTML * oneDay; break; case 'h': delayConv = delayTime[k].innerHTML * oneHour; break; case 'm': delayConv = delayTime[k].innerHTML * oneMinute; break; case 's': delayConv = delayTime[k].innerHTML * oneSecond; break; }   var nextDate2 = new Date(nextDate.getTime + delayConv); while (nextDate.getTime <= now.getTime) { nextDate.setTime(nextDate.getTime + loopConv); i += 1; }   while (nextDate2.getTime <= now.getTime) { nextDate2.setTime(nextDate2.getTime + loopConv); }   var diff  = (nextDate.getTime  - now.getTime); var diff2 = (nextDate2.getTime - now.getTime); var yearsleft   = Math.floor(diff  / oneYear); var yearsleft2  = Math.floor(diff2 / oneYear); var monthsleft  = Math.floor(diff  / oneMonth); var monthsleft2 = Math.floor(diff2 / oneMonth); var daysleft    = Math.floor(diff  / oneDay); var daysleft2   = Math.floor(diff2 / oneDay); var hoursleft   = Math.floor(diff  / oneHour); var hoursleft2  = Math.floor(diff2 / oneHour); var minutesleft = Math.floor(diff  / oneMinute); var minutesleft2 = Math.floor(diff2 / oneMinute); var secondsleft = Math.floor(diff  / oneSecond); var secondsleft2 = Math.floor(diff2 / oneSecond); var Y_Count = 0, M_Count = 0, D_Count = 0, h_Count = 0, m_Count = 0, s_Count = 0; for (var position = 0; position < dateFormat[k].innerHTML.length; position++) { switch (dateFormat[k].innerHTML.charAt(position)) { case 'Y': Y_Count += 1; break; case 'M': M_Count += 1; break; case 'D': D_Count += 1; break; case 'h': h_Count += 1; break; case 'm': m_Count += 1; break; case 's': s_Count += 1; break; }   }    if (Y_Count === 0) {yearsleft   = 0; yearsleft2   = 0;} if (M_Count === 0) {monthsleft = 0; monthsleft2  = 0;} else { monthsleft = (monthsleft *oneMonth - yearsleft *oneYear) / oneMonth; monthsleft2 = (monthsleft2*oneMonth - yearsleft2*oneYear) / oneMonth; }   if (D_Count === 0) {daysleft    = 0; daysleft2    = 0;} else { daysleft = (daysleft *oneDay - yearsleft *oneYear - monthsleft *oneMonth) / oneDay; daysleft2 = (daysleft2*oneDay - yearsleft2*oneYear - monthsleft2*oneMonth) / oneDay; }   if (h_Count === 0) {hoursleft   = 0; hoursleft2   = 0;} else { hoursleft = (hoursleft *oneHour - yearsleft *oneYear - monthsleft *oneMonth - daysleft *oneDay) / oneHour; hoursleft2 = (hoursleft2*oneHour - yearsleft2*oneYear - monthsleft2*oneMonth - daysleft2*oneDay) / oneHour; }   if (m_Count === 0) {minutesleft = 0; minutesleft2 = 0;} else { minutesleft = (minutesleft *oneMinute - yearsleft *oneYear - monthsleft *oneMonth - daysleft *oneDay - hoursleft *oneHour) / oneMinute; minutesleft2 = (minutesleft2*oneMinute - yearsleft2*oneYear - monthsleft2*oneMonth - daysleft2*oneDay - hoursleft2*oneHour) / oneMinute; }   if (s_Count === 0) {secondsleft = 0; secondsleft2 = 0;} else { secondsleft = (secondsleft *oneSecond - yearsleft *oneYear - monthsleft *oneMonth - daysleft *oneDay - hoursleft *oneHour - minutesleft *oneMinute) / oneSecond; secondsleft2 = (secondsleft2*oneSecond - yearsleft2*oneYear - monthsleft2*oneMonth - daysleft2*oneDay - hoursleft2*oneHour - minutesleft2*oneMinute) / oneSecond; }   var Y_zeros  = , M_zeros  = , D_zeros  = , h_zeros  = , m_zeros  = , s_zeros  = ; var Y_zeros2 = , M_zeros2 = , D_zeros2 = , h_zeros2 = , m_zeros2 = , s_zeros2 = ; for (var j = 1; j < s_Count; j++) { if (secondsleft < Math.pow(10, s_Count - j)) s_zeros  = '0' + s_zeros; if (secondsleft2 < Math.pow(10, s_Count - j)) s_zeros2 = '0' + s_zeros2; }   for (j = 1; j < m_Count; j++) { if (minutesleft < Math.pow(10, m_Count - j)) m_zeros  = '0' + m_zeros; if (minutesleft2 < Math.pow(10, m_Count - j)) m_zeros2 = '0' + m_zeros2; }   for (j = 1; j < h_Count; j++) { if (hoursleft < Math.pow(10, h_Count - j)) h_zeros  = '0' + h_zeros; if (hoursleft2 < Math.pow(10, h_Count - j)) h_zeros2 = '0' + h_zeros2; }   for (j = 1; j < D_Count; j++) { if (daysleft < Math.pow(10, D_Count - j)) D_zeros  = '0' + D_zeros; if (daysleft2 < Math.pow(10, D_Count - j)) D_zeros2 = '0' + D_zeros2; }   for (j = 1; j < M_Count; j++) { if (monthsleft < Math.pow(10, M_Count - j)) M_zeros  = '0' + M_zeros; if (monthsleft2 < Math.pow(10, M_Count - j)) M_zeros2 = '0' + M_zeros2; }   for (j = 1; j < Y_Count; j++) { if (yearsleft < Math.pow(10, Y_Count - j)) Y_zeros  = '0' + Y_zeros; if (yearsleft2 < Math.pow(10, Y_Count - j)) Y_zeros2 = '0' + Y_zeros2; }   var yearunit = , monthunit  = , dayunit    = ''; var hourunit = , minuteunit = , secondunit = ''; if (dateLabels[k].innerHTML === 'full') { yearunit = ' Years'; monthunit = ' Months'; dayunit     = ' Days'; hourunit = ' Hours'; minuteunit = ' Minutes'; secondunit = ' Seconds'; } else if (dateLabels[k].innerHTML === 'single') { yearunit = 'Y'; monthunit = 'M'; dayunit    = 'D'; hourunit = 'h'; minuteunit = 'm'; secondunit = 's'; }   var sep = separators[k].innerHTML; if (separators[k].innerHTML === ) sep = ;

if ((Math.floor(diff2 / oneSecond) * oneSecond) < delayConv) { document.getElementById('bText_' + k).setAttribute("style","display:none"); document.getElementById('aText_' + k).setAttribute("style","display:none"); document.getElementById('aDelayText_' + k).setAttribute("style","display:visible"); document.getElementById('bDelayText_' + k).setAttribute("style","display:visible"); if (document.getElementById('delayCountDisplay_' + k).innerHTML === '') { if (Y_Count !== 0) $('#years_' + k).html(Y_zeros2  + yearsleft2   + yearunit   + sep); if (M_Count !== 0) $('#months_' + k).html(M_zeros2 + monthsleft2  + monthunit  + sep); if (D_Count !== 0) $('#days_' + k).html(D_zeros2   + daysleft2    + dayunit    + sep); if (h_Count !== 0) $('#hours_' + k).html(h_zeros2  + hoursleft2   + hourunit   + sep); if (m_Count !== 0) $('#minutes_' + k).html(m_zeros2 + minutesleft2 + minuteunit + sep); if (s_Count !== 0) $('#seconds_' + k).html(s_zeros2 + secondsleft2 + secondunit); } else { $('#years_' + k).html(); $('#months_' + k).html(); $('#days_' + k).html(''); $('#hours_' + k).html(); $('#minutes_' + k).html(); $('#seconds_' + k).html(''); }   } else { document.getElementById('bDelayText_' + k).setAttribute("style","display:none"); document.getElementById('aDelayText_' + k).setAttribute("style","display:none"); document.getElementById('aText_' + k).setAttribute("style","display:visible"); document.getElementById('bText_' + k).setAttribute("style","display:visible"); if (Y_Count !== 0) $('#years_' + k).html(Y_zeros  + yearsleft   + yearunit   + sep); if (M_Count !== 0) $('#months_' + k).html(M_zeros + monthsleft  + monthunit  + sep); if (D_Count !== 0) $('#days_' + k).html(D_zeros   + daysleft    + dayunit    + sep); if (h_Count !== 0) $('#hours_' + k).html(h_zeros  + hoursleft   + hourunit   + sep); if (m_Count !== 0) $('#minutes_' + k).html(m_zeros + minutesleft + minuteunit + sep); if (s_Count !== 0) $('#seconds_' + k).html(s_zeros + secondsleft + secondunit); }   document.getElementById('loopCount_' + k).innerHTML = i;    document.getElementById('countXinterval_' + k).innerHTML = i * loopTime[k].innerHTML; } } var count         = document.getElementsByClassName("custom-countdown"); var loopCount     = document.getElementsByClassName('loopCount'); var countXinterval = document.getElementsByClassName('countXinterval'); var bText         = document.getElementsByClassName('bText'); var bDelayText    = document.getElementsByClassName('bDelayText'); var years         = document.getElementsByClassName('years'); var months        = document.getElementsByClassName('months'); var days          = document.getElementsByClassName('days'); var hours         = document.getElementsByClassName('hours'); var minutes       = document.getElementsByClassName('minutes'); var seconds       = document.getElementsByClassName('seconds'); var aText         = document.getElementsByClassName('aText'); var aDelayText    = document.getElementsByClassName('aDelayText'); var seedDate      = document.getElementsByClassName('seedDate'); var loopTime      = document.getElementsByClassName('loopTime'); var loopUnit      = document.getElementsByClassName('loopTimeUnit'); var delayTime     = document.getElementsByClassName('delayTime'); var delayUnit     = document.getElementsByClassName('delayTimeUnit'); var delayDisplay  = document.getElementsByClassName('delayCountDisplay'); var dateFormat    = document.getElementsByClassName('dateFormat'); var dateLabels    = document.getElementsByClassName('dateLabels'); var separators    = document.getElementsByClassName('separators'); for (var k = 0; k < count.length; k++) { loopCount[k].id = 'loopCount_'     + k; countXinterval[k].id = 'countXinterval_'    + k;    bText[k].id      = 'bText_'         + k; bDelayText[k].id     = 'bDelayText_'        + k;    years[k].id      = 'years_'         + k; months[k].id         = 'months_'            + k;    days[k].id       = 'days_'          + k; hours[k].id          = 'hours_'             + k;    minutes[k].id    = 'minutes_'       + k; seconds[k].id        = 'seconds_'           + k;    aText[k].id      = 'aText_'         + k; aDelayText[k].id     = 'aDelayText_'        + k;    seedDate[k].id   = 'seedDate_'      + k; loopTime[k].id       = 'loopTime_'          + k;    loopUnit[k].id   = 'loopTimeUnit_'  + k; delayTime[k].id      = 'delayTime_'         + k;    delayUnit[k].id  = 'delayTimeUnit_' + k; delayDisplay[k].id   = 'delayCountDisplay_' + k;    dateFormat[k].id = 'dateFormat_'    + k; dateLabels[k].id     = 'dateLabels_'        + k;    separators[k].id = 'separators_'    + k; } Countdown(seedDate, loopTime, loopUnit, delayTime, delayUnit, dateFormat, dateLabels, separators); setInterval(function { Countdown(seedDate, loopTime, loopUnit, delayTime, delayUnit, dateFormat, dateLabels, separators) }, 1000); /* FINNER/Test10 END */

/////////////////////////////////////////////////////////////////////////////////   /* FINNER/Dupes START *

dil = new Array; function findDupImages(gf) { output = ""; url = "/api.php?action=query&generator=allimages&prop=duplicatefiles&gailimit=5000&format=json"; if (gf) url += "&gaifrom=" + gf; $.getJSON(url,function (data) { if (data.query) { pages = data.query.pages; for (pageID in pages) { dils = ","+dil.join; if (dils.indexOf(","+pages[pageID].title) == -1 && pages[pageID].title.indexOf("File::") == -1 && pages[pageID].duplicatefiles) { output += " "+pages[pageID].title+" \n\n"; for (x=0;xFile:"+pages[pageID].duplicatefiles[x].name+"\n"; dil.push("File:"+pages[pageID].duplicatefiles[x].name.replace(/_/g," ")); } output += "\n\n"; } } $("#mw-dupimages").append(output); if (data["query-continue"]) setTimeout("findDupImages('"+data["query-continue"].allimages.gaifrom+"');",5000); } }); } $(function { if ($("#mw-dupimages").length) findDupImages; });

/* FINNER/Dupes END */