diff --git a/bin/categories-to-lang b/bin/categories-to-lang
index 551e9009..ba386983 100755
--- a/bin/categories-to-lang
+++ b/bin/categories-to-lang
@@ -103,7 +103,7 @@ function writeTranslationFiles () {
let data = {}
allIds.forEach(function (id) {
- data[id] = null
+ data[id] = ''
})
let keys = Object.keys(all[lang])
diff --git a/conf.php-dist b/conf.php-dist
index d0339532..7e706f41 100644
--- a/conf.php-dist
+++ b/conf.php-dist
@@ -82,13 +82,13 @@ $config['baseMaps'] = array(
// List of available user interface languages
$languages = array(
+ "en", // English
"ast", // Asturian
"ca", // Catalan
"cs", // Czech
"da", // Danish
"de", // German
"el", // Greek
- "en", // English
"es", // Spanish
"et", // Estonian
"fr", // French
@@ -97,6 +97,7 @@ $languages = array(
"ja", // Japanese
"nl", // Dutch
"pl", // Polish
+ "pt", // Portugese
"pt-br", // Portugese (Brazil)
"ro", // Romanian
"ru", // Russian
diff --git a/httpGet.php b/httpGet.php
new file mode 100644
index 00000000..88a75be1
--- /dev/null
+++ b/httpGet.php
@@ -0,0 +1,2 @@
+Loading...'
+ p.innerHTML = '' + lang('loading') + ''
this.dom.appendChild(p)
p = document.createElement('div')
@@ -223,12 +223,12 @@ CategoryOverpass.prototype.updateStatus = function () {
if (typeof this.data.query === 'object') {
var highestZoom = Object.keys(this.data.query).reverse()[0]
if (this.map.getZoom() < highestZoom) {
- this.domStatus.innerHTML = 'zoom in for more map features'
+ this.domStatus.innerHTML = lang('zoom_in_more')
}
}
if ('minZoom' in this.data && this.map.getZoom() < this.data.minZoom) {
- this.domStatus.innerHTML = 'zoom in for map features to appear'
+ this.domStatus.innerHTML = lang('zoom_in_appear')
}
}
@@ -391,9 +391,10 @@ CategoryOverpass.prototype.updatePopupContent = function (object, popup) {
popupBody.innerHTML = this.popupBodyTemplate.render(data)
}
- var footer = document.createElement('div')
- footer.className = 'footer'
- var footerContent = '' + lang('show details') + ''
+ var footer = document.createElement('ul')
+ footer.className = 'popup-footer'
+ var footerContent = '
' + lang('show details') + ''
+ footerContent += '' + lang('edit') + ''
footer.innerHTML = footerContent
popup._contentNode.appendChild(footer)
diff --git a/src/httpGet.js b/src/httpGet.js
index dcc0cb8f..a07695f6 100644
--- a/src/httpGet.js
+++ b/src/httpGet.js
@@ -1,9 +1,14 @@
-function httpGet (url, callback) {
- var xhr = new XMLHttpRequest()
- xhr.open('get', url, true)
- xhr.responseType = 'text'
- xhr.onreadystatechange = function () {
+function httpGet (url, options, callback) {
+ let corsRetry = true
+ var xhr
+
+ function readyStateChange () {
if (xhr.readyState === 4) {
+ if (corsRetry && xhr.status === 0) {
+ corsRetry = false
+ return viaServer()
+ }
+
if (xhr.status === 200) {
callback(null, { body: xhr.responseText })
} else {
@@ -11,7 +16,28 @@ function httpGet (url, callback) {
}
}
}
- xhr.send()
+
+ function direct () {
+ xhr = new XMLHttpRequest()
+ xhr.open('get', url, true)
+ xhr.responseType = 'text'
+ xhr.onreadystatechange = readyStateChange
+ xhr.send()
+ }
+
+ function viaServer () {
+ xhr = new XMLHttpRequest()
+ xhr.open('get', 'httpGet.php?url=' + encodeURIComponent(url), true)
+ xhr.responseType = 'text'
+ xhr.onreadystatechange = readyStateChange
+ xhr.send()
+ }
+
+ if (options.forceServerLoad) {
+ viaServer()
+ } else {
+ direct()
+ }
}
module.exports = httpGet
diff --git a/src/image.js b/src/image.js
index 5ac6be88..3d5e07d8 100644
--- a/src/image.js
+++ b/src/image.js
@@ -1,3 +1,4 @@
+var httpGet = require('./httpGet')
var ImageLoader = require('./ImageLoader')
var showTimer
@@ -9,17 +10,25 @@ function showImage (image, dom) {
}
function showWikimediaImage (image, dom) {
- var size = 400
- if ('width' in image && image.width < size) {
- size = image.width
- }
+ httpGet(
+ 'https://commons.wikimedia.org/wiki/File:' + encodeURIComponent(image.id),
+ {
+ forceServerLoad: true
+ },
+ function (err, result) {
+ if (!result) {
+ return
+ }
- var url = 'https://commons.wikimedia.org/w/thumb.php?f=' + encodeURIComponent(image.id) + '&w=' + size
+ let m = result.body.match('img .* src="([^"]+)" .* data-file-width="([0-9]+)" data-file-height="([0-9]+)"')
+ let src = m[1]
- var div = document.createElement('div')
- div.innerHTML = ''
+ var div = document.createElement('div')
+ div.innerHTML = ''
- dom.appendChild(div)
+ dom.appendChild(div)
+ }
+ )
}
// feature: { id: 'File:xxx.jpg', type: 'wikimedia|url', url: 'https://...' }
diff --git a/src/index.js b/src/index.js
index 4af743c2..bee2ceb1 100644
--- a/src/index.js
+++ b/src/index.js
@@ -186,7 +186,7 @@ function show (id, options, callback) {
if (options.showDetails) {
call_hooks('hide-' + document.getElementById('content').className)
document.getElementById('content').className = 'details'
- document.getElementById('contentDetails').innerHTML = 'Loading ...'
+ document.getElementById('contentDetails').innerHTML = lang('loading')
}
var m = id.match(/^(.*)\/([nwr]\d+)(\/details)?$/)
@@ -269,7 +269,7 @@ window.showDetails = function (data, category) {
)
h = document.createElement('h3')
- h.innerHTML = 'Attributes'
+ h.innerHTML = lang('header:attributes')
dom.appendChild(h)
div = document.createElement('dl')
@@ -286,7 +286,7 @@ window.showDetails = function (data, category) {
dom.appendChild(div)
h = document.createElement('h3')
- h.innerHTML = 'OSM Meta'
+ h.innerHTML = lang('header:osm_meta')
dom.appendChild(h)
div = document.createElement('dl')
diff --git a/src/wikidata.js b/src/wikidata.js
index 55c5f678..fe7da3ab 100644
--- a/src/wikidata.js
+++ b/src/wikidata.js
@@ -13,7 +13,7 @@ function wikidataLoad (id, callback) {
}
loadClash[id] = []
- httpGet('https://www.wikidata.org/wiki/Special:EntityData/' + id + '.json', function (err, result) {
+ httpGet('https://www.wikidata.org/wiki/Special:EntityData/' + id + '.json', {}, function (err, result) {
if (err) {
return callback(err, null)
}
diff --git a/style.css b/style.css
index 3fab58f5..2442f96a 100644
--- a/style.css
+++ b/style.css
@@ -109,11 +109,13 @@ a:active {
margin-left: 0;
}
-#content a.showDetails {
- display: none;
+.leaflet-popup-content ul.popup-footer {
+ padding: 0;
}
-a.showDetails {
- display: block;
+.leaflet-popup-content ul.popup-footer li {
+ display: inline-block;
+ list-style: none;
+ padding-right: 1em;
}
/* Footer */