User:Twilight Maxxis/clogs.js

/* * QLicense.js, [originally] by User:Cakemix, decoded and formatted. * Decoded, formatted, and shortened by Monchoman45. */ function QLicenseUI { window.qapi = new APIQuery; var options = { '': 'Public domain', '': 'Game Screenshot', '': 'Fair use' };	var optstr = ''; for(i in options) {optstr += '' + options[i] + ' ';} var html = '' + optstr + ' Add license'; if(document.getElementById('LicensedFile') || document.getElementById('Copyright')) {html += ' This file is licensed. ';}	else {html += ' This file is not licensed. ';}	$('#filetoc').append(html); document.getElementById('aSubmit').onclick = function(event) { qapi.send(new qapi.Query(qapi, 'POST', 'action=edit&title=' + wgPageName + '&appendtext=' + document.getElementById('QLicenseSelect').value + '&summary=Licensing image', function(result) { if(result.edit.result == 'Success') {window.location = wgServer + '/index.php?title=' + wgPageName + '&action=purge';} else {alert('An error occurred while submitting the edit.');} }));		this.innerHTML = ''; } } if(wgCanonicalNamespace == 'File') { addOnloadHook(QLicenseUI); importScriptPage('MediaWiki:APIQuery.js', 'monchbox'); } // ******************* // Custom edit buttons // ******************* if (wgAction == "edit" || wgAction == "submit") { /***** Custom edit buttons *****/ if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images4.wikia.nocookie.net/callofduty/images/5/5e/Button_welcome_141.png", "speedTip": "Welcome user (TF141)", "tagOpen": "", "tagClose": "", "sampleText": wgUserName}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images1.wikia.nocookie.net/callofduty/images/6/60/Button_welcome_price.png", "speedTip": "Welcome user (Price)", "tagOpen": "", "tagClose": "", "sampleText": wgUserName}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/__cb20120128095141/callofduty/images/2/2c/CreeperForEmote.jpg", "speedTip": "Vandalism Template", "tagOpen": "", "tagClose": "", "sampleText": "PAGE"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/__cb20100708142061/callofduty/images/b/b9/Button_Bblock.jpg", "speedTip": "B", "tagOpen": "", "tagClose": "", "sampleText": "DURATION"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/__cb20100502153339/callofduty/images/1/17/Button_Ssig.jpg", "speedTip": "Signature", "tagOpen": " ~"+""+"", "tagClose": "", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/central/images/c/c8/Button_redirect.png", "speedTip": "Redirect", "tagOpen": "#redirect",               "tagClose": "", "sampleText": "PAGE"}; } } // *********************** // End custom edit buttons // ***********************

