MediaWiki:Wikiminiatlas.js: Difference between revisions
more compact test for JSON support
(make it 10% of traffic) |
(more compact test for JSON support) |
||
Line 314: | Line 314: | ||
clist.lonright = coord_list[ineg].lon; | clist.lonright = coord_list[ineg].lon; | ||
} | } | ||
if ( | if ('JSON' in window) { | ||
mes.postMessage( JSON.stringify(clist), document.location.protocol + wma_domain ); | mes.postMessage(JSON.stringify(clist), document.location.protocol + wma_domain); | ||
if (kml!==null) { | if (kml!==null) { | ||
mes.postMessage( JSON.stringify(kml), document.location.protocol + wma_domain ); | mes.postMessage(JSON.stringify(kml), document.location.protocol + wma_domain); | ||
} | } | ||
} | } | ||
Line 331: | Line 331: | ||
iframe.div.css( { top: yPos( coord_list[parseInt(d[1])].obj ) + 'px'} ); | iframe.div.css( { top: yPos( coord_list[parseInt(d[1])].obj ) + 'px'} ); | ||
// make sure scroll target gets highlighted | // make sure scroll target gets highlighted | ||
setTimeout( function () { highlight(parseInt(d[1])); }, 200 ); | setTimeout(function () { highlight(parseInt(d[1])); }, 200); | ||
break; | break; | ||
case 'highlight' : | case 'highlight' : | ||
Line 365: | Line 365: | ||
if (wc.enabled===false) { return; } | if (wc.enabled===false) { return; } | ||
site = ( dbName==="commonswiki" ) ? "commons" : mw.config.get( 'wgPageContentLanguage' ); | site = (dbName==="commonswiki") ? "commons" : mw.config.get('wgPageContentLanguage'); | ||
language = mw.config.get( 'wgUserLanguage' ); | language = mw.config.get( 'wgUserLanguage' ); | ||
Line 567: | Line 567: | ||
// already got a request message | // already got a request message | ||
if (mes!==null && kml.ways.length>0 && | if (mes!==null && kml.ways.length>0 && 'JSON' in window) { | ||
mes.postMessage(JSON.stringify(kml), document.location.protocol + wma_domain); | mes.postMessage(JSON.stringify(kml), document.location.protocol + wma_domain); | ||
} | } |