PageRenderTime 48ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/exercise-06-01/htmlSites/Apple_Trek_files/index_002.php

https://github.com/robert-fu-berlin/Exercises-Web-based-Information-Systems
PHP | 458 lines | 374 code | 53 blank | 31 comment | 50 complexity | 7668d3c72b2b06ab6d6a15bc780dff92 MD5 | raw file
  1. // [[image:Erioll_world.svg|18px]] '''WikiMiniAtlas''' <br>
  2. // Script to embed interactive maps into pages that have coordinate templates <br>
  3. // also check my user page [[User:Dschwen]] for more tools<pre>
  4. //
  5. // Revision 13
  6. var wikiminiatlas =
  7. {
  8. config:
  9. {
  10. width : 600,
  11. height : 400,
  12. timeout : 5000,
  13. zoom : -1,
  14. quicklink : false,
  15. quicklinkurl : 'http://maps.google.com/maps?ll={latdegdec},{londegdec}&spn={span},{span}&q={latdegdec},{londegdec}',
  16. enabled : true,
  17. onlytitle : false,
  18. iframeurl : 'http://toolserver.org/~dschwen/wma/iframe.html',
  19. imgbase : 'http://toolserver.org/~dschwen/wma/tiles/',
  20. coordurls : [
  21. 'http://stable.toolserver.org/geohack/geohack.php?',
  22. 'http://stable.ts.wikimedia.org/geohack/geohack.php?',
  23. 'http://toolserver.org/~magnus/geo/geohack.php?',
  24. 'http://toolserver.org/~geohack/geohack.php?',
  25. 'http://tools.wikimedia.de/~magnus/geo/geohack.php?',
  26. 'http://www8.brinkster.com/erikbaas/wiki/maps.asp?',
  27. 'http://www.nsesoftware.nl/wiki/maps.asp?'
  28. ],
  29. buttonImage:
  30. 'http://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Erioll_world.svg/18px-Erioll_world.svg.png'
  31. },
  32. strings:
  33. {
  34. buttonTooltip : {
  35. af:'Vertoon ligging op \'n interaktiwe kaart.',
  36. als:'Ort uf dr interaktivä Chartä zeigä',
  37. ar:'شاهد الموقع على الخريطة التفاعلية',
  38. 'be-tarask':'паказаць месцазнаходжаньне на інтэрактыўнай мапе',
  39. 'be-x-old':'паказаць месцазнаходжаньне на інтэрактыўнай мапе',
  40. bg:'покажи местоположението на интерактивната карта',
  41. bpy:'জীবন্ত মানচিত্রগর মা মাপাহান দেখাদিতই',
  42. br:'diskouez al lec\'hiadur war ur gartenn etrewezhiat',
  43. ca:'mostra la localització en un mapa interactiu',
  44. cs:'zobraz místo na interaktivní mapě',
  45. da:'vis beliggenhed på interaktivt kort',
  46. de:'Ort auf interaktiver Karte anzeigen',
  47. el:'εμφάνιση τοποθεσίας σε διαδραστικό χάρτη',
  48. en:'show location on an interactive map',
  49. eo:'Montru lokigon sur interaktiva karto',
  50. eu:'erakutsi kokalekua mapa interaktibo batean',
  51. es:'mostrar el lugar en un mapa interactivo',
  52. fr:'Montrer la localisation sur une carte interactive',
  53. fur:'mostre la localizazion suntune mape interative',
  54. fy:'it plak op in oanpasbere kaart oanjaan',
  55. gl:'Amosar o lugar nun mapa interactivo',
  56. he:'הראה מיקום במפה האינטראקטיבית',
  57. hi:'सक्रिय नक्शे पर लोकेशन या स्थान दिखायें',
  58. hr:'prikaži lokaciju na interaktivnom zemljovidu',
  59. hu:'Mutasd a helyet egy interaktív térképen!',
  60. hy:'ցուցադրել դիրքը ինտերակտիվ քարտեզի վրա',
  61. it:'mostra la località su una carta interattiva',
  62. is:'sýna staðsetningu á gagnvirku korti',
  63. id:'Tunjukkan letak di peta interaktif',
  64. ja:'インタラクティブ地図上に位置を表示',
  65. km:'បង្ហាញទីតាំងនៅលើផែនទីអន្តរកម្ម',
  66. ko:'인터랙티브 지도에 위치를 표시',
  67. lt:'Rodyti vietą interaktyviame žemėlapyje',
  68. mk:'прикажи положба на интерактивна карта',
  69. nl:'de locatie op een interactieve kaart tonen',
  70. nv:'kéyah tʼáá dah siʼą́ą́ ńtʼę́ę́ʼ beʼelyaaígíí',
  71. no:'vis beliggenhet på interaktivt kart',
  72. pl:'Pokaż lokalizację na mapie interaktywnej',
  73. pt:'mostrar a localidade num mapa interactivo',
  74. ro:'arată locaţia pe o hartă interactivă',
  75. ru:'показать положение на интерактивной карте',
  76. sk:'zobraz miesto na interaktívnej mape',
  77. sl:'Prikaži lego na interaktivnem zemljevidu',
  78. sq:'trego vendndodhjen në hartë',
  79. fi:'näytä paikka interaktiivisella kartalla',
  80. sv:'visa platsen på en interaktiv karta',
  81. uk:'показати положення на інтерактивній карті',
  82. vi:'xem vị trí này trên bản đồ tương tác',
  83. vo:'Jonön topi su kaed itjäfidik',
  84. zh:'显示该地在地图上的位置',
  85. 'zh-cn':'显示该地在地图上的位置',
  86. 'zh-sg':'显示该地在地图上的位置',
  87. 'zh-tw':'顯示該地在地圖上的位置',
  88. 'zh-hk':'顯示該地在地圖上的位置'
  89. },
  90. close : {
  91. af:'Sluit',
  92. als:'Zuä machä',
  93. ar:'غلق',
  94. 'be-tarask':'закрыць',
  95. 'be-x-old':'закрыць',
  96. bg:'затвори',
  97. bpy:'জিপা',
  98. br:'serriñ',
  99. ca:'tanca',
  100. cs:'zavřít',
  101. da:'luk',
  102. de:'schließen',
  103. el:'έξοδος',
  104. en:'close',
  105. eo:'fermu',
  106. eu:'itxi',
  107. es:'cerrar',
  108. fr:'Quitter',
  109. fur:'siere',
  110. fy:'ticht',
  111. gl:'pechar',
  112. he:'לסגור',
  113. hi:'बंद करें',
  114. hr:'zatvori',
  115. hu:'bezárás',
  116. hy:'փակել',
  117. id:'tutup',
  118. is:'loka',
  119. it:'chiudi',
  120. ja:'閉じる',
  121. km:'បិទ',
  122. ko:'닫기',
  123. lt:'uždaryti',
  124. mk:'затвори',
  125. nl:'sluiten',
  126. no:'lukk',
  127. pl:'zamknij',
  128. pt:'fechar',
  129. ro:'închide',
  130. ru:'закрыть',
  131. sk:'zatvoriť',
  132. sl:'zapri',
  133. sq:'mbylle',
  134. fi:'sulje',
  135. sv:'stäng',
  136. uk:'закрити',
  137. vi:'đóng',
  138. vo:'färmükön',
  139. zh:'关闭',
  140. 'zh-cn':'关闭',
  141. 'zh-sg':'关闭',
  142. 'zh-tw':'關閉',
  143. 'zh-hk':'關閉'
  144. }
  145. },
  146. bodyc : null,
  147. language : '',
  148. site: '',
  149. iframe : { div: null, iframe: null, closebutton: null },
  150. coord_index: 0,
  151. coord_filter: /^([\d+-.]+)_([\d+-.]*)_?([\d+-.]*)_?([NS])_([\d+-.]+)_([\d+-.]*)_?([\d+-.]*)_?([EOW])/,
  152. quicklinkbox : null,
  153. quicklinkdest : null,
  154. region_index : 0,
  155. coordinate_region : '',
  156. WikiMiniAtlasHTML : '',
  157. hookUpMapbutton : function( mb )
  158. {
  159. var mapparam = mb.mapparam,
  160. mapy = wikiminiatlas.totalOffset( mb, 0 ) + 20;
  161. function doEvent()
  162. {
  163. wikiminiatlas.toggleIFrame( mapparam, mapy );
  164. return true;
  165. }
  166. mb.onclick = doEvent;
  167. },
  168. // vertikale position auf der Seite bestimmen
  169. totalOffset : function( obj, offset )
  170. {
  171. if( obj.offsetParent === null || obj.offsetParent.id === 'content' ) {
  172. return offset + obj.offsetTop;
  173. }
  174. else {
  175. return wikiminiatlas.totalOffset(obj.offsetParent, offset + obj.offsetTop );
  176. }
  177. },
  178. // move iframe around and toggle visibility
  179. toggleIFrame : function( mp, my )
  180. {
  181. var w = wikiminiatlas,
  182. wi = w.iframe,
  183. newurl = w.config.iframeurl + '?' + mp;
  184. if( wi.div.style.visibility !== "visible" ||
  185. ( ( wi.iframe.src !== newurl ) && ( my !== undefined ) ) )
  186. {
  187. if( wi.iframe.src !== newurl )
  188. {
  189. wi.iframe.src = newurl;
  190. }
  191. wi.div.style.top = my + 'px';
  192. wi.div.style.visibility = "visible";
  193. wi.div.style.display = "block";
  194. }
  195. else
  196. {
  197. wi.div.style.visibility = "hidden";
  198. wi.div.style.display = "none";
  199. }
  200. return false;
  201. },
  202. // start the timer to fade in the quicklink tooltip
  203. qlStart : function()
  204. {
  205. },
  206. // abort the timer, hide the tooltip
  207. qlStop : function()
  208. {
  209. },
  210. // show the tooltip menu
  211. qlShowMenu : function()
  212. {
  213. },
  214. // fill in the map-service templates
  215. qlURL : function( lat, lon, zoom )
  216. {
  217. var url = wikiminiatlas.config.quicklinkurl,
  218. span = Math.pow( 2.0, zoom) / 150.0;
  219. url = url.replace( /\{latdegdec\}/g, lat );
  220. url = url.replace( /\{londegdec\}/g, lon );
  221. url = url.replace( /\{span\}/g, span.toFixed(4) );
  222. return url;
  223. },
  224. // Check against coordinate urls
  225. isMaplink : function( url_orig )
  226. {
  227. var w = wikiminiatlas,
  228. url, key;
  229. if( typeof(url_orig) !== 'string' ) { return false; }
  230. // needed for the russian WP
  231. try { url = decodeURI( url_orig ); } catch(err) { url = url_orig; }
  232. for( key in w.config.coordurls ) {
  233. if( url.substr(0,w.config.coordurls[key].length) === w.config.coordurls[key] ) {
  234. return true;
  235. }
  236. }
  237. return false;
  238. },
  239. // Insert the IFrame into the page.
  240. loader : function()
  241. {
  242. var w = wikiminiatlas,
  243. wi = w.iframe,
  244. wc = w.config,
  245. ds_filter = /(dim|scale):([\d+-.]+)(km|)/,
  246. marker = { lat:0, lon:0 },
  247. link, links, coordinates, quicklinkbox,
  248. key, len, coord_title, coord_params, icons, startTime, zoomlevel, content, mapbutton;
  249. // apply settings
  250. if( typeof(wma_settings) === 'object' ) {
  251. for ( key in wma_settings) {
  252. if( typeof(wma_settings[key]) === typeof(wc[key]) ) {
  253. wc[key] = wma_settings[key];
  254. }
  255. }
  256. }
  257. if( wc.enabled === false ) { return; }
  258. w.site = window.location.host.substr( 0, window.location.host.indexOf('.') );
  259. w.language = wgUserLanguage;
  260. // remove icons from title coordinates
  261. coord_title = document.getElementById('coordinates') || document.getElementById('coordinates-title');
  262. if( coord_title ) {
  263. icons = coord_title.getElementsByTagName('a');
  264. len = icons.length;
  265. for( key = 0; key < len; key++ ) {
  266. if( typeof(icons[key]) === 'object' &&
  267. icons[key] !== null &&
  268. icons[key].className === 'image' ) {
  269. icons[key].parentNode.removeChild(icons[key]);
  270. }
  271. }
  272. }
  273. if( wc.onlytitle ) {
  274. w.bodyc = document.getElementById('coordinates') || document.getElementById('coordinates-title');
  275. if( w.bodyc === null ) { return; }
  276. }
  277. else {
  278. // the french moved their title coordinates outside of bodyContent!
  279. if( w.site === 'fr' ) {
  280. w.bodyc = document.getElementById('content') || document;
  281. } else {
  282. w.bodyc = document.getElementById('bodyContent') || document;
  283. }
  284. }
  285. startTime = (new Date()).getTime();
  286. links = w.bodyc.getElementsByTagName('a');
  287. len = links.length;
  288. for( key = 0; key < len; key++ )
  289. {
  290. link = links[key];
  291. // check for timeout (every 10 links only)
  292. if( key % 10 === 9 && (new Date()).getTime() > startTime + wc.timeout ) { break; }
  293. if( link.className !== 'external text' ||
  294. link.href.match(/_globe:(?!earth)/i) !== null ) { continue; }
  295. coordinates = link.href.replace( //g, '-' );
  296. coord_params = coordinates.match(/&params=([^&=<>|]{7,255})/);
  297. if(!coord_params) { continue; }
  298. coord_params = coord_params[1];
  299. if(w.coord_filter.test(coord_params)) {
  300. w.coord_filter.exec(coord_params);
  301. marker.lat=(1.0*RegExp.$1) + ((RegExp.$2||0)/60.0) + ((RegExp.$3||0)/3600.0);
  302. if( RegExp.$4 === 'S' ) { marker.lat*=-1; }
  303. marker.lon=(1.0*RegExp.$5) + ((RegExp.$6||0)/60.0) + ((RegExp.$7||0)/3600.0);
  304. if( RegExp.$8 === 'W' ) { marker.lon*=-1; }
  305. }
  306. // Find a sensible Zoom-level based on type
  307. zoomlevel = 1;
  308. if( coord_params.indexOf('_type:landmark') >= 0 ) {
  309. zoomlevel = 8;
  310. } else if( coord_params.indexOf('_type:city') >= 0 ) {
  311. zoomlevel = 4;
  312. }
  313. // If given use dim or scale for a zoomlevel
  314. if( ds_filter.test(coord_params) )
  315. {
  316. ds_filter.exec(coord_params);
  317. // wma shows dim approx 4e7m at zoom 0 or 1.5e8 is the scale of zoomlevel 0
  318. zoomlevel = (RegExp.$1 === 'dim' ?
  319. ( RegExp.$3 === 'km' ? Math.log( 4e4/RegExp.$2 ) : Math.log( 4e7/RegExp.$2 ) ) :
  320. Math.log( 1.5e8/RegExp.$2 ) ) / Math.log(2);
  321. if( zoomlevel > 10 ) { zoomlevel = 10; }
  322. }
  323. if( wc.zoom !== -1 ) { zoomlevel = wc.zoom; }
  324. // Test the unicode Symbol
  325. if( w.site === 'de' && link.parentNode.id !== 'coordinates' ) {
  326. mapbutton = document.createElement('SPAN');
  327. mapbutton.appendChild( document.createTextNode('♁') );
  328. mapbutton.style.color = 'blue';
  329. } else {
  330. mapbutton = document.createElement('img');
  331. mapbutton.src = wc.buttonImage;
  332. }
  333. mapbutton.title = w.strings.buttonTooltip[w.language] || w.strings.buttonTooltip.en;
  334. mapbutton.alt = '';
  335. mapbutton.style.padding = '0px 3px 0px 0px';
  336. mapbutton.style.cursor = 'pointer';
  337. mapbutton.className = 'noprint';
  338. mapbutton.mapparam =
  339. marker.lat + '_' + marker.lon + '_' +
  340. wc.width + '_' + wc.height + '_' +
  341. w.site + '_' + zoomlevel + '_' + w.language;
  342. // link.parentNode.insertBefore(mapbutton, link.nextSibling);
  343. link.parentNode.insertBefore(mapbutton,link);
  344. w.hookUpMapbutton(mapbutton);
  345. if ( wc.quicklink ) {
  346. link.href = w.qlURL( marker.lat, marker.lon, zoomlevel );
  347. link.onmouseover = w.qlStart;
  348. link.onmouseout = w.qlStop;
  349. }
  350. } //for
  351. // prepare quicklink menu box
  352. if ( coordinates !== null && wc.quicklink ) {
  353. quicklinkbox = document.createElement('div');
  354. // more to come :-)
  355. }
  356. // prepare iframe to house the map
  357. if ( coordinates !== null ) {
  358. wi.div = document.createElement('div');
  359. wi.div.style.visibility = 'hidden';
  360. wi.div.style.display = 'none';
  361. wi.div.style.width = (wc.width+2)+'px';
  362. wi.div.style.height = (wc.height+2)+'px';
  363. wi.div.style.margin = '0px';
  364. wi.div.style.padding = '0px';
  365. wi.div.style.backgroundColor = 'white';
  366. wi.div.style.position = 'absolute';
  367. wi.div.style.right = '2em';
  368. wi.div.style.top = '1em';
  369. wi.div.style.border = '1px solid gray';
  370. wi.div.style.zIndex = 13;
  371. wi.closebutton = document.createElement('img');
  372. wi.closebutton.title = w.strings.close[w.language] || w.strings.close.en;
  373. // was: config.imgbase + 'button_hide.png'
  374. wi.closebutton.src = 'http://upload.wikimedia.org/wikipedia/commons/d/d4/Button_hide.png';
  375. wi.closebutton.style.zIndex = 15;
  376. wi.closebutton.style.position = 'absolute';
  377. wi.closebutton.style.right = '11px';
  378. wi.closebutton.style.top = '9px';
  379. wi.closebutton.style.width = '18px';
  380. wi.closebutton.style.cursor = 'pointer';
  381. wi.closebutton.mapparam = '';
  382. wi.closebutton.onclick = w.toggleIFrame;
  383. wi.iframe = document.createElement('iframe');
  384. wi.iframe.scrolling = 'no';
  385. wi.iframe.frameBorder = '0';
  386. wi.iframe.style.zIndex = 14;
  387. wi.iframe.style.position = 'absolute';
  388. wi.iframe.style.right = '1px';
  389. wi.iframe.style.top = '1px';
  390. wi.iframe.style.width = (wc.width)+'px';
  391. wi.iframe.style.height = (wc.height)+'px';
  392. wi.iframe.style.margin = '0px';
  393. wi.iframe.style.padding = '0px';
  394. wi.div.appendChild(wi.iframe);
  395. wi.div.appendChild(wi.closebutton);
  396. content = document.getElementById('content') || document.getElementById('mw_content');
  397. if(content) { content.insertBefore(wi.div,content.childNodes[0]); }
  398. }
  399. }
  400. };
  401. //
  402. // Hook up installation function
  403. //
  404. addOnloadHook(wikiminiatlas.loader);
  405. //</pre>