„Benutzer:TestBotOnly/vector.js“ – Versionsunterschied
Erscheinungsbild
Inhalt gelöscht Inhalt hinzugefügt
Keine Bearbeitungszusammenfassung |
AZ: Der Seiteninhalt wurde durch einen anderen Text ersetzt. |
||
Zeile 1: | Zeile 1: | ||
jQuery('#siteNotice').html('<div id="editorSurvey2011" style="display:none"><div id="editorSurvey2011-logo"> </div><div id="editorSurvey2011-content"><!-- TODO: replace by localized {{{BannerHtml}}} --><span style="font-size: 1em;line-height: 1.5em;"><a id="editorSurveyLink" style="color:black" target="_blank" href="http://survey.wikipediaresearch.org/?a=1&b="><b>Wie zufrieden bist Du mit Wikipedia? <u>Dein</u> Feedback ist uns wichtig!</b><br/>Als kleines Dankeschön für die Unterstützung verlosen wir Wikipedia T-Shirts.<br/>Klicke hier, um mehr zu erfahren!</a></span></div><div id="cn-toggle-box"><a id="editorSurveyClose" href="#"><img border="0" src="http://bits.wikimedia.org/skins-1.17/common/images/closewindow.png" alt="Close" /></a></div></div>'); |
|||
const constSamplingRate = 1 / 1; //<!-- TODO: replace by localized {{{SamplingRate}}} --> |
|||
const constDisplayTimeSpan = 3 ; //<!-- TODO: replace by localized {{{DisplayTimeSpan}}} --> |
|||
const constDone = 'done'; |
|||
const constTodo = 'todo'; |
|||
$(document).ready( function() |
|||
{ |
|||
wmdeslog( '$(document).ready' ); |
|||
// If the survey should not be hidden... |
|||
if ( $.cookie( 'surveyStatus' ) != constDone ) |
|||
{ |
|||
initSurveyIfNeeded(); |
|||
} |
|||
} ); |
|||
function initSurveyIfNeeded() |
|||
{ |
|||
wmdeslog( 'initSurveyIfNeeded' ); |
|||
// If the users has been picked to participate in the survey |
|||
if ( $.cookie( 'surveyStatus' ) == constTodo ) |
|||
{ |
|||
var startTime = $.cookie( 'surveyStartTime' ); |
|||
// If the start of the survey is set, display it when still within 5 mins, otherwise set done. |
|||
if ( startTime != null ) |
|||
{ |
|||
if ( parseInt( startTime ) + ( 1000*60* constDisplayTimeSpan ) > (new Date()).getTime() ) |
|||
{ |
|||
displaySurvey(); |
|||
} |
|||
else |
|||
{ |
|||
setSurveyStatus( constDone ); |
|||
} |
|||
} |
|||
// If the start of the survey is not set, check for the right page (first page that is not an "action" page) |
|||
else if ( window.location.toString().indexOf( 'action=' ) == -1 ) |
|||
{ |
|||
$.cookie( 'surveyStartTime', (new Date()).getTime().toString(), { 'expires': 31 /* days */, 'path': '/' } ); |
|||
mw.loader.using( 'jquery.clicktracking', function() { $.trackAction( 'wmdesurvey-surveyparticipant' ); } ); |
|||
displaySurvey(); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
// If the user is an editor, do lottery. |
|||
if ( window.location.toString().indexOf( 'action=edit' ) != -1 ) |
|||
{ |
|||
var selectionSize = constSamplingRate ; |
|||
// If the user wins the lottery, set DisplayTodo |
|||
if ( Math.random() < selectionSize ) |
|||
{ |
|||
setSurveyStatus( constTodo ); |
|||
} |
|||
// If the user loses, set done. |
|||
else |
|||
{ |
|||
setSurveyStatus( constDone ); |
|||
} |
|||
} |
|||
// (If the user is not an editor, do nothing.) |
|||
} |
|||
} |
|||
function setSurveyStatus( status ) |
|||
{ |
|||
wmdeslog( 'setSurveyStatus: ' + status ); |
|||
$.cookie( 'surveyStatus', status, { 'expires': 31 /* days */, 'path': '/' } ); |
|||
} |
|||
function displaySurvey() |
function displaySurvey() |
||
{ |
{ |
||
Zeile 83: | Zeile 6: | ||
$( '#editorSurveyClose' ).click( onSurveyCloseClick ); |
$( '#editorSurveyClose' ).click( onSurveyCloseClick ); |
||
$( '#editorSurvey2011' ).show(); |
|||
if (!wgNoticeToggleState) toggleNotice(); |
|||
} |
|||
$( '#editorSurvey2011' ).show(); |
|||
var isFirstClick = true; |
|||
function onSurveyLinkClick() |
|||
{ |
|||
wmdeslog( 'onSurveyLinkClick' ); |
|||
if ( isFirstClick ) |
|||
{ |
|||
wmdeslog( 'onSurveyLinkClick - first click' ); |
|||
setSurveyStatus(constDone); |
|||
var sender = $( this ); |
|||
sender.attr( 'href', sender.attr( 'href' ) + Math.random().toString().substring(2)); |
|||
isFirstClick = false; |
|||
} |
|||
return true; |
|||
} |
|||
function onSurveyCloseClick() |
|||
{ |
|||
$( '#editorSurvey2011' ).hide(); |
|||
setSurveyStatus( constDone ); |
|||
} |
|||
function wmdeslog( message ) { |
|||
console.log( 'WMDE survey: ' + message ); |
|||
} |
} |