Misplaced Pages

MediaWiki:Gadget-geonotice-list.js: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Browse history interactively← Previous editNext edit →Content deleted Content added
Revision as of 17:08, 22 March 2012 view sourceHJ Mitchell (talk | contribs)Edit filter managers, Autopatrolled, Checkusers, Oversighters, Administrators121,847 edits +Coventry 2← Previous edit Revision as of 17:32, 22 March 2012 view source Amalthea (talk | contribs)31,926 edits restoring, repaired.Next edit →
(One intermediate revision by the same user not shown)
Line 6: Line 6:
end: '28 March 2012 23:59 UTC', end: '28 March 2012 23:59 UTC',
corners: , ], corners: , ],
text: 'You're invited to the ''']''' in Boston at Simmons College on Tuesday, March 27, starting at 4:30 p.m. Free food provided!' text: "You're invited to the ''']''' in Boston at Simmons College on Tuesday, March 27, starting at 4:30 p.m. Free food provided!"
}, },


Line 131: Line 131:
end: '28 April 2012 15:00 UTC', end: '28 April 2012 15:00 UTC',
corners:, ], corners:, ],
text: 'Interested in having a chat with fellow Wikipedians over lunch or a drink? There are upcoming meetups in ]; ]; ]; and ]!' text: "Interested in having a chat with fellow Wikipedians over lunch or a drink? There are upcoming meetups in ]; ]; ]; and ]!"
}, },



Revision as of 17:32, 22 March 2012

var notices = {

SimmonsCollege:
{ 
  begin: '22 March 2012 00:00 UTC',
  end: '28 March 2012 23:59 UTC',
  corners: ,  ],
  text: "You're invited to the ''']''' in Boston at Simmons College on Tuesday, March 27, starting at 4:30 p.m. Free food provided!"
},

HongKongMeetup:
{
begin : '22 March 2012 00:00 UTC',
end : '23 March 2012 16:00 UTC',
corners : ,  ],
text : 'Please come to the next ] on Friday 23 March from 19:00 at Think Cafe, Causeway Bay, and discuss the ]!'
},

melb19:
{
  begin : '20 March 2012 00:00 UTC',
  end: '25 March 2012 23:59 UTC',
  corners: ,  ],
  text: 'Come along and catch up with fellow Wikimedians at the 19th ], this Sunday (25 March) at 11am. Pizza provided.'
},

NYCmar:
 { begin: '12 March 2012 00:00 UTC',
   end: '19 March 2012 00:00 UTC',
   corners: ,  ],
   text: 'You are invited to the ] on Sunday March 18!'
 },

AmbassadorsAppleton:
{
  begin : '4 March 2012 00:00 UTC',
  end: '4 April 2012 00:00 UTC',
  corners: ,  ],
  text: 'Wikipedians of Appleton: Are you interested in guiding students through their first 100 edits? <a href="' + mw.util.wikiGetlink( 'Special:EmailUser/Bob the Wikipedian') + '">Contact us</a> if you are interested in becoming a campus ambassador.'
},
 
AmbassadorsHillsdale:
{
  begin : '4 March 2012 00:00 UTC',
  end: '4 April 2012 00:00 UTC',
  corners: ,  ],
  text: 'Wikipedians of Hillsdale: Are you interested in guiding students through their first 100 edits? <a href="' + mw.util.wikiGetlink( 'Special:EmailUser/Bob the Wikipedian') + '">Contact us</a> if you are interested in becoming a campus ambassador.'
},
 
AmbassadorsDanville:
{
  begin : '4 March 2012 00:00 UTC',
  end: '4 April 2012 00:00 UTC',
  corners: ,  ],
  text: 'Wikipedians of Danville: Are you interested in guiding students through their first 100 edits? <a href="' + mw.util.wikiGetlink( 'Special:EmailUser/Bob the Wikipedian') + '">Contact us</a> if you are interested in becoming a campus ambassador.'
},
 
AmbassadorsGreenBay:
{
  begin : '4 March 2012 00:00 UTC',
  end: '4 April 2012 00:00 UTC',
  corners: ,  ],
  text: 'Wikipedians of Green Bay: Are you interested in guiding students through their first 100 edits? <a href="' + mw.util.wikiGetlink( 'Special:EmailUser/Bob the Wikipedian') + '">Contact us</a> if you are interested in becoming a campus ambassador.'
},
 
AmbassadorsLouisville:
{
  begin : '4 March 2012 00:00 UTC',
  end: '4 April 2012 00:00 UTC',
  corners: ,  ],
  text: 'Wikipedians of Louisville: Are you interested in guiding students through their first 100 edits? <a href="' + mw.util.wikiGetlink( 'Special:EmailUser/Bob the Wikipedian') + '">Contact us</a> if you are interested in becoming a campus ambassador.'
},
 
AmbassadorsDetroit:
{
  begin : '4 March 2012 00:00 UTC',
  end: '4 April 2012 00:00 UTC',
  corners: ,  ],
  text: 'Wikipedians of Detroit: Are you interested in guiding students through their first 100 edits? <a href="' + mw.util.wikiGetlink( 'Special:EmailUser/Bob the Wikipedian') + '">Contact us</a> if you are interested in becoming a campus ambassador.'
},
 
RegionalHawaii:
{
begin: '18 February 2011 00:00 UTC',
  end: '18 March 2012 00:00 UTC',
  corners:,  ],
  text: 'Are you interested in encouraging more university professors to use Misplaced Pages as a teaching tool? Do you enjoy leading, coordinating, and organizing teams? If so, we want you! We are now recruiting for Misplaced Pages Regional Ambassadors to the multiple regions of the U.S. ]'
},
 
RegionalAlaska:
{
begin: '18 February 2011 00:00 UTC',
  end: '18 March 2012 00:00 UTC',
  corners:,  ],
  text: 'Are you interested in encouraging more university professors to use Misplaced Pages as a teaching tool? Do you enjoy leading, coordinating, and organizing teams? If so, we want you! We are now recruiting for Misplaced Pages Regional Ambassadors to the multiple regions of the U.S. ]'
},
 
RegionalContiguous:
{
begin: '18 February 2011 00:00 UTC',
  end: '18 March 2012 00:00 UTC',
  corners:,  ],
  text: 'Are you interested in encouraging more university professors to use Misplaced Pages as a teaching tool? Do you enjoy leading, coordinating, and organizing teams? If so, we want you! We are now recruiting for Misplaced Pages Regional Ambassadors to the multiple regions of the U.S. ]'
},

Bangalore:
{ begin : '1 March 2012 00:00 UTC',
  end : '11 March 2012 11:00 UTC',
  corners : , ],
  text : 'Come along and catch up with fellow Wikimedians at the 43rd <a href="http://wiki.wikimedia.in/WikiMeetups/Bangalore/Bangalore43">Bangalore Wikimeetup</a> on Sunday 11th March at 3 pm.'
},

Coimbatore:
{ begin : '1 March 2012 00:00 UTC',
  end : '10 March 2012 11:00 UTC',
  corners : , ],
  text : 'Come along and catch up with fellow Wikimedians at the 3rd ] on Saturday 10th March at 11 am.'

},

Delhi:
{ begin : '1 March 2012 00:00 UTC',
  end : '11 March 2012 11:00 UTC',
  corners : , ],
  text : 'Come along and catch up with fellow Wikimedians at the 7th ] on Sunday 11th March at 3 pm.'
},

UKMarchAprilMayMeetups:
{
   begin: '25 February 2012 23:40 UTC',
   end: '28 April 2012 15:00 UTC',
   corners:,  ], 
   text: "Interested in having a chat with fellow Wikipedians over lunch or a drink? There are upcoming meetups in ]; ]; ]; and ]!"
},

CoventryEditathon:
{
   begin: '10 March 2012 14:02 UTC',
   end: '31 March 2012 12:00 UTC',
   corners:,  ], 
   text: 'You are invited to an editathon at the ], Coventry. Wikipedians of all backgrounds and levels of experience are welcome—please ]!'
},
 
DC28:
{
  begin : '6 March 2012 00:00 UTC',
  end: '10 March 2012 23:00 UTC',
  corners: ,  ],
  text: 'You are invited to <a href="' + mw.util.wikiGetlink( 'Misplaced Pages:Meetup/DC_28') + '">DC Misplaced Pages Meetup #28</a> on Saturday, March 10 at 7pm, at Capitol City Brewery (11th & H)'
}

/*******************************************
 *             End of list.
 *           Edit only above!
 *tt
 * Format is:
 *
 * ID:
 * { begin: 'date',
 *   end: 'date',
 *   corners: ,  ],
 *   text: 'message'
 * }
 *
 * There should be commas between the notices, but not after the last one.
 * Use ] 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;
      if (!notice || !notice.corners) {
           continue;
      }
      minlat = Math.min(notice.corners, notice.corners);
      maxlat = Math.max(notice.corners, notice.corners);
      minlon = Math.min(notice.corners, notice.corners);
      maxlon = Math.max(notice.corners, notice.corners);

      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>';
      }
    }
  }
}