MediaWiki:Geonotice.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button. Firefox: hold down the Shift key while clicking Reload (or press Ctrl-Shift-R). Google Chrome and Safari users can just click the Reload button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.

var notices = {

AmbassadorsSouthBend:
{
  begin : '4 January 2011 00:00 UTC',
  end: '4 February 2012 00:00 UTC',
  corners: [ [41.47,-86.05], [41.87,-86.45] ],
  text: 'Wikipedians of South Bend: A professor at Notre Dame is looking for Wikipedia Campus Ambassadors for the upcoming spring semester! <a href="' + mw.util.wikiGetlink( 'Special:EmailUser/Etlib') + '">Contact us</a> if you are interested.'
},

GLAMBL:
{
   begin: '24 December 2011 00:00 UTC',
   end: '17 January 2012 23:00 UTC',
   corners:[ [60,-9], [50.2, 1.3] ], 
   text: 'Guided tour of British Library <a href="http://www.bl.uk/royal">Royal Manuscripts: The Genius of Illumination</a> exhibition, evening of January 17, <a href="http://en.wikipedia.org/wiki/Wikipedia:GLAM/BL/Royal">sign up here</a>.'
},

AmbassadorsBloomington:
{
  begin : '24 December 2011 00:00 UTC',
  end: '24 January 2012 00:00 UTC',
  corners: [ [38.95,-86.3], [39.35,-86.7] ],
  text: 'The Wikipedia Education Program is now accepting applications for [[:outreach:Wikipedia_Recruitment_Ambassadors|Recruitment Ambassadors]] in Bloomington. Please follow the link to read more about this awesome volunteer position!'
},

AmbassadorsIndy:
{
  begin : '24 December 2011 00:00 UTC',
  end: '24 January 2012 00:00 UTC',
  corners: [ [39.5,-85.9], [40.0,-86.4] ],
  text: 'The Wikipedia Education Program is now accepting applications for [[:outreach:Wikipedia_Recruitment_Ambassadors|Recruitment Ambassadors]] in Indianapolis. Please follow the link to read more about this awesome volunteer position!'
},

AmbassadorsDetroit:
{
  begin : '24 December 2011 00:00 UTC',
  end: '24 January 2012 00:00 UTC',
  corners: [ [42.1,-82.8], [42.5,-83.2] ],
  text: 'The Wikipedia Education Program is now accepting applications for [[:outreach:Wikipedia_Recruitment_Ambassadors|Recruitment Ambassadors]] in Detroit. Please follow the link to read more about this awesome volunteer position!'
},

AmbassadorsAnnArbor:
{
  begin : '24 December 2011 00:00 UTC',
  end: '24 January 2012 00:00 UTC',
  corners: [ [42.1,-83.5], [42.5,-83.9] ],
  text: 'The Wikipedia Education Program is now accepting applications for [[:outreach:Wikipedia_Recruitment_Ambassadors|Recruitment Ambassadors]] in Ann Arbor. Please follow the link to read more about this awesome volunteer position!'
},

AmbassadorsSanFrancisco:
{
  begin : '24 December 2011 00:00 UTC',
  end: '24 January 2012 00:00 UTC',
  corners: [ [37.6,-122.2], [38.0,-122.6] ],
  text: 'The Wikipedia Education Program is now accepting applications for [[:outreach:Wikipedia_Recruitment_Ambassadors|Recruitment Ambassadors]] in San Francisco. Please follow the link to read more about this awesome volunteer position!'
},

AmbassadorsSeattle:
{
  begin : '24 December 2011 00:00 UTC',
  end: '24 January 2012 00:00 UTC',
  corners: [ [47.4,-122.1], [47.8,-122.5] ],
  text: 'The Wikipedia Education Program is now accepting applications for [[:outreach:Wikipedia_Recruitment_Ambassadors|Recruitment Ambassadors]] in Seattle. Please follow the link to read more about this awesome volunteer position!'
},

AmbassadorsDC:
{
  begin : '24 December 2011 00:00 UTC',
  end: '24 January 2012 00:00 UTC',
  corners: [ [38.7,-76.8], [39.1,-77.2] ],
  text: 'The Wikipedia Education Program is now accepting applications for [[:outreach:Wikipedia_Recruitment_Ambassadors|Recruitment Ambassadors]] in D.C. Please follow the link to read more about this awesome volunteer position!'
},

AmbassadorsMuncie:
{
  begin : '24 December 2011 00:00 UTC',
  end: '24 January 2012 00:00 UTC',
  corners: [ [40.0,-85.2], [40.4,-85.6] ],
  text: 'Wikipedians of Muncie: A professor at Ball State is looking for Wikipedia Campus Ambassadors for the upcoming spring semester! <a href="' + mw.util.wikiGetlink( 'Special:EmailUser/Etlib') + '">Contact us</a> if you are interested.'
},

NorthernOnRegional:
{
begin: '22 December 2011 00:00 UTC',
  end: 'January 22 2012 00:00 UTC',
  corners:[ [54.0, -95.0], [48.0, -79.4] ],
  text: 'Are you interested in encouraging more university professors to use Wikipedia as a teaching tool? Do you enjoy leading, coordinating, and organizing teams? If so, we want you! We are now recruiting for a Wikipedia Regional Ambassador to Ontario. [[:outreach:Regional_Ambassadors/Apply|Click here for more details.]]'
},

CentralOnRegional:
{
begin: '22 December 2011 00:00 UTC',
  end: 'January 22 2012 00:00 UTC',
  corners:[ [48.0, -78.5], [46.2, -86.0] ],
  text: 'Are you interested in encouraging more university professors to use Wikipedia as a teaching tool? Do you enjoy leading, coordinating, and organizing teams? If so, we want you! We are now recruiting for a Wikipedia Regional Ambassador to Ontario. [[:outreach:Regional_Ambassadors/Apply|Click here for more details.]]'
},

SouthernOnRegional:
{
begin: '22 December 2011 00:00 UTC',
  end: 'January 22 2012 00:00 UTC',
  corners:[ [46.2, -74.4], [41.9, -83.1] ],
  text: 'Are you interested in encouraging more university professors to use Wikipedia as a teaching tool? Do you enjoy leading, coordinating, and organizing teams? If so, we want you! We are now recruiting for a Wikipedia Regional Ambassador to Ontario. [[:outreach:Regional_Ambassadors/Apply|Click here for more details.]]'
},

NARA4:
{
begin: '22 December 2011 00:00 UTC',
  end: 'January 8 2012 00:00 UTC',
  corners:[ [41.6, -79.5], [36.5, -73] ], 
  text: 'You are invited to participate in Wikipedia\'s [[meta:w:en:Wikipedia:Meetup/NARA 4|National Archives ExtravaSCANza]], taking place January 4–7. Please [[meta:w:en:Wikipedia:Meetup/NARA 4|sign up and submit ideas]].'
},

RCC2012CBR:
{
  begin : '18 December 2011 00:00 UTC',
  end: '23 January 2012 00:00 UTC',
  corners: [ [-10.8,110.1], [-48.0,180] ],
  text: 'The [[v:University of Canberra/RCC2012|2012 RecentChangesCamp conference]], at the University of Canberra, takes place from 20 to 22 January 2011.  Travel grants available.'
},


AmbassadorsLansing:
{
  begin : '18 December 2011 00:00 UTC',
  end: '18 January 2012 00:00 UTC',
  corners: [ [42.5,-84.3], [42.9,-84.7] ],
  text: 'Wikipedians of Lansing: A professor at Lansing Community College is looking for Wikipedia Campus Ambassadors for the upcoming spring semester! <a href="' + mw.util.wikiGetlink( 'Special:EmailUser/Bob the Wikipedian') + '">Contact us</a> if you are interested.'
},

AmbassadorsJackson:
{
  begin : '18 December 2011 00:00 UTC',
  end: '18 January 2012 00:00 UTC',
  corners: [ [42.0,-84.2], [42.4,-84.6] ],
  text: 'Wikipedians of Jackson: A professor at Jackson Community College is looking for Wikipedia Campus Ambassadors for the upcoming spring semester! <a href="' + mw.util.wikiGetlink( 'Special:EmailUser/Bob the Wikipedian') + '">Contact us</a> if you are interested.'
},

AmbassadorsOberlin:
{
  begin : '18 December 2011 00:00 UTC',
  end: '18 January 2012 00:00 UTC',
  corners: [ [41.0,-82.3], [41.4,-81.9] ],
  text: 'Wikipedians of Oberlin: A professor at Oberlin College is looking for Wikipedia Campus Ambassadors for the upcoming spring semester! <a href="' + mw.util.wikiGetlink( 'Special:EmailUser/Etlib') + '">Contact us</a> if you are interested.'
},

UKOTRSworkshop:
 { begin: '13 December 2011 13:20 UTC',
   end: '8 January 2012 08:00 UTC',
   corners:[ [60,-9], [50.2, 1.3] ], 
   text: 'An OTRS workshop will be held at the WMUK office in London, 7–8 January 2012; interested editors are invited to [[wmuk:OTRS_workshop#Volunteers_and_participants|sign up]].'
 }

/*******************************************
 *             End of list.
 *           Edit only above!
 *tt
 * Format is:
 *
 * ID:
 * { begin: 'date',
 *   end: 'date',
 *   corners: [ [lat,lon], [lat,lon] ],
 *   text: 'message'
 * }
 *
 * There should be commas between the notices, but not after the last one.
 * Use [[meta:w:en:link|link]] format for internal links, so that they work properly on the other projects where the geonotice is displayed.
 *
 *******************************************/
};

