Jump to content

User:TestBotOnly/vector.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by TestBotOnly (talk | contribs) at 13:37, 23 May 2011 (Created page with 'jQuery('#mp-topbanner').html('<div id="editorSurvey2011" style="display:none"><div id="editorSurvey2011-logo"> </div><div id="editorSurvey2011-content"><span style=...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
jQuery('#mp-topbanner').html('<div id="editorSurvey2011" style="display:none"><div id="editorSurvey2011-logo"> </div><div id="editorSurvey2011-content"><span style="font-size: 1.3em;"><a target=”_blank” href=”http://www.test.de/”><b>Wie zufrieden bist du mit Wikipedia? <u>Dein</u> Feedback ist wichtig!</b><br/>Als Dankeschön erhältst du die Chance, ein Wikipedia T-Shirt zu gewinnen.<br/>Klicke hier, um an der Befragung teilzunehmen!</a></span><br /></div><div id="cn-toggle-box"><a href="#" onclick="toggleNotice();$(\"#editorSurvey2011\").hide();return false;"><img border="0" src="http://bits.wikimedia.org/skins-1.17/common/images/closewindow.png" alt="Close" /></a></div></div>');

jQuery(document).ready( function() {
console.log('jQuery(document).ready');
	// If the survey should not be hidden...
	if ( document.cookie.indexOf('isDoneWithSurvey=1') == -1 ) {
		initSurveyIfNeeded();
	}
} );

function initSurveyIfNeeded() {
console.log('initSurveyIfNeeded');
	var tsSetting = 'surveyStartTime=';
	var timeStampLocation = document.cookie.indexOf( tsSetting );

	// If the start of the survey is set, display it when still within 5 mins, otherwise set done.
	if ( timeStampLocation != -1 ) {
		if ( parseInt( document.cookie.substr( timeStampLocation + tsSetting.length, 13 ) ) + ( 1000*60*3 ) > (new Date()).getTime() ) {
			displaySurvey();
		}
		else {
			setSurveyDone();
		}
	} // If the survey has not started yet and the user is an editor, do lottery.
	else if ( window.location.toString().indexOf( 'action=edit' ) != -1 ) {
		var selectionSize = 1 / 1;
		
		// If the user wins the lottery, set the start of the survey and display it.
		if ( Math.random() < selectionSize ) {
			var currentTime = (new Date()).getTime();
			document.cookie = 'surveyStartTime=' + currentTime.toString() + '; expires=' + ( currentTime + (31*24*60*60*1000) ).toString() + '; path=/';
			displaySurvey();
		} // If the user loses, set done.
		else {
			setSurveyDone();
		}
	}
}

function setSurveyDone() {
console.log('setSurveyDone');
	document.cookie = 'isDoneWithSurvey=1; expires=' + ( (new Date()).getTime() + (31*24*60*60*1000) ).toString() + '; path=/';
}

function displaySurvey() {
console.log('displaySurvey');
	jQuery('#editorSurvey2011').show();
	jQuery('head').append('<link rel="stylesheet" href="http://wikimediafoundation.org/tracker/bannerImpression.php?req=css&surveyView=1 " type="text/css" />');
}