-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js.map
1 lines (1 loc) · 77.4 KB
/
app.js.map
1
{"version":3,"sources":["app/initialize.js","app/lib/editor.js","app/lib/getUrlVars.js","app/lib/map.js","app/lib/red_fetch.js","app/lib/taxonomy.js","app/lib/translations.js"],"names":["editor","require","document","addEventListener","console","log","initMap","getUrlVars","redFetch","taxonomy","translations","window","map","endpoint","module","exports","urlVars","dataUrls","place","test","normalizedPlace","replace","length","createToiArray","toiString","toiArray","split","i","trim","startLang","selectAllowedLang","current_lang","supported_languages","typeOfInintiatives","toiHashtable","fillTransforMapTax","data","dataArray","results","bindings","itemLabel","needs","interactions","identities","forEach","entry","subclass_of","label","value","currentObject","item","needs_tag","push","interaction_tag","identity_tag","$","empty","newOption","attr","currentData","properties","provides","needs_array","need","append","selectpicker","interaction","interactions_array","interact","identity","identity_array","fillTOIs","toiSelect","getElementById","type_of_initiative_tag","labelCompare","a","b","match","sort","createElement","optionValue","createAttribute","setAttributeNode","type_of_initiative","tois","toi","newSelected","createTextNode","appendChild","addFreeTagsRow","freetags","lastRow","lastChild","nodeType","previousSibling","keyNode","firstChild","nextSibling","newNr","parseInt","id","slice","newRow","divClass","newKey","bootstrapClass","newValue","keyId","valueId","elementName","cloneNode","fillForm","placeData","_deleted","style","display","key","field","valueNode","geometry","coordinates","lon","lat","undefined","error","my_current_marker","L","marker","icon","my_placeMarker","my_editableLayers","addLayer","my_drawControl","getDrawControl","addControl","panTo","LatLng","_id","osm","e","menu","initializeTranslatedTOIs","Q5data","initializeLanguageSwitcher","nowPossibleLang","fetchAndSetNewTranslation","lang","getLangTaxURL","cacheBusting","createCORSRequest","method","url","xhr","XMLHttpRequest","open","XDomainRequest","clickSubmit","requiredFields","alert","parseFloat","allInputs","getElementsByTagName","freeTags","keys","values","element","type","name","nr","keynr","allSelects","childCounter","children","child","selected","allTextareas","uuid","sendData","JSON","stringify","setRequestHeader","send","onreadystatechange","readyState","status","retJson","parse","responseText","onclick","clickDelete","confirm","clickSearch","country","city","street","housenumber","querystring","query","successData","result","class","focus","setView","setTimeout","stopRKey","evt","event","node","target","srcElement","keyCode","onkeypress","updateLinkPosition","centre","getCenter","targetlocation","getZoom","lng","maplink","href","getAttribute","splitstr","setAttribute","newlink","on","vars","parts","location","m","L_Hash","L_Draw","editableLayers","drawControl","placeMarker","popupText","allowNewMarker","markerValue","options","position","draw","polyline","polygon","rectangle","circle","edit","featureGroup","remove","Control","Draw","attrOsm","attrPois","leafletBgMaps","zoom","defaultlayer","center","baseMaps","tileLayer","attribution","maxZoom","noWrap","zoomControl","layers","ctrl","Layers","hash","Hash","FeatureGroup","Icon","extend","shadowUrl","iconAnchor","Point","iconSize","iconUrl","Event","CREATED","layerType","layer","bindPopup","_latlng","toFixed","removeControl","updateMarkerFromForm","coords","latLng","setLatLng","onblur","processStatus","response","Promise","resolve","reject","Error","statusText","parseJson","json","getWrappedPromise","wrappedPromise","promise","then","bind","catch","getWrappedFetch","args","Array","prototype","call","arguments","fetch","apply","MAX_WAITING_TIME","getJSON","params","wrappedFetch","Date","getTime","headers","timeoutId","clearTimeout","myGetJSON","successFunction","errorFunction","getJSONparams","redundantFetch","dataUrlArray","constructor","currentUrl","shift","localErrorFunction","localSuccessFunction","tax_query","encodeURIComponent","getLangs","language","navigator","languages","userLanguage","short_lang","indexOf","setFallbackLangs","fallback_langs","browser_languages","abbr","join","resetLang","abbr_langnames","switchToLang","langnames","langnames_abbr","returned_data","entities","Q5","labels","langstr","langstr_query","langstrings","langLabel","langcode","is_default","removeClass","addClass","wishedLang","matches"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAMA,SAASC,QAAQ,YAAR,CAAf;;AAEAC,SAASC,gBAAT,CAA0B,kBAA1B,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B;AAAA,IACI9S,eAAeuT,kBAAkB,CAAlB,CADnB;AAAA,IAEID,iBAAiB,EAFrB;;AAIAvU,OAAOC,OAAP,GAAiB;AACf8T,YAAUA,QADK;AAEf7L,8BAA4BA,0BAFb;AAGfhH,uBAAqBA,mBAHN;AAIfsT,qBAAmBA,iBAJJ;AAKfvT,gBAAcA,YALC;AAMf4T,gBAAcA,YANC;AAOf7T,qBAAmBA;AAPJ,CAAjB","file":"public/app.js","sourcesContent":["const editor = require('lib/editor')\n\ndocument.addEventListener('DOMContentLoaded', () => {\n // do your setup here\n editor()\n console.log('Initialized app')\n})\n","/* global alert, L, XMLHttpRequest, XDomainRequest */ // used by standardjs (linter)\n\nconst initMap = require('./map.js')\nconst getUrlVars = require('./getUrlVars.js')\nconst redFetch = require('./red_fetch.js')\nconst taxonomy = require('./taxonomy.js')\nconst translations = require('./translations.js')\nwindow.translations = translations\n\nvar map\nconst endpoint = 'https://data.transformap.co/place/'\n\nmodule.exports = function () {\n console.log('editor initialize start')\n\n map = initMap()\n\n var urlVars = getUrlVars()\n var dataUrls\n const place = urlVars['place']\n if (place) {\n if (/^[0-9a-f-]{32,36}$/i.test(place)) {\n const normalizedPlace = place.replace(/-/, '')\n if (normalizedPlace.length === 32) {\n dataUrls = [ endpoint + place, 'http://192.168.0.2:6000/place/' + place, place ]\n } else {\n dataUrls = [ place ]\n }\n } else {\n dataUrls = [ place ]\n }\n }\n\n function createToiArray (toiString) {\n if (typeof (toiString) !== 'string') { return [] }\n var toiArray = toiString.split(';')\n for (var i = 0; i < toiArray.length; i++) {\n toiArray[i] = toiArray[i].trim()\n }\n return toiArray\n }\n\n var startLang = translations.selectAllowedLang(translations.current_lang)\n console.log(\"lang on start: \" + startLang)\n console.log(translations.supported_languages)\n var typeOfInintiatives = []\n var toiHashtable = {}\n\n function fillTransforMapTax (data) {\n console.log('fillTransforMapTax called')\n\n var dataArray = data.results.bindings\n const current_lang = dataArray[0].itemLabel['xml:lang']\n \n var needs = []\n var interactions = []\n var identities = []\n\n dataArray.forEach(function (entry) {\n if (!entry.subclass_of) {\n return\n }\n var label = {}\n label[current_lang] = entry.itemLabel.value\n var currentObject = {\n item: entry.item.value,\n label: label\n }\n if(entry.subclass_of.value == 'https://base.transformap.co/entity/Q146') {\n currentObject['needs_tag'] = entry.needs_tag.value\n needs.push(currentObject)\n } else if (entry.subclass_of.value == 'https://base.transformap.co/entity/Q150') {\n currentObject['interaction_tag'] = entry.interaction_tag.value\n interactions.push(currentObject)\n } else if (entry.subclass_of.value == 'https://base.transformap.co/entity/Q176') {\n currentObject['identity_tag'] = entry.identity_tag.value\n identities.push(currentObject)\n }\n });\n\n //needs\n $('#_key_provides').empty()\n needs.forEach(function (entry) {\n var newOption = $('<option>')\n newOption.attr('value', entry.needs_tag)\n\n if (currentData.properties && currentData.properties.provides) {\n var needs_array = createToiArray(currentData.properties.provides)\n needs_array.forEach(function (need) {\n if (need === entry.needs_tag) {\n newOption.attr('selected','selected')\n }\n })\n }\n newOption.append(entry.label[current_lang])\n $('#_key_provides').append(newOption)\n $('#_key_provides').selectpicker('refresh')\n })\n\n //interaction\n $('#_key_interaction').empty()\n interactions.forEach(function (entry) {\n var newOption = $('<option>')\n newOption.attr('value', entry.interaction_tag)\n\n if (currentData.properties && currentData.properties.interaction) {\n var interactions_array = createToiArray(currentData.properties.interaction)\n interactions_array.forEach(function (interact) {\n if (interact === entry.interaction_tag) {\n newOption.attr('selected','selected')\n }\n })\n }\n newOption.append(entry.label[current_lang])\n $('#_key_interaction').append(newOption)\n $('#_key_interaction').selectpicker('refresh')\n })\n\n //identity\n $('#_key_identity').empty()\n identities.forEach(function (entry) {\n var newOption = $('<option>')\n newOption.attr('value', entry.identity_tag)\n\n if (currentData.properties && currentData.properties.identity) {\n var identity_array = createToiArray(currentData.properties.identity)\n identity_array.forEach(function (identity) {\n if (identity === entry.identity_tag) {\n newOption.attr('selected','selected')\n }\n })\n }\n newOption.append(entry.label[current_lang])\n $('#_key_identity').append(newOption)\n $('#_key_identity').selectpicker('refresh')\n })\n }\n\n function fillTOIs (data) {\n $('#_key_type_of_initiative').empty()\n\n typeOfInintiatives = []\n toiHashtable = {}\n\n var toiSelect = document.getElementById('_key_type_of_initiative')\n var dataArray = data.results.bindings\n const current_lang = dataArray[0].itemLabel['xml:lang']\n dataArray.forEach(function (entry) {\n if (!entry.type_of_initiative_tag) {\n return\n }\n if (toiHashtable[entry.type_of_initiative_tag.value]) { // filter out duplicates\n return\n }\n var label = {}\n label[current_lang] = entry.itemLabel.value\n\n var currentObject = {\n item: entry.item.value,\n label: label,\n type_of_initiative_tag: entry.type_of_initiative_tag.value\n }\n typeOfInintiatives.push(currentObject)\n toiHashtable[entry.type_of_initiative_tag.value] = currentObject\n })\n function labelCompare (a, b) {\n // 'Others' cat should get sorted last\n if (a.item === 'https://base.transformap.co/entity/Q20') return 1\n if (b.item === 'https://base.transformap.co/entity/Q20') return -1\n\n // in toi list, 'other*' should be last\n if (a.type_of_initiative_tag && a.type_of_initiative_tag.match(/^other_/)) return 1\n if (b.type_of_initiative_tag && b.type_of_initiative_tag.match(/^other_/)) return -1\n\n if (a.label[current_lang] < b.label[current_lang]) {\n return -1\n } else {\n return 1\n }\n }\n typeOfInintiatives.sort(labelCompare)\n\n typeOfInintiatives.forEach(function (entry) {\n var newOption = document.createElement('option')\n var optionValue = document.createAttribute('value')\n optionValue.value = entry.type_of_initiative_tag\n newOption.setAttributeNode(optionValue)\n\n if (currentData.properties && currentData.properties.type_of_initiative) {\n var tois = createToiArray(currentData.properties.type_of_initiative)\n tois.forEach(function (toi) {\n if (toi === entry.type_of_initiative_tag) {\n var newSelected = document.createAttribute('selected')\n newOption.setAttributeNode(newSelected)\n }\n })\n }\n\n var label = document.createTextNode(entry.label[current_lang]) // FIXME fallback langs\n newOption.appendChild(label)\n\n toiSelect.appendChild(newOption)\n $('#_key_type_of_initiative').selectpicker('refresh')\n\n })\n }\n\n function addFreeTagsRow () {\n var freetags = document.getElementById('freetags')\n\n var lastRow = freetags.lastChild\n while (lastRow.nodeType === 3) { // 3 = text-node\n lastRow = lastRow.previousSibling\n }\n\n var keyNode = (lastRow.firstChild.nodeType === 1) ? lastRow.firstChild : lastRow.firstChild.nextSibling\n var newNr = parseInt(keyNode.id.slice(-1)) + 1\n\n var newRow = document.createElement('div')\n var divClass = document.createAttribute('class')\n divClass.value = 'row'\n newRow.setAttributeNode(divClass)\n var newKey = document.createElement('input')\n var bootstrapClass = document.createAttribute('class')\n bootstrapClass.value = 'form-control';\n newKey.setAttributeNode(bootstrapClass);\n var bootstrapClass = document.createAttribute('class')\n bootstrapClass.value = 'form-control';\n var newValue = document.createElement('input')\n newValue.setAttributeNode(bootstrapClass);\n var keyId = document.createAttribute('id')\n keyId.value = 'key' + newNr\n var valueId = document.createAttribute('id')\n valueId.value = 'value' + newNr\n newKey.setAttributeNode(keyId)\n newValue.setAttributeNode(valueId)\n\n var elementName = document.createAttribute('name')\n elementName.value = 'freetags'\n newKey.setAttributeNode(elementName)\n newValue.setAttributeNode(elementName.cloneNode(true))\n\n newRow.appendChild(newKey)\n newRow.appendChild(newValue)\n freetags.appendChild(newRow)\n }\n\n var currentData = {}\n\n function fillForm (placeData) {\n currentData = placeData\n\n if (currentData._deleted) {\n document.getElementById('deleted').style.display = 'block'\n }\n\n if (currentData.properties) {\n for (var key in currentData.properties) {\n // ignore DB-generated fields\n if (/^_/.test(key)) {\n continue\n }\n\n var field = document.getElementById('_key_' + key)\n var value = currentData.properties[key]\n\n if (field) {\n // console.log(field)\n // console.log(value)\n field.value = value\n } else { // put it into \"free tags\"\n // get last child\n var freetags = document.getElementById('freetags')\n var lastRow = freetags.lastChild\n while (lastRow.nodeType === 3) { // 3 = text-node\n lastRow = lastRow.previousSibling\n }\n\n // set data on last child\n var keyNode = (lastRow.firstChild.nodeType === 1) ? lastRow.firstChild : lastRow.firstChild.nextSibling\n keyNode.value = key\n var valueNode = (lastRow.lastChild.nodeType === 1) ? lastRow.lastChild : lastRow.lastChild.previousSibling\n valueNode.value = value\n\n addFreeTagsRow()\n }\n }\n }\n if (currentData.geometry && currentData.geometry.coordinates) {\n var lon = currentData.geometry.coordinates[0]\n var lat = currentData.geometry.coordinates[1]\n if (lat === undefined || lon === undefined) {\n console.error('lat or lon empty')\n return\n }\n\n document.getElementById('_geometry_lon').value = lon\n document.getElementById('_geometry_lat').value = lat\n\n map.my_current_marker = new L.marker([lat, lon], { icon: new map.my_placeMarker() })\n map.my_editableLayers.addLayer(map.my_current_marker)\n\n map.my_drawControl = map.getDrawControl(false)\n map.addControl(map.my_drawControl)\n\n map.panTo(new L.LatLng(lat, lon))\n } else { // allow adding a marker\n map.my_drawControl = map.getDrawControl(true)\n map.addControl(map.my_drawControl)\n }\n if (currentData.properties && currentData.properties._id) {\n document.getElementById('_id').value = currentData.properties._id\n $('#transformapapilink').attr('href', endpoint + currentData.properties._id)\n } else if (currentData._id) {\n document.getElementById('_id').value = currentData._id\n $('#transformapapilink').attr('href', endpoint + currentData._id)\n }\n if(currentData.properties.osm) {\n $('#osmlink').attr('href', currentData.properties.osm)\n }\n }\n\n if (place) {\n redFetch(dataUrls, fillForm, function (e) {\n console.error(e)\n map.my_drawControl = map.getDrawControl(true)\n map.addControl(map.my_drawControl)\n })\n } else {\n map.my_drawControl = map.getDrawControl(true)\n map.addControl(map.my_drawControl)\n }\n\n //add languageswitcher\n var menu = document.getElementById('menu')\n $('#menu').append(\n '<div id=languageSelector onClick=\"$(\\'#languageSelector ul\\').toggleClass(\\'open\\');\">' +\n '<span lang=en>Choose Language:</span>' +\n '<ul></ul>' +\n '</div>')\n\n function initializeTranslatedTOIs(Q5data) {\n translations.initializeLanguageSwitcher(Q5data)\n \n var nowPossibleLang = translations.selectAllowedLang(translations.current_lang)\n translations.current_lang = nowPossibleLang\n fetchAndSetNewTranslation(nowPossibleLang)\n }\n\n function fetchAndSetNewTranslation(lang) {\n redFetch([ taxonomy.getLangTaxURL(lang, 'Q8'), 'https://raw.githubusercontent.com/TransforMap/transformap-viewer-translations/master/taxonomy-backup/susy/taxonomy.' + lang + '.json' ],\n fillTOIs,\n function (error) { console.error('none of the taxonomy data urls available') },\n { cacheBusting: false })\n redFetch([ taxonomy.getLangTaxURL(lang, 'Q4'), 'https://raw.githubusercontent.com/TransforMap/transformap-viewer-translations/master/taxonomy-backup/susy/taxonomy.' + lang + '.json' ],\n fillTransforMapTax,\n function (error) { console.error('none of the taxonomy data urls available') },\n { cacheBusting: false })\n }\n translations.fetchAndSetNewTranslation = fetchAndSetNewTranslation\n\n redFetch( [ \"https://base.transformap.co/wiki/Special:EntityData/Q5.json\", \"https://raw.githubusercontent.com/TransforMap/transformap-viewer/Q5-fallback.json\" ],\n initializeTranslatedTOIs,\n function(error) { console.error(\"none of the lang init data urls available\") } );\n\n\n function createCORSRequest (method, url) {\n // taken from https://www.html5rocks.com/en/tutorials/cors/\n var xhr = new XMLHttpRequest()\n if ('withCredentials' in xhr) {\n // Check if the XMLHttpRequest object has a \"withCredentials\" property.\n // \"withCredentials\" only exists on XMLHTTPRequest2 objects.\n xhr.open(method, url, true)\n } else if (typeof XDomainRequest !== 'undefined') {\n // Otherwise, check if XDomainRequest.\n // XDomainRequest only exists in IE, and is IE's way of making CORS requests.\n xhr = new XDomainRequest()\n xhr.open(method, url)\n } else {\n // Otherwise, CORS is not supported by the browser.\n xhr = null\n }\n return xhr\n }\n\n function clickSubmit () {\n console.log('clickSubmit enter')\n const requiredFields = [ '_key_type_of_initiative', '_key_name', '_geometry_lat', '_geometry_lon' ]\n for (var i = 0; i < requiredFields.length; i++) {\n var id = requiredFields[i]\n var value = document.getElementById(id).value\n if (!value || !value.length) {\n console.error('submit: field ' + id + ' empty')\n alert('Error on submit: field ' + id.replace(/^_key_/, '') + ' is not allowed to be empty')\n return false\n }\n }\n\n var data = {\n 'type': 'Feature',\n 'properties': {\n },\n 'geometry': {\n 'type': 'Point',\n 'coordinates': [\n parseFloat(document.getElementById('_geometry_lon').value),\n parseFloat(document.getElementById('_geometry_lat').value)\n ]\n }\n }\n\n // all 'input type=text'\n var allInputs = document.getElementsByTagName('input')\n var freeTags = { keys: {}, values: {} }\n\n console.log(allInputs)\n\n for (var i = 0; i < allInputs.length; i++) {\n var element = allInputs[i]\n if (!element.type === 'text') {\n continue\n }\n if (element.value && element.id) {\n console.log(element.id + ': ' + element.value)\n if (/^_key_/.test(element.id)) {\n var key = element.id.replace(/^_key_/, '')\n data.properties[key] = element.value.trim()\n // element of 'free tags'\n } else if (/^key[0-9]+$/.test(element.id) && element.name === 'freetags') {\n var nr = element.id.replace(/^key/, '')\n freeTags.keys[nr] = element.value\n } else if (/^value[0-9]+$/.test(element.id) && element.name === 'freetags') {\n var nr = element.id.replace(/^value/, '')\n freeTags.values[nr] = element.value\n }\n }\n }\n console.log(freeTags)\n\n for (var keynr in freeTags.keys) {\n var key = freeTags.keys[keynr].trim()\n if (key && freeTags.values[keynr]) { // only take if key and value are not \"\"\n data.properties[key] = freeTags.values[keynr].trim()\n }\n }\n\n // drop-down\n var allSelects = document.getElementsByTagName('select')\n for (var i = 0; i < allSelects.length; i++) {\n var element = allSelects[i]\n if (/^_key_/.test(element.id) && element.value) {\n var key = element.id.replace(/^_key_/, '')\n\n for (var childCounter = 0; childCounter < element.children.length; childCounter++) {\n var child = element.children[childCounter]\n if (child.selected === true) {\n data.properties[key] = (data.properties[key] ? (data.properties[key] + ';') : '') + child.value\n }\n }\n }\n }\n\n // textarea\n var allTextareas = document.getElementsByTagName('textarea')\n for (var i = 0; i < allTextareas.length; i++) {\n var element = allTextareas[i]\n if (/^_key_/.test(element.id) && element.value) {\n var key = element.id.replace(/^_key_/, '')\n data.properties[key] = element.value.trim()\n }\n }\n\n console.log(data)\n\n const uuid = document.getElementById('_id').value\n const sendData = JSON.stringify(data)\n console.log(sendData)\n\n // PUT is for UPDATE, POST is for CREATE\n var xhr = createCORSRequest(uuid ? 'PUT' : 'POST', endpoint + uuid)\n xhr.setRequestHeader('Content-Type', 'application/json')\n xhr.send(sendData)\n console.log(xhr)\n\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n var retJson = JSON.parse(xhr.responseText)\n console.log(retJson)\n if(retJson.id) {\n document.getElementById('_id').value = retJson.id\n $('#transformapapilink').attr('href', endpoint + retJson.id)\n $('#osmlink').attr('href', $('#_key_osm').attr('value') )\n alert('Save successful')\n } else {\n alert('Error: something wrent wrong on saving: ' + JSON.stringify(retJson) )\n }\n } else {\n console.error(xhr)\n }\n }\n }\n document.getElementById('deleted').style.display = 'none'\n }\n document.getElementById('save').onclick = clickSubmit\n\n function clickDelete () {\n const uuid = document.getElementById('_id').value\n if (!uuid) {\n alert('nothing to delete')\n return\n }\n if(!confirm('Do you really want to delete this POI? It will be only marked as deleted and can be restored later if you save the current Browser URL.')) {\n console.log('user aborted delete')\n return\n }\n var xhr = createCORSRequest('DELETE', endpoint + uuid)\n xhr.send()\n console.log(xhr)\n\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n var retJson = JSON.parse(xhr.responseText)\n console.log(retJson)\n } else {\n console.error(xhr)\n }\n }\n }\n document.getElementById('deleted').style.display = 'block'\n }\n document.getElementById('delete').onclick = clickDelete\n document.getElementById('plus').onclick = addFreeTagsRow\n\n function clickSearch () {\n const country = document.getElementById('_key_addr:country').value\n const city = document.getElementById('_key_addr:city').value\n // const postcode = document.getElementById('_key_addr:postcode').value // postcode not used in nominatim, decreases result quality\n const street = document.getElementById('_key_addr:street').value\n const housenumber = document.getElementById('_key_addr:housenumber').value\n\n var querystring = 'q='\n if (street) {\n if (housenumber) {\n querystring += housenumber + '+'\n }\n querystring += street + ','\n }\n if (city) {\n querystring += city + ','\n }\n querystring += country\n\n var query = '//nominatim.openstreetmap.org/search?' + querystring + '&format=json&limit=1&[email protected]'\n console.log(query)\n\n redFetch([ query ],\n function (successData) {\n console.log(successData)\n if (successData.length !== 1) {\n console.error('error in Nominatim return data: length != 1')\n alert('Sorry, Nothing found')\n return\n }\n var result = successData[0]\n if (result.class === 'building' ||\n result.class === 'amenity' ||\n result.class === 'shop' ||\n (result.class === 'place' && result.type === 'house')\n ) {\n console.log('address found exactly')\n document.getElementById('_geometry_lon').value = result.lon\n document.getElementById('_geometry_lat').value = result.lat\n\n // trigger update of place marker\n document.getElementById('_geometry_lat').focus()\n document.getElementById('_geometry_lon').focus()\n map.setView(new L.LatLng(result.lat, result.lon), 18)\n } else {\n map.setView(new L.LatLng(result.lat, result.lon), 18)\n console.log('address not found exactly')\n setTimeout(function () { // wait for map to pan to location\n alert('Attention: The address was not found exactly, please place the marker manually!')\n document.getElementById('_geometry_lon').value = ''\n document.getElementById('_geometry_lat').value = ''\n document.getElementById('_geometry_lon').focus()\n document.getElementById('_geometry_lat').focus()\n }, 400)\n }\n },\n function (error) {\n console.log(error)\n alert('Sorry, Address search did not work')\n }\n )\n }\n document.getElementById('coordsearch').onclick = clickSearch\n\n function stopRKey(evt) {\n var evt = (evt) ? evt : ((event) ? event : null)\n var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null)\n if ((evt.keyCode == 13) && (node.type == 'text')) {\n return false\n } \n }\n document.onkeypress = stopRKey\n\n function updateLinkPosition() {\n var centre = map.getCenter()\n var targetlocation = '#' + map.getZoom() + '/' + centre.lat + '/' + centre.lng\n\n var maplink = document.getElementById('gotomap')\n var href = maplink.getAttribute ('href')\n var splitstr = href.split('#')\n href = maplink.getAttribute ('href').split('#')[0] + targetlocation\n maplink.setAttribute('href',href);\n\n var newlink = document.getElementById('newbutton')\n newlink.setAttribute('href','./' + targetlocation)\n\n\n }\n map.on('moveend', updateLinkPosition);\n\n console.log('editor initialize end')\n}\n","/*\n * This library provides a simple function to parse URL parameters\n *\n * Mon 3 Oct 15:07:12 CEST 2016\n * Michael Maier (species@github), WTFPL\n *\n * returns object with key:value pairs\n\n This program is free software. It comes without any warranty, to\n * the extent permitted by applicable law. You can redistribute it\n * and/or modify it under the terms of the Do What The Fuck You Want\n * To Public License, Version 2, as published by Sam Hocevar. See\n * http://www.wtfpl.net/ for more details. */\n\nfunction getUrlVars () {\n var vars = {}\n var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {\n vars[key] = value.replace(/#.*$/, '')\n })\n return vars\n}\n\nmodule.exports = getUrlVars\n","const L = require('leaflet')\nconst L_Hash = require('leaflet-hash')\nconst L_Draw = require('leaflet-draw')\n\nvar editableLayers\nvar drawControl\nvar placeMarker\nvar popupText = 'Press the edit button to move me. <img style=\"width:30px;height:30px;background-position:-150px -1px;background-image:url(\\'images/spritesheet.svg\\');background-size: 270px 30px;\"> <br><br> Find it on the bottom left corner of the map.'\n\nfunction getDrawControl (allowNewMarker) {\n var markerValue = allowNewMarker ? { icon: new placeMarker() } : false\n var options = {\n position: 'bottomleft',\n draw: {\n polyline: false,\n polygon: false,\n rectangle: false,\n circle: false,\n marker: markerValue\n },\n edit: {\n featureGroup: editableLayers, // REQUIRED!!\n remove: false\n }\n }\n return new L.Control.Draw(options)\n}\n\nfunction initMap () {\n console.log('initMap start')\n var map\n\n var attrOsm = 'Map data by <a href=\"https://openstreetmap.org\">OpenStreetMap</a> contributors, under <a href=\"https://www.openstreetmap.org/copyright\">ODbL</a>. '\n var attrPois = 'POIs by <a href=\"http://solidariteconomy.eu\">SUSY</a>, <a href=\"https://creativecommons.org/publicdomain/zero/1.0/\">CC-0</a>. '\n var leafletBgMaps\n var zoom\n var defaultlayer\n var center\n var baseMaps = {}\n\n baseMaps['mapnik'] = new L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {\n attribution: attrOsm + attrPois,\n maxZoom: 19,\n noWrap: true\n })\n baseMaps['stamen_terrain'] = new L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png', {\n attribution: 'Map tiles by <a href=\"http://stamen.com/\">Stamen Design</a>, ' +\n 'under <a href=\"https://creativecommons.org/licenses/by/3.0\">CC BY 3.0</a>. ' +\n attrOsm + attrPois,\n maxZoom: 18,\n noWrap: true\n })\n baseMaps['stamen_terrain_bg'] = new L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/terrain-background/{z}/{x}/{y}.png', {\n attribution: 'Map tiles by <a href=\"http://stamen.com/\">Stamen Design</a>, ' +\n 'under <a href=\"https://creativecommons.org/licenses/by/3.0\">CC BY 3.0</a>. ' +\n attrOsm + attrPois,\n maxZoom: 18,\n noWrap: true\n })\n baseMaps['hot'] = new L.tileLayer('http://tile-{s}.openstreetmap.fr/hot/{z}/{x}/{y}.png', {\n attribution: 'Tiles courtesy of <a href=\"http://hot.openstreetmap.org/\">Humanitarian OpenStreetMap Team</a>. ' +\n attrOsm + attrPois,\n maxZoom: 20,\n noWrap: true\n })\n\n if (!leafletBgMaps) {\n leafletBgMaps = {\n 'Stamen - Terrain': baseMaps['stamen_terrain'],\n 'Stamen - Terrain Background': baseMaps['stamen_terrain_bg'],\n 'OpenStreetMap - Mapnik': baseMaps['mapnik'],\n 'Humanitarian OpenStreetMap ': baseMaps['hot']\n }\n }\n if (!defaultlayer) {\n defaultlayer = baseMaps['mapnik']\n }\n\n map = L.map('map', {\n zoomControl: true,\n center: center ? center : new L.LatLng(28.6, 9),\n zoom: zoom ? zoom : 2,\n layers: defaultlayer\n })\n\n const ctrl = new L.Control.Layers(leafletBgMaps)\n map.addControl(ctrl)\n var hash = new L.Hash(map) // Leaflet persistent Url Hash function\n\n // leaflet draw\n editableLayers = new L.FeatureGroup()\n map.addLayer(editableLayers)\n placeMarker = L.Icon.extend({\n options: {\n shadowUrl: null,\n iconAnchor: new L.Point(12, 40),\n iconSize: new L.Point(25, 40),\n iconUrl: 'marker-green.png'\n }\n })\n\n map.on(L.Draw.Event.CREATED, function (e) {\n var type = e.layerType\n var layer = e.layer\n\n if (type === 'marker') {\n layer.bindPopup(popupText)\n }\n\n editableLayers.addLayer(layer)\n map.my_current_marker = layer\n document.getElementById('_geometry_lon').value = layer._latlng.lng.toFixed(6)\n document.getElementById('_geometry_lat').value = layer._latlng.lat.toFixed(6)\n\n map.removeControl(map.my_drawControl)\n map.my_drawControl = getDrawControl(false) // deactivate \"add marker\" after the 1st one\n map.addControl(map.my_drawControl)\n // fixme instantly enable 'edit' mode of layer\n })\n\n map.on('draw:editmove', function (e) {\n console.log('editmove')\n console.log(e)\n document.getElementById('_geometry_lon').value = e.layer._latlng.lng.toFixed(6)\n document.getElementById('_geometry_lat').value = e.layer._latlng.lat.toFixed(6)\n })\n\n map.my_editableLayers = editableLayers\n // map.my_drawControl = drawControl\n map.my_placeMarker = placeMarker\n map.getDrawControl = getDrawControl\n\n map.updateMarkerFromForm = function () {\n const lat = document.getElementById('_geometry_lat').value\n const lon = document.getElementById('_geometry_lon').value\n console.log('new lat: ' + lat + ' lon: ' + lon)\n\n if (lat && lon) {\n const coords = L.latLng(lat, lon)\n if(map.my_current_marker) {\n map.my_current_marker.setLatLng(coords)\n } else {\n map.my_current_marker = new L.marker([lat, lon], { icon: new map.my_placeMarker() })\n map.my_current_marker.bindPopup(popupText)\n map.my_editableLayers.addLayer(map.my_current_marker)\n map.removeControl(map.my_drawControl)\n map.my_drawControl = getDrawControl(false)\n map.addControl(map.my_drawControl)\n }\n \n map.panTo(coords)\n }\n else\n {\n //delete marker\n console.log('no coords, remove marker')\n map.my_current_marker.remove()\n delete(map.my_current_marker)\n map.removeControl(map.my_drawControl)\n map.my_drawControl = getDrawControl(true) // allow \"add marker\" again\n map.addControl(map.my_drawControl)\n }\n }\n document.getElementById('_geometry_lat').onblur = map.updateMarkerFromForm\n document.getElementById('_geometry_lon').onblur = map.updateMarkerFromForm\n\n // console.log(map)\n\n console.log('initMap end')\n return map\n}\n\nmodule.exports = initMap\n","/*\n * This library provides a 'fetch', where you can use fallback URIs, to build on redundant servers.\n *\n * Mon 3 Oct 15:07:12 CEST 2016\n * Michael Maier (species@github), WTFPL\n *\n * Give it an array of resources, that can be fetched from different urls.\n * Will try to fetch them in the provided order.\n * Execute successFunction on the first successful fetch, and errorFunction only if all resources fail to fetch.\n */\n\n/* This program is free software. It comes without any warranty, to\n * the extent permitted by applicable law. You can redistribute it\n * and/or modify it under the terms of the Do What The Fuck You Want\n * To Public License, Version 2, as published by Sam Hocevar. See\n * http://www.wtfpl.net/ for more details. */\n\n/* new version of getting map data with promises\n\n taken from https://blog.hospodarets.com/fetch_in_action\n*/\n\nvar processStatus = function (response) {\n // status '0' to handle local files fetching (e.g. Cordova/Phonegap etc.)\n if (response.status === 200 || response.status === 0) {\n return Promise.resolve(response)\n } else {\n return Promise.reject(new Error(response.statusText))\n }\n}\n\nvar parseJson = function (response) {\n return response.json()\n}\n\n/* @returns {wrapped Promise} with .resolve/.reject/.catch methods */\n// It goes against Promise concept to not have external access to .resolve/.reject methods, but provides more flexibility\nvar getWrappedPromise = function () {\n var wrappedPromise = {}\n var promise = new Promise(function (resolve, reject) {\n wrappedPromise.resolve = resolve\n wrappedPromise.reject = reject\n })\n wrappedPromise.then = promise.then.bind(promise)\n wrappedPromise.catch = promise.catch.bind(promise)\n wrappedPromise.promise = promise// e.g. if you want to provide somewhere only promise, without .resolve/.reject/.catch methods\n return wrappedPromise\n}\n\n/* @returns {wrapped Promise} with .resolve/.reject/.catch methods */\nvar getWrappedFetch = function () {\n var wrappedPromise = getWrappedPromise()\n var args = Array.prototype.slice.call(arguments)// arguments to Array\n\n window.fetch.apply(null, args)// calling original fetch() method\n .then(function (response) {\n wrappedPromise.resolve(response)\n }, function (error) {\n wrappedPromise.reject(error)\n })\n .catch(function (error) {\n wrappedPromise.catch(error)\n })\n return wrappedPromise\n}\n\n/**\n * Fetch JSON by url\n * @param { {\n * url: {String},\n * [cacheBusting]: {Boolean}\n * } } params\n * @returns {Promise}\n*/var MAX_WAITING_TIME = 5000// in ms\n\nvar getJSON = function (params) {\n var wrappedFetch = getWrappedFetch(\n params.cacheBusting ? params.url + '?' + new Date().getTime() : params.url,\n {\n method: 'get', // optional, 'GET' is default value\n headers: {\n 'Accept': 'application/json'\n }\n })\n\n var timeoutId = setTimeout(function () {\n wrappedFetch.reject(new Error('Load timeout for resource: ' + params.url))// reject on timeout\n }, MAX_WAITING_TIME)\n\n return wrappedFetch.promise// getting clear promise from wrapped\n .then(function (response) {\n clearTimeout(timeoutId)\n return response\n })\n .then(processStatus)\n .then(parseJson)\n}\n\nfunction myGetJSON (url, successFunction, errorFunction) {\n var getJSONparams = { url: url, cacheBusting: true }\n\n getJSON(getJSONparams).then(\n function (data) { successFunction(data) },\n function (error) { errorFunction(error) }\n )\n}\n\nfunction redundantFetch (dataUrlArray, successFunction, errorFunction, params) {\n if (!(!!dataUrlArray && Array === dataUrlArray.constructor)) {\n console.error('redundantFetch: argument is no array')\n console.error(dataUrlArray)\n return false\n }\n var currentUrl = dataUrlArray[0]\n if (typeof (currentUrl) !== 'string') {\n console.error('redundantFetch: url is no string')\n return false\n }\n\n console.log('redundantFetch called, urls:')\n console.log(dataUrlArray)\n\n dataUrlArray.shift()\n\n var localErrorFunction\n var localSuccessFunction\n if (dataUrlArray.length == 0) { // last iteration\n localSuccessFunction = successFunction\n localErrorFunction = errorFunction\n } else {\n localSuccessFunction = successFunction\n localErrorFunction = function (error) {\n redundantFetch(dataUrlArray, successFunction, errorFunction, params)\n }\n }\n\n var getJSONparams = { url: currentUrl, cacheBusting: ((params && params.cacheBusting === false) ? false : true) }\n getJSON(getJSONparams).then(\n function (data) { localSuccessFunction(data); console.log('rfetch: success on '); console.log(data) },\n function (error) { localErrorFunction(error); console.log('rfetch: fail on '); console.log(error) }\n )\n}\n\nmodule.exports = redundantFetch\n","/*\n * This library handles taxonomy related stuff for the transformap editor\n *\n * Mon 3 Oct 15:07:12 CEST 2016\n * Michael Maier (species@github), WTFPL\n\n * This program is free software. It comes without any warranty, to\n * the extent permitted by applicable law. You can redistribute it\n * and/or modify it under the terms of the Do What The Fuck You Want\n * To Public License, Version 2, as published by Sam Hocevar. See\n * http://www.wtfpl.net/ for more details. */\n\n/* takes the language (string:\"iso\"), and the wished taxonomy (string: \"Qnn\") */\nfunction getLangTaxURL (lang, taxonomy) {\n\n if (!lang) {\n console.error('setFilterLang: no lang given')\n return false\n }\n\n if(!taxonomy)\n taxonomy = \"Q8\";\n\n var tax_query =\n 'prefix bd: <http://www.bigdata.com/rdf#> ' +\n 'prefix wikibase: <http://wikiba.se/ontology#> ' +\n 'prefix wdt: <https://base.transformap.co/prop/direct/>' +\n 'prefix wd: <https://base.transformap.co/entity/>' +\n 'SELECT ?item ?itemLabel ?instance_of ?subclass_of ?type_of_initiative_tag ?interaction_tag ?needs_tag ?identity_tag ?wikipedia ?description ' +\n 'WHERE {' +\n '?item wdt:P8* wd:'+taxonomy+' .' +\n '?item wdt:P8 ?subclass_of .' +\n 'OPTIONAL { ?item wdt:P4 ?instance_of . }' +\n 'OPTIONAL { ?item wdt:P15 ?type_of_initiative_tag }' +\n 'OPTIONAL { ?item wdt:P16 ?interaction_tag }' +\n 'OPTIONAL { ?item wdt:P17 ?needs_tag }' +\n 'OPTIONAL { ?item wdt:P18 ?identity_tag }' +\n 'OPTIONAL { ?item schema:description ?description FILTER(LANG(?description) = \"' + lang + '\") }' +\n 'OPTIONAL { ?wikipedia schema:about ?item . ?wikipedia schema:inLanguage \"en\"}' +\n 'SERVICE wikibase:label {bd:serviceParam wikibase:language \"' + lang + '\" }' +\n '}'\n\n return 'https://query.base.transformap.co/bigdata/namespace/transformap/sparql?query=' + encodeURIComponent(tax_query) + '&format=json'\n}\n\nmodule.exports = {\n getLangTaxURL: getLangTaxURL\n}\n","// mostly taken from https://github.com/TransforMap/transformap-viewer/blob/gh-pages/scripts/map.js\n\nfunction getLangs () {\n var language = window.navigator.languages ? window.navigator.languages[0] : (window.navigator.language || window.navigator.userLanguage);\n\n if(typeof language === 'string')\n language = [ language ];\n\n // we need to have the following languages:\n // browserlang\n // a short one (de instead of de-AT) if not present\n // en as fallback if not present\n\n for(var i = 0; i < language.length; i++) {\n if(language[i].match(/-/)) {\n var short_lang = language[i].match(/^([a-zA-Z]*)-/)[1];\n if(language.indexOf(short_lang) == -1) {\n language.push(short_lang);\n continue;\n }\n }\n }\n\n if(language.indexOf(\"en\") == -1)\n language.push(\"en\");\n\n console.log(language);\n return language;\n}\n\nfunction setFallbackLangs() {\n fallback_langs = [];\n if(current_lang != \"en\") {\n for(var i=0; i < browser_languages.length; i++) {\n var abbr = browser_languages[i];\n if(current_lang != abbr)\n fallback_langs.push(abbr);\n }\n }\n console.log(\"new fallback langs: \" + fallback_langs.join(\",\") + \".\");\n}\n\nfunction resetLang() {\n current_lang = \"en\";\n for(var i=0; i < browser_languages.length; i++) {\n var abbr = browser_languages[i];\n if(abbr_langnames[abbr]) {\n current_lang = abbr;\n break;\n }\n }\n switchToLang(current_lang);\n}\n\n/* get languages for UI from our Wikibase, and pick languages that are translated there */\n\nvar supported_languages = [],\n langnames = [],\n abbr_langnames = {},\n langnames_abbr = {};\nfunction initializeLanguageSwitcher(returned_data){\n var lang;\n for(lang in returned_data.entities.Q5.labels) { //Q5 is arbitrary. Choose one that gets translated for sure.\n supported_languages.push(lang);\n }\n var langstr = supported_languages.join(\"|\");\n \n var langstr_query =\n 'SELECT ?lang ?langLabel ?abbr ' +\n 'WHERE' +\n '{' +\n '?lang wdt:P218 ?abbr;' +\n 'FILTER regex (?abbr, \"^('+langstr+')$\").' +\n 'SERVICE wikibase:label { bd:serviceParam wikibase:language \"en\". }' +\n '}';\n \n langstr_query = 'https://query.wikidata.org/bigdata/namespace/wdq/sparql?query=' +encodeURIComponent(langstr_query) + \"&format=json\";\n $.getJSON(langstr_query, function (langstrings){\n \n langstrings.results.bindings.forEach(function (item) {\n abbr_langnames[item.abbr.value] = item.langLabel.value;\n langnames_abbr[item.langLabel.value] = item.abbr.value;\n langnames.push(item.langLabel.value);\n });\n langnames.sort();\n \n resetLang();\n setFallbackLangs();\n \n langnames.forEach(function (item) {\n var langcode = langnames_abbr[item];\n var is_default = (langcode == current_lang) ? \" class=default\" : \"\";\n console.log(\"adding lang '\" + langcode + \"' (\" + item + \")\"); \n $(\"#languageSelector ul\").append(\"<li targetlang=\" + langcode + is_default + \" onClick='window.translations.switchToLang(\\\"\"+langcode+\"\\\");'>\"+item+\"</li>\");\n });\n });\n}\n\nfunction switchToLang(lang) {\n $(\"#languageSelector li.default\").removeClass(\"default\");\n $(\"#languageSelector li[targetlang=\"+lang+\"]\").addClass(\"default\");\n current_lang = lang;\n window.translations.current_lang = lang;\n window.translations.fetchAndSetNewTranslation(lang);\n setFallbackLangs();\n/*\n //updateTranslatedTexts();\n\n if(! dictionary[lang]) {\n var dict_uri = \"https://raw.githubusercontent.com/TransforMap/transformap-viewer-translations/master/json/\"+lang+\".json\";\n\n $.ajax({\n url: dict_uri,\n context: { lang: current_lang },\n success: function(returned_data) {\n var trans_jsonobj = JSON.parse(returned_data);\n\n if(! dictionary[this.lang])\n dictionary[this.lang] = {};\n for (item in trans_jsonobj) {\n var index = reverse_dic[item];\n dictionary[this.lang][index] = trans_jsonobj[item];\n }\n\n console.log(\"successfully fetched \" + this.lang);\n //updateTranslatedTexts();\n\n }\n });\n\n }\n\n // As rebuilding the filters does not yet support advanced mode by default,\n // we switch to simple mode, as language switching is a very rare case.\n if(getFilterMode() == \"advanced\")\n toggleAdvancedFilterMode();\n\n resetFilter();\n setFilterLang(lang);\n*/\n console.log(\"new lang:\" +lang);\n}\n\n// if wishedLang is in supported, OK\n// shorten wishedLang and see if in supported\n// take fallback\nfunction selectAllowedLang(wishedLang) {\n console.log(\"selectAllowedLang(\" + wishedLang + \") called\")\n if(wishedLang) {\n if(supported_languages.indexOf(wishedLang) != -1) {\n current_lang = wishedLang\n return current_lang\n }\n console.log(\"not in supported, try shorten\")\n var matches = wishedLang.match(/^([a-zA-Z]*)-/)\n if(matches && matches[1]) {\n var short_lang = matches[1];\n console.log(\"short: \" + short_lang)\n if(short_lang) {\n if(supported_languages.indexOf(short_lang) != -1) {\n current_lang = short_lang\n console.log(\"current_lang set to \" + short_lang)\n return current_lang\n }\n }\n }\n }\n setFallbackLangs()\n if(fallback_langs[0]) {\n if(supported_languages.indexOf(fallback_langs[0]) != -1) {\n current_lang = fallback_langs[0]\n return current_lang\n }\n }\n current_lang = 'en'\n return current_lang\n}\n\nvar browser_languages = getLangs(),\n current_lang = browser_languages[0],\n fallback_langs = [];\n\nmodule.exports = {\n getLangs: getLangs,\n initializeLanguageSwitcher: initializeLanguageSwitcher,\n supported_languages: supported_languages,\n browser_languages: browser_languages,\n current_lang: current_lang,\n switchToLang: switchToLang,\n selectAllowedLang: selectAllowedLang\n}\n"]}