// //import this using importScript('User:Joeytje50/ChatLogger.js') //To set an interval of submitting logs, put var logInterval = (amount of milliseconds); above the import. Default is 1 hour. //cookie functions function setCookie( c_name, value, expiredays ) { var exdate = new Date; exdate.setDate( exdate.getDate + expiredays); document.cookie = c_name + "=" + escape(value) + ( ( expiredays === null ) ? "" : ";expires=" + exdate.toGMTString ); } function getCookie( c_name ) { if ( document.cookie.length > 0 ) { var c_start = document.cookie.indexOf( c_name + "=" ) if ( c_start !== -1 ) { c_start = c_start + c_name.length + 1; var c_end = document.cookie.indexOf( ";", c_start ); if ( c_end === -1 ) { c_end = document.cookie.length; }			return unescape( document.cookie.substring( c_start, c_end ) ); } 	}	return ""; } //Script if (wgCanonicalSpecialPageName=="Chat" && skin=="oasis") { if (getCookie('lastRestart') == "") { setCookie('lastRestart', 0, 1000) } //--- function restartChat { window.chatwindow = window.open('/index.php?title=Special:Chat&useskin=wikia'); window.chatwindow.onload = function { window.chatwindow.$('body').prepend(' \nfunction importScript(b){var a=wgScript+"?title="+encodeURIComponent(b.replace(/ /g,"_")).replace(/%2F/ig,"/").replace(/%3A/ig,":")+"&action=raw&ctype=text/javascript";return importScriptURI(a)}\nfunction importScriptURI(a){var b=document.createElement("script");b.setAttribute("src",a);b.setAttribute("type","text/javascript");document.getElementsByTagName("head")[0].appendChild(b);return b}\nfunction importScriptPage(b,d){var a="/index.php?title="+encodeURIComponent(b.replace(/ /g,"_")).replace("%2F","/").replace("%3A",":")+"&action=raw&ctype=text/javascript";if(typeof d=="string"){if(d.indexOf("://")==-1){a="http://"+d+".wikia.com"+a}else{a=d+a}}return importScriptURI(a)}\nfunction importStylesheet(a){return importStylesheetURI(wgScript+"?action=raw&ctype=text/css&title="+encodeURIComponent(a.replace(/ /g,"_")))}\nfunction importStylesheetURI(b,d){var a=document.createElement("link");a.type="text/css";a.rel="stylesheet";a.href=b;if(d){a.media=d}document.getElementsByTagName("head")[0].appendChild(a);return a}\nfunction importStylesheetPage(b,d){var a="/index.php?title="+encodeURIComponent(b.replace(/ /g,"_")).replace("%2F","/").replace("%3A",":")+"&action=raw&ctype=text/css";if(typeof d=="string"){if(d.indexOf("://")==-1){a="http://"+d+".wikia.com"+a}else{a=d+a}}return importStylesheetURI(a)}\n//This isn\'t the same as the regular addOnloadHook, because the regular one runs from a script tag in the body that I don\'t feel like appending. It\'s easier to just make it $(function), which is essentially equivalent\nfunction addOnloadHook(func) {$(func);}\n ');		//global.js		window.chatwindow.importScriptURI('http://community.wikia.com/index.php?title=User:' + wgUserName + '/global.js&action=raw&ctype=text/javascript');		//wikia.js		window.chatwindow.importScriptURI(wgServer + '/index.php?title=User:' + wgUserName + '/wikia.js&action=raw&ctype=text/javascript');		//global.css		window.chatwindow.importStylesheetURI('http://community.wikia.com/index.php?title=User:' + wgUserName + '/global.css&action=raw&ctype=text/css');		//wikia.css		window.chatwindow.importStylesheetURI(wgServer + '/index.php?title=User:' + wgUserName + '/wikia.css&action=raw&ctype=text/css');		window.close	} } function dcRestart {	if ($('.inline-alert:contains("You have been disconnected")').length > 0) {		submitLog('restart')	}	callAPI({ 'action': 'query', 'prop': 'info|revisions', 'titles': 'User:'+wgUserName+'/Restart', 'rvprop': 'content', 'rvlimit': '1', 'indexpageids': 'true', }, 'GET', function(response) { var page = response.query.pages[response.query.pageids[0]]; var restartPage = page.revisions[0]['*'].split('\n')[0] if (escape(restartPage) != getCookie('lastRestart')) { setCookie('lastRestart', restartPage, 1000) submitLog('restartChat') }	}) } //--- var d = new Date var curTime = [,,] curTime[0] = d.getUTCHours; curTime[1] = d.getUTCMinutes; curTime[2] = d.getUTCSeconds; var timeTillMidnight = ((23-curTime[0])*60*60000)+((59-curTime[1])*60000)+((60-curTime[2])*1000) setTimeout('setInterval("submitLog",86400000)',timeTillMidnight) setTimeout('submitLog',timeTillMidnight) setInterval('dcRestart',60000) var logInterval = logInterval?logInterval:2000000; //--- function toUTCTime(ts) {	var tz = d.getTimezoneOffset/60;	var hour = parseInt(ts.split(':')[0]);	var UTChour = hour+tz;	if (UTChour<1) {		UTChour = 12+UTChour;	} else if (UTChour>12) {		UTChour = UTChour-12;	}	var UTCtime = ((UTChour+).length==1?'0':)+UTChour+':'+ts.split(':')[1]+(ts.split(':').length>=3?':'+ts.split(':')[2]:);	return UTCtime; } //--- function getLog(exists,content) {	//Getting arrays with messages and senders	var allmsgs = document.getElementsByClassName('Chat')[0].getElementsByClassName('message'); var message = allmsgs[0].innerHTML; var msguser = allmsgs[0].parentNode.getAttribute('data-user'); var msgtime = toUTCTime(allmsgs[0].parentNode.getElementsByClassName('time')[0].innerHTML); for (i=1;allmsgs[i];i++) { message += '<|>'+allmsgs[i].innerHTML; msguser += '<|>'+allmsgs[i].parentNode.getAttribute('data-user'); msgtime += '<|>'+toUTCTime(allmsgs[i].parentNode.getElementsByClassName('time')[0].innerHTML); }	message = message.split('<|>') msguser = msguser.split('<|>') msgtime = msgtime.split('<|>') //Turning the format into a log instead of arrays var ChatLog=''; for (i=0;message[i];i++) { ChatLog += '['+msgtime[i]+'] <'+msguser[i]+'> '+message[i]+'\n' }	while (ChatLog.match(/\n[^\[]/)) { ChatLog = ChatLog.replace(/\[(\d\d?:\d\d)\] <([^>]*)> (.*)\n([^\[<])/g, '[$1] <$2> $3\n[$1] <$2> $4') }	var wikilinks = new RegExp('([^<]*)','g')	var rmUScore = /\[\[([^\]]*?)_(([^\]]*?)_)?(([^\]]*?)_)?(([^\]]*?)_)?(([^\]]*?)_)?(([^\]]*?)_)?(([^\]]*?)_)?/g	ChatLog = ChatLog.replace(/( |	){2,}/g, ' ').replace(/]*>/g, '$1').replace(wikilinks, '$2').replace(rmUScore,'$1 $3 $5 $7 $9 $11 $13 ').replace(/\[\[([^\*?) {2,}/g, ']*)\|\1/g, '$1').replace(/[^<]*<\/a>/g, '$1').replace('|'+wgServer+'/wiki/', wgServer+'/wiki/') //HTML img and a tag fixes active.clearWindow var returnThis = exists?content.replace(' ',ChatLog+' '):'\n'+ChatLog+' \n' return returnThis } //--- function callAPI(data, method, callback) { data['format'] = 'json'; $.ajax({		data: data,		dataType: 'json',		url: wgScriptPath + '/api.php',		type: method,		success: function(response) {			if (response.error)				showError('API error: ' + response.error.info);			else 				callback(response);		},		error: function(xhr, error) { showError('AJAX error: ' + error); }	}); } //--- function submitLog(restart) { restart = restart?restart:false; var d = new Date var monthNames = ["January","February","March","April","May","June","July","August","September","October","November","December"]; var date = d.getUTCDate + '_' + monthNames[d.getUTCMonth] + '_' + d.getUTCFullYear callAPI({		'action': 'query',		'prop': 'info|revisions',		'intoken': 'edit',		'titles': 'User:Twilight_Maxxis/Chat_session_archive/'+date,		'rvprop': 'content',		'rvlimit': '1',		'indexpageids': 'true',	}, 'GET', function(response) {		var page = response.query.pages[response.query.pageids[0]];		var pageExists = response.query.pages["-1"]?false:true;		var content = typeof(page["revisions"])!="undefined"?page.revisions[0]['*']:'';		callAPI({ 'minor': 'yes', 'summary': 'Adding the chat log, no need to tell about', 'action': 'edit', 'title': 'User:Twilight_Maxxis/Chat_session_archive/'+date, 'startimestamp': page.starttimestamp, 'token': page.edittoken, 'text': getLog(pageExists,content) }, 'POST', function(response) { restart?restartChat:''; });	}); } setInterval('submitLog', logInterval) }