function geoWikiLinker (str, page, text) {
	text = text || page;
	return mw.html.element(
		'a', {
			href: mw.util.wikiGetlink( page ),
			title: page
		}, text
	);
}


if ( Geo !== undefined ) {

  var now = new Date(),
      id, notice, insertsub, minlat, maxlat, minlon, maxlon,
      regexForInternalLinks = /\[\[([^{|}\[\]\n]+)(?:\|(.*?))?\]\]/g;

  for (id in notices) {

    if (!document.cookie.match('hidegeonotice'+id+'=1')) {

      notice = notices[id];
      if (!notice || !notice.corners) {
           continue;
      }
      minlat = Math.min(notice.corners[0][0], notice.corners[1][0]);
      maxlat = Math.max(notice.corners[0][0], notice.corners[1][0]);
      minlon = Math.min(notice.corners[0][1], notice.corners[1][1]);
      maxlon = Math.max(notice.corners[0][1], notice.corners[1][1]);

      if ( now.getTime() > Date.parse(notice.begin)
           && now.getTime() < Date.parse(notice.end)
           && minlat<Geo.lat && Geo.lat<maxlat
           && minlon<Geo.lon && Geo.lon<maxlon
         ) {

        insertsub = document.getElementById('contentSub');
        mw.util.addCSS( [
            '#contentSub .geonotice {',
                'width:98%;',
                'margin:5px auto 0;',
                'background:transparent;',
                'text-align:left;',
                'line-height:1.8em;',
            '}',
            '#contentSub .geonotice span {',
                'font-size:170%;',
            '}',
            '#contentSub .geonotice small {',
                'font-style:italic;',
            '}'
        ].join( ' ' ) );
        insertsub.innerHTML +=
            '<div class="geonotice plainlinks" id="geonotice'+id+'">'+
                '<span>'+notice.text.replace( regexForInternalLinks, geoWikiLinker )+'</span> '+
                '<small>['+
                    '<a href="#" onClick="'+
                            'var date = new Date();'+
                            'date.setTime(date.getTime()+8640000000);'+
                            'document.cookie = \'hidegeonotice'+id+'=1;'+
                            'expires=\' + date.toGMTString() + \';'+
                            'path=/\';'+
                            'document.getElementById(\'geonotice'+id+'\').style.visibility = \'hidden\';'+
                            'return false;'+
                        '">hide</a>'+
            ']</small></div>';
      }
    }
  }
}