<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://pool.calebcooper.ie/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3AGadget-geonotice-core.js</id>
	<title>MediaWiki:Gadget-geonotice-core.js - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pool.calebcooper.ie/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3AGadget-geonotice-core.js"/>
	<link rel="alternate" type="text/html" href="https://pool.calebcooper.ie/index.php?title=MediaWiki:Gadget-geonotice-core.js&amp;action=history"/>
	<updated>2026-04-07T23:27:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://pool.calebcooper.ie/index.php?title=MediaWiki:Gadget-geonotice-core.js&amp;diff=10048&amp;oldid=prev</id>
		<title>Caleb Cooper: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://pool.calebcooper.ie/index.php?title=MediaWiki:Gadget-geonotice-core.js&amp;diff=10048&amp;oldid=prev"/>
		<updated>2020-01-28T15:04:22Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:04, 28 January 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Caleb Cooper</name></author>
	</entry>
	<entry>
		<id>https://pool.calebcooper.ie/index.php?title=MediaWiki:Gadget-geonotice-core.js&amp;diff=10047&amp;oldid=prev</id>
		<title>powerstorewiki&gt;Caleb Cooper: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://pool.calebcooper.ie/index.php?title=MediaWiki:Gadget-geonotice-core.js&amp;diff=10047&amp;oldid=prev"/>
		<updated>2020-01-21T18:20:55Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;/*  _____________________________________________________________________________&lt;br /&gt;
 * |                                                                             |&lt;br /&gt;
 * |                    === WARNING: GLOBAL GADGET FILE ===                      |&lt;br /&gt;
 * |                  Changes to this page affect many users.                    |&lt;br /&gt;
 * | Please discuss changes on the talk page or on [[WT:Gadget]] before editing. |&lt;br /&gt;
 * |_____________________________________________________________________________|&lt;br /&gt;
 *&lt;br /&gt;
 * Imported as of 8 august 2014 from [[testwiki:MediaWiki:Gadget-geonotice-core.js]]&lt;br /&gt;
 * Shows notices to registered users based on their location&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
/* global jQuery, mediaWiki */&lt;br /&gt;
&lt;br /&gt;
( function ( mw, $ ) {&lt;br /&gt;
&amp;#039;use strict&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
mw.messages.set( {&lt;br /&gt;
	&amp;#039;gn-hideButton&amp;#039;: &amp;#039;Hide&amp;#039;&lt;br /&gt;
} );&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Namespace for all Geonotice methods and properties.&lt;br /&gt;
 * @class&lt;br /&gt;
 * @singleton&lt;br /&gt;
 */&lt;br /&gt;
var gn = {};&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * @param {string} str Wiki-text of the link&lt;br /&gt;
 * @param {string} page The title of the target page of the link&lt;br /&gt;
 * @param {string} text The text to be used for the link&lt;br /&gt;
 */&lt;br /&gt;
/* jshint unused: true */&lt;br /&gt;
&lt;br /&gt;
gn.geoWikiLinker = function (str, page, text) {&lt;br /&gt;
	text = text || page;&lt;br /&gt;
	return mw.html.element(&lt;br /&gt;
		&amp;#039;a&amp;#039;, {&lt;br /&gt;
			href: mw.util.getUrl( page ),&lt;br /&gt;
			title: page&lt;br /&gt;
		}, text&lt;br /&gt;
	);&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Handle click events.&lt;br /&gt;
 *&lt;br /&gt;
 * @param {jQuery.Event} e Click event&lt;br /&gt;
 */&lt;br /&gt;
gn.hideGeonotice = function (e) {&lt;br /&gt;
	e.preventDefault();&lt;br /&gt;
&lt;br /&gt;
	var parentId = $(e.target).closest(&amp;#039;li&amp;#039;).attr(&amp;#039;id&amp;#039;).replace( /^geonotice/, &amp;#039;&amp;#039;);&lt;br /&gt;
	var hiddenNotices = gn.getHiddenNotices();&lt;br /&gt;
&lt;br /&gt;
	hiddenNotices.push(parentId);&lt;br /&gt;
	gn.saveHiddenNotices(hiddenNotices);&lt;br /&gt;
&lt;br /&gt;
	$( &amp;#039;#geonotice&amp;#039; + parentId ).hide();&lt;br /&gt;
	$( &amp;#039;#geonotice-hr&amp;#039; ).hide();&lt;br /&gt;
&lt;br /&gt;
	return false;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Boolean indicating whether this will be the first notice added to the page&lt;br /&gt;
 */&lt;br /&gt;
gn.firstnotice = true;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Regular expression used to detect links in wiki-text&lt;br /&gt;
 */&lt;br /&gt;
gn.regexForInternalLinks = /\[\[([^{|}\[\]\n]+)(?:\|(.*?))?\]\]/g;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * A key used to store the array of hidden notices in Web Storage&lt;br /&gt;
 */&lt;br /&gt;
gn.storageKey = &amp;#039;hidegeonotices&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Get a list of the hidden notices&lt;br /&gt;
 */&lt;br /&gt;
gn.getHiddenNotices = function () {&lt;br /&gt;
	var hiddenNotices = mw.storage.get( gn.storageKey )&lt;br /&gt;
			|| mw.storage.session.get( gn.storageKey );&lt;br /&gt;
&lt;br /&gt;
	try {&lt;br /&gt;
		return JSON.parse(hiddenNotices) || [];&lt;br /&gt;
	} catch (e) {&lt;br /&gt;
		return [];&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Save the list of the hidden notices&lt;br /&gt;
 */&lt;br /&gt;
gn.saveHiddenNotices = function ( notices ) {&lt;br /&gt;
	notices = JSON.stringify( notices );&lt;br /&gt;
	mw.storage.set( gn.storageKey, notices )&lt;br /&gt;
		|| mw.storage.session.set( gn.storageKey, notices );&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Removes ids from localstorage that are no longer in use&lt;br /&gt;
 */&lt;br /&gt;
gn.expungeOldNotices = function( currentList ) {&lt;br /&gt;
	var savedList = gn.getHiddenNotices(),&lt;br /&gt;
		originalLength = savedList.length;&lt;br /&gt;
	for (var i = savedList.length - 1; i &amp;gt;= 0; i--) {&lt;br /&gt;
		if( !( savedList[i] in currentList ) ) {&lt;br /&gt;
			savedList.splice( i, 0 );&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	if( originalLength !== savedList.length ) {&lt;br /&gt;
		gn.saveHiddenNotices( savedList );&lt;br /&gt;
	}&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Add a notice on top of the watchlist&lt;br /&gt;
 *&lt;br /&gt;
 * @param {Object} notice Object representing a notice&lt;br /&gt;
 */&lt;br /&gt;
gn.displayGeonotice = function (notice) {&lt;br /&gt;
	var geonoticeText = notice.text.replace( gn.regexForInternalLinks, gn.geoWikiLinker );&lt;br /&gt;
&lt;br /&gt;
	if (gn.firstnotice) {&lt;br /&gt;
		gn.firstnotice = false;&lt;br /&gt;
		&lt;br /&gt;
		$(&amp;#039;#watchlist-message&amp;#039;).prepend(&lt;br /&gt;
			$( &amp;#039;&amp;lt;hr&amp;gt;&amp;#039; ).attr({ &amp;#039;id&amp;#039; : &amp;#039;geonotice-hr&amp;#039; })&lt;br /&gt;
		);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	$(&amp;#039;#watchlist-message&amp;#039;).prepend(&lt;br /&gt;
		$(&amp;#039;&amp;lt;li&amp;gt;&amp;#039;)&lt;br /&gt;
			.attr({&lt;br /&gt;
				&amp;#039;class&amp;#039; : &amp;#039;geonotice plainlinks&amp;#039;,&lt;br /&gt;
				&amp;#039;id&amp;#039; : &amp;#039;geonotice&amp;#039; + notice.id&lt;br /&gt;
			})&lt;br /&gt;
			.append(&lt;br /&gt;
				$( &amp;#039;&amp;lt;span&amp;gt;&amp;#039; )&lt;br /&gt;
					.html( geonoticeText ),&lt;br /&gt;
				$( &amp;#039;&amp;lt;small&amp;gt;&amp;#039; )&lt;br /&gt;
					.append(&lt;br /&gt;
						$(&amp;#039;&amp;lt;a&amp;gt;&amp;#039;)&lt;br /&gt;
							.text( mw.msg( &amp;#039;gn-hideButton&amp;#039; ) )&lt;br /&gt;
							.click( gn.hideGeonotice )&lt;br /&gt;
							.attr( { &amp;#039;href&amp;#039; : &amp;#039;#&amp;#039; } )&lt;br /&gt;
					)&lt;br /&gt;
			)&lt;br /&gt;
	).show();&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Determine which notices are still valid and are targeted to the location of the current user&lt;br /&gt;
 */&lt;br /&gt;
gn.runGeonotice = function () {&lt;br /&gt;
	var now = new Date(),&lt;br /&gt;
		hide, id, notice, minlat, maxlat, minlon, maxlon,&lt;br /&gt;
		startNotice, endNotice,&lt;br /&gt;
		hiddenNotices = gn.getHiddenNotices();&lt;br /&gt;
&lt;br /&gt;
	for (id in gn.notices) {&lt;br /&gt;
		hide = hiddenNotices.indexOf( id ) &amp;gt;= 0;&lt;br /&gt;
		&lt;br /&gt;
		if (!hide) {&lt;br /&gt;
&lt;br /&gt;
			notice = gn.notices[id];&lt;br /&gt;
			notice.id = id;&lt;br /&gt;
&lt;br /&gt;
			if (!notice || !notice.begin || !notice.end) {&lt;br /&gt;
				continue;&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			startNotice = Date.parse(notice.begin);&lt;br /&gt;
			endNotice = Date.parse(notice.end);&lt;br /&gt;
&lt;br /&gt;
			if ( now.getTime() &amp;gt; startNotice &amp;amp;&amp;amp;&lt;br /&gt;
				now.getTime() &amp;lt; endNotice ) {&lt;br /&gt;
				if (notice.country &amp;amp;&amp;amp; Geo.country === notice.country) {&lt;br /&gt;
					gn.displayGeonotice(notice);&lt;br /&gt;
				} else {&lt;br /&gt;
					if (notice.corners) {&lt;br /&gt;
						minlat = Math.min(notice.corners[0][0], notice.corners[1][0]);&lt;br /&gt;
						maxlat = Math.max(notice.corners[0][0], notice.corners[1][0]);&lt;br /&gt;
						minlon = Math.min(notice.corners[0][1], notice.corners[1][1]);&lt;br /&gt;
						maxlon = Math.max(notice.corners[0][1], notice.corners[1][1]);&lt;br /&gt;
&lt;br /&gt;
						// Geo coordinates can be empty string if unknown. parseFloat makes&lt;br /&gt;
						// these NaN, so that you do not get to see a notice in that case.&lt;br /&gt;
						if ( minlat &amp;lt; parseFloat( Geo.lat ) &amp;amp;&amp;amp; parseFloat( Geo.lat ) &amp;lt; maxlat &amp;amp;&amp;amp;&lt;br /&gt;
							minlon &amp;lt; parseFloat( Geo.lon ) &amp;amp;&amp;amp; parseFloat( Geo.lon ) &amp;lt; maxlon&lt;br /&gt;
						) {&lt;br /&gt;
							gn.displayGeonotice(notice);&lt;br /&gt;
						}&lt;br /&gt;
					}&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	gn.expungeOldNotices( gn.notices );&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
// Attach to window&lt;br /&gt;
window.GeoNotice = $.extend( gn, window.GeoNotice );&lt;br /&gt;
&lt;br /&gt;
if ( window.Geo !== undefined ) {&lt;br /&gt;
	$( gn.runGeonotice );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}( mediaWiki, jQuery ) );&lt;/div&gt;</summary>
		<author><name>powerstorewiki&gt;Caleb Cooper</name></author>
	</entry>
</feed>