r83895 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83894‎ | r83895 | r83896 >
Date:14:07, 14 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
moved over js from sm
Modified paths:
  • /branches/Maps0.8/Maps.php (modified) (history)
  • /branches/Maps0.8/includes/ext.maps.coord.js (added) (history)

Diff [purge]

Index: branches/Maps0.8/Maps.php
@@ -236,7 +236,22 @@
237237 )
238238 );
239239
 240+$wgResourceModules['ext.maps.coord'] = array(
 241+ 'localBasePath' => dirname( __FILE__ ) . '/includes',
 242+ 'remoteBasePath' => $egMapsScriptPath . '/includes',
 243+ 'group' => 'ext.maps',
 244+ 'messages' => array(
 245+ 'maps-abb-north',
 246+ 'maps-abb-east',
 247+ 'maps-abb-south',
 248+ 'maps-abb-west',
 249+ ),
 250+ 'scripts' => array(
 251+ 'ext.maps.coord.js'
 252+ )
 253+);
240254
 255+
241256 /**
242257 * Initialization function for the Maps extension.
243258 *
Index: branches/Maps0.8/includes/ext.maps.coord.js
@@ -0,0 +1,105 @@
 2+/**
 3+ * JavasSript for coordinate handling in the Maps extension.
 4+ * @see http://www.mediawiki.org/wiki/Extension:Maps
 5+ *
 6+ * @since 0.8
 7+ * @ingroup Laos
 8+ *
 9+ * @licence GNU GPL v3
 10+ * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
 11+ */
 12+
 13+window.coord = new ( function( $ ) {
 14+
 15+ /**
 16+ * The separator used between latitude and longitude in a coordinate set.
 17+ * @const
 18+ * @type {string}
 19+ */
 20+ this.SEPARATOR = ',';
 21+
 22+ /**
 23+ * The delimiter used between coordinate sets.
 24+ * @const
 25+ * @type {string}
 26+ */
 27+ this.DELIMITER = ';';
 28+
 29+ /**
 30+ * Returns a list with coordinates obtained by splitting the provided string.
 31+ * @param {string} coords The coordinates to split.
 32+ * @return {Array} The split coordinates.
 33+ */
 34+ this.split = function( coords ) {
 35+ coords = coords.split( this.DELIMITER );
 36+ for ( i in coords ) coords[i] = coords[i].trim();
 37+ return coords;
 38+ }
 39+
 40+ /**
 41+ * Returns the provided coordinates joined in a string.
 42+ * @param {Array} coords The coordinates to join.
 43+ * @return {string} The joined coordinates.
 44+ */
 45+ this.join = function( coords ) {
 46+ return coords.join( this.DELIMITER + ' ' );
 47+ }
 48+
 49+ /**
 50+ * Returns a string with the directional DMS representatation of the provided latitude and longitude.
 51+ * @param {float} lat The latitude.
 52+ * @param {float} lon The longitude.
 53+ * @return {string} The string with DMS coordinates.
 54+ */
 55+ this.dms = function( lat, lon ) { // TODO: i18n
 56+ return Math.abs( lat ).toString() + '° ' + ( lat < 0 ? 'S' : 'N' )
 57+ + this.SEPARATOR + ' '
 58+ + Math.abs( lon ).toString() + '° ' + ( lon < 0 ? 'W' : 'E' );
 59+ };
 60+
 61+ /**
 62+ * Returns a string with the non-directional float representatation of the provided latitude and longitude.
 63+ * @param {float} lat The latitude.
 64+ * @param {float} lon The longitude.
 65+ * @return {string} The string with float coordinates.
 66+ */
 67+ this.float = function( lat, lon ) {
 68+ return lat.toString() + this.SEPARATOR + ' ' + lon.toString();
 69+ }
 70+
 71+ this.parse = function( coord ) {
 72+ coord = coord.split( this.SEPARATOR );
 73+ if ( coord.length != 2 ) return false;
 74+
 75+ var lat = coord[0].trim();
 76+ var lon = coord[1].trim();
 77+ var parsed;
 78+
 79+ parsed = this.parseFloat( lat, lon );
 80+ if ( parsed !== false ) return parsed;
 81+
 82+ parsed = this.parseDMS( lat, lon );
 83+ if ( parsed !== false ) return parsed;
 84+
 85+ return false;
 86+ }
 87+
 88+ this.parseDMS = function( lat, lon ) {
 89+ if ( true ) {
 90+ // TODO
 91+ }
 92+ else {
 93+ return false;
 94+ }
 95+ }
 96+
 97+ this.parseFloat = function( lat, lon ) {
 98+ if ( true ) {
 99+ // TODO
 100+ }
 101+ else {
 102+ return false;
 103+ }
 104+ }
 105+
 106+} )( jQuery );
\ No newline at end of file
Property changes on: branches/Maps0.8/includes/ext.maps.coord.js
___________________________________________________________________
Added: svn:eol-style
1107 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r83896follow up to r83895jeroendedauw14:07, 14 March 2011

Status & tagging log