MediaWiki:Common.js/lockoldblogs.js

/** * lockoldblogs.js * * Locks blog posts that haven't been commented on for over 30 days * @author slyst */

var lock = { status: 'enabled', observer: function { var m = new MutationObserver(function(mutations) {               mutations.forEach(function(mutation) { if (mutation.addedNodes.length) { var target = $(mutation.addedNodes).find('.comment .speech-bubble-message').find('.permalink'), link = target.attr('href'), date = new Array(/@comment-\w*-(\w{4})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(?=\?)/gi.exec(link)).pop; if (date) { var then = Date.parse(date[1] + '-' + date[2] + '-' + date[3] + 'T' + date[4] + ':' + date[5] + ':' + date[6] + '.000Z'), now = Date.now, /* diff is a new date formed by the difference of the two; offset: Jan 01 1970 */ diff = new Date(now - then); /* either not january || january but not 1970 → 30 days have passed */ if (diff.getMonth > 0 || (diff.getMonth == 0 && diff.getFullYear > 1970)) { lock.status = 'disabled'; lock.disable; }                       }                        /* we don't disconnect here to watch out for pagination changes */ }               });            });            m.observe(document.getElementById('WikiaArticleComments'), {                attributes: true,                childList: true,                subtree: true            }); },       disable: function { if (this.status == 'disabled') { /* comment box */ $('#article-comm').attr({                   disabled: 'disabled',                    placeholder: 'This blog post hasn\'t been commented on for over 30 days. There is no need to comment.'                }); /* submit button */ $('#article-comm-submit').remove; /* reply buttons */ $('.article-comm-reply').each(function {                   $(this).remove;                }); /* edit links */ $('.tools .edit-link').each(function {                   $(this).remove;                }); }       }    };    $(lock.observer); })(window.mediaWiki);
 * (function(mw) {