r71281 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71280‎ | r71281 | r71282 >
Date:00:39, 19 August 2010
Author:adam
Status:deferred
Tags:
Comment:
Adding the stub of new javascript code for central notice. Not currently in use, just an outline of what I think will need built to support the testing outlined in phase three of central notice
Modified paths:
  • /trunk/extensions/CentralNotice/newCentralNotice.js (added) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/newCentralNotice.js
@@ -0,0 +1,77 @@
 2+/*
 3+ * New Central Notice Javascript
 4+ *
 5+ * Mostly stubbed functionallity for central notice improvements
 6+ * May or may not be used, definitely will be changed.
 7+ * More of a sketch of what we think needs to be done.
 8+ *
 9+ * QUESTIONS:
 10+ * 1. How do I determin if a user is logged in or not?
 11+ * 2. How do I determin a users location?
 12+ *
 13+ */
 14+( function( $ ) {
 15+ $.centralNotice = {
 16+ 'data': {
 17+ 'getVars': {}
 18+ },
 19+ 'fn': {
 20+ 'loadBanner': function( bannerName ) {
 21+ // get the requested banner from /centralnotice/banners/<bannername>/<wgUserLanguage>.js
 22+ var request = $.ajax( {
 23+ url: 'response.html',
 24+ dataType: 'html',
 25+ success: function( data ) {
 26+ $.centralNotice.fn.displayBanner( data );
 27+ }
 28+ });
 29+ },
 30+ 'loadCampaign': function( timestamp ) {
 31+ var listURL;
 32+ if ( timestamp ) {
 33+ listURL = "TBD"
 34+ } else {
 35+ listURL = "/centralnotice/<project type>/<wgContentLanguage>.js"
 36+ }
 37+ var request = $.ajax( {
 38+ url: listURL,
 39+ dataType: 'json',
 40+ success: function( data ) {
 41+ $.centralNotice.fn.chooseBanner( data );
 42+ }
 43+ } );
 44+ },
 45+ 'chooseBanner': function( bannerList ) {
 46+ // pick a banner based on logged-in status and geotargetting
 47+ var bannerHTML = bannerList[0].html;
 48+ $.centralNotice.fn.displayBanner( bannerHTML );
 49+ },
 50+ 'displayBanner': function( bannerHTML ) {
 51+ // inject the banner html into the page
 52+ $( '#centralNotice' ).replaceWith( bannerHTML );
 53+ },
 54+ 'getQueryStringVariables': function() {
 55+ document.location.search.replace( /\??(?:([^=]+)=([^&]*)&?)/g, function () {
 56+ function decode( s ) {
 57+ return decodeURIComponent( s.split( "+" ).join( " " ) );
 58+ }
 59+ $.centralNotice.data.getVars[decode( arguments[1] )] = decode( arguments[2] );
 60+ } );
 61+ }
 62+ }
 63+ }
 64+ $( document ).ready( function () {
 65+ // initialize the query string vars
 66+ $.centralNotice.fn.getQueryStringVariables();
 67+ if( $.centralNotice.data.getVars['forceBanner'] ) {
 68+ // if we're forcing one banner
 69+ $.centralNotice.fn.loadBanner( $.centralNotice.data.getVars['forceBanner'] );
 70+ } else if ( $.centralNotice.data.getVars['forceTimestamp'] ) {
 71+ // if we're forcing a future campaign time
 72+ $.centralNotice.fn.loadCampaign( $.centralNotice.data.getVars['forceTimestamp'] );
 73+ } else {
 74+ // look for banners ready to go NOW
 75+ $.centralNotice.fn.loadCampaign( );
 76+ }
 77+ } ); //document ready
 78+} )( jQuery );
Property changes on: trunk/extensions/CentralNotice/newCentralNotice.js
___________________________________________________________________
Added: svn:eol-style
179 + native

Status & tagging log