diff --git a/js/Dataloader/Dataloader.js b/js/Dataloader/Dataloader.js index 62b65d3..193a539 100644 --- a/js/Dataloader/Dataloader.js +++ b/js/Dataloader/Dataloader.js @@ -29,13 +29,16 @@ function Dataloader(parent) { this.dataLoader = this; - + this.parent = parent; this.options = parent.options; this.initialize(); } +var addToProxysWhitelistMessage1 = "Could not load data!\n\nPlease check your URL <"; +var addToProxysWhitelistMessage2 = "> and CSV or KML file content. If the URL is correct, and the file is a non-empty Geo-Browser CSV or KML data file, our proxy may prevent the file from loading. In that case please send us an email, we gladly add your host to the proxy's white list."; + Dataloader.prototype = { show : function() { @@ -56,17 +59,17 @@ Dataloader.prototype = { this.addLocalKMLLoader(); this.addLocalCSVLoader(); this.addLocalXLSXLoader(); - - // trigger change event on the select so + + // trigger change event on the select so // that only the first loader div will be shown $(this.parent.gui.loaderTypeSelect).change(); }, - + getFileName : function(url) { var fileName = $.url(url).attr('file'); if ( (typeof fileName === "undefined") || (fileName.length === 0) ){ fileName = $.url(url).attr('path'); - //startsWith and endsWith defined in SIMILE Ajax (string.js) + //startsWith and endsWith defined in SIMILE Ajax (string.js) while (fileName.endsWith("/")){ fileName = fileName.substr(0,fileName.length-1); } @@ -77,25 +80,25 @@ Dataloader.prototype = { } return fileName; }, - + distributeDataset : function(dataSet) { GeoTemConfig.addDataset(dataSet); }, - + distributeDatasets : function(datasets) { GeoTemConfig.addDatasets(datasets); }, - + addStaticLoader : function() { if (this.options.staticKML.length > 0){ - $(this.parent.gui.loaderTypeSelect).append(""); - + $(this.parent.gui.loaderTypeSelect).append(""); + this.StaticLoaderTab = document.createElement("div"); $(this.StaticLoaderTab).attr("id","StaticLoader"); - + this.staticKMLList = document.createElement("select"); $(this.StaticLoaderTab).append(this.staticKMLList); - + var staticKMLList = this.staticKMLList; var isFirstHeader = true; $(this.options.staticKML).each(function(){ @@ -113,7 +116,7 @@ Dataloader.prototype = { //close last optgroup (if there were any) if (!isFirstHeader) $(staticKMLList).append(""); - + this.loadStaticKMLButton = document.createElement("button"); $(this.loadStaticKMLButton).text("load"); $(this.loadStaticKMLButton).addClass(GeoTemConfig.buttonCssClass); @@ -130,76 +133,74 @@ Dataloader.prototype = { var kml = GeoTemConfig.getKml(kmlURL); if ((typeof kml !== "undefined") && (kml != null)) { var dataSet = new Dataset(GeoTemConfig.loadKml(kml), fileName, origURL); - + if (dataSet != null) this.distributeDataset(dataSet); } else - alert("Could not load file."); + alert("Could not load file!\n\nData type seems not to be KML!"); },this)); $(this.parent.gui.loaders).append(this.StaticLoaderTab); } }, - + addKMLLoader : function() { - $(this.parent.gui.loaderTypeSelect).append(""); - + $(this.parent.gui.loaderTypeSelect).append(""); + this.KMLLoaderTab = document.createElement("div"); $(this.KMLLoaderTab).attr("id","KMLLoader"); - + this.kmlURL = document.createElement("input"); $(this.kmlURL).attr("type","text"); $(this.KMLLoaderTab).append(this.kmlURL); - + this.loadKMLButton = document.createElement("button"); $(this.loadKMLButton).text("load KML"); $(this.KMLLoaderTab).append(this.loadKMLButton); - + $(this.loadKMLButton).click($.proxy(function(){ var kmlURL = $(this.kmlURL).val(); - + if (kmlURL.length === 0) return; var origURL = kmlURL; var fileName = this.getFileName(kmlURL); - + if (typeof GeoTemConfig.proxy != 'undefined') { - kmlURL = GeoTemConfig.proxy + kmlURL; + kmlURL = GeoTemConfig.proxy + kmlURL; } - + var kml = GeoTemConfig.getKml(kmlURL); if ((typeof kml !== "undefined") && (kml != null)) { var dataSet = new Dataset(GeoTemConfig.loadKml(kml), fileName, origURL); - + if (dataSet != null) this.distributeDataset(dataSet); } else - alert("Could not load file. Please check your URL. If the URL is correct, our " + - "proxy may prevent the file from loading. In that case please send us an email, " + - "and we gladly add your host to the white list."); + alert(addToProxysWhitelistMessage1 + kmlURL + addToProxysWhitelistMessage2); },this)); - + $(this.parent.gui.loaders).append(this.KMLLoaderTab); }, - + addKMZLoader : function() { - $(this.parent.gui.loaderTypeSelect).append(""); - + $(this.parent.gui.loaderTypeSelect).append(""); + this.KMZLoaderTab = document.createElement("div"); $(this.KMZLoaderTab).attr("id","KMZLoader"); - + this.kmzURL = document.createElement("input"); $(this.kmzURL).attr("type","text"); $(this.KMZLoaderTab).append(this.kmzURL); - + this.loadKMZButton = document.createElement("button"); $(this.loadKMZButton).text("load KMZ"); $(this.KMZLoaderTab).append(this.loadKMZButton); $(this.loadKMZButton).click($.proxy(function(){ - + var dataLoader = this; - + var kmzURL = $(this.kmzURL).val(); if (kmzURL.length === 0) return; @@ -207,11 +208,11 @@ Dataloader.prototype = { var fileName = dataLoader.getFileName(kmzURL); if (typeof GeoTemConfig.proxy != 'undefined') kmzURL = GeoTemConfig.proxy + kmzURL; - + GeoTemConfig.getKmz(kmzURL, function(kmlArray){ $(kmlArray).each(function(){ var dataSet = new Dataset(GeoTemConfig.loadKml(this), fileName, origURL); - + if (dataSet != null) dataLoader.distributeDataset(dataSet); }); @@ -220,57 +221,53 @@ Dataloader.prototype = { $(this.parent.gui.loaders).append(this.KMZLoaderTab); }, - + addCSVLoader : function() { - $(this.parent.gui.loaderTypeSelect).append(""); - + $(this.parent.gui.loaderTypeSelect).append(""); + this.CSVLoaderTab = document.createElement("div"); $(this.CSVLoaderTab).attr("id","CSVLoader"); - + this.csvURL = document.createElement("input"); $(this.csvURL).attr("type","text"); $(this.CSVLoaderTab).append(this.csvURL); - + this.loadCSVButton = document.createElement("button"); $(this.loadCSVButton).text("load CSV"); $(this.CSVLoaderTab).append(this.loadCSVButton); $(this.loadCSVButton).click($.proxy(function(){ var dataLoader = this; - + var csvURL = $(this.csvURL).val(); if (csvURL.length === 0) return; var origURL = csvURL; var fileName = dataLoader.getFileName(csvURL); - if (typeof GeoTemConfig.proxy != 'undefined') - csvURL = GeoTemConfig.proxy + csvURL; + // Choose proxy or direct access in GeoTemConfig.getCSV(). GeoTemConfig.getCsv(csvURL, function(json){ if ((typeof json !== "undefined") && (json.length > 0)) { var dataSet = new Dataset(GeoTemConfig.loadJson(json), fileName, origURL); - if (dataSet != null) dataLoader.distributeDataset(dataSet); } else - alert("Could not load file. Please check your URL. If the URL is correct, our " + - "proxy may prevent the file from loading. In that case please send us an email, " + - "and we gladly add your host to the white list."); + alert(addToProxysWhitelistMessage1 + csvURL + addToProxysWhitelistMessage2); }); },this)); $(this.parent.gui.loaders).append(this.CSVLoaderTab); - }, - + }, + addLocalKMLLoader : function() { - $(this.parent.gui.loaderTypeSelect).append(""); - + $(this.parent.gui.loaderTypeSelect).append(""); + this.localKMLLoaderTab = document.createElement("div"); $(this.localKMLLoaderTab).attr("id","LocalKMLLoader"); - + this.kmlFile = document.createElement("input"); $(this.kmlFile).attr("type","file"); $(this.localKMLLoaderTab).append(this.kmlFile); - + this.loadLocalKMLButton = document.createElement("button"); $(this.loadLocalKMLButton).text("load KML"); $(this.localKMLLoaderTab).append(this.loadLocalKMLButton); @@ -281,7 +278,7 @@ Dataloader.prototype = { var file = filelist[0]; var fileName = file.name; var reader = new FileReader(); - + reader.onloadend = ($.proxy(function(theFile) { return function(e) { var dataSet = new Dataset(GeoTemConfig.loadKml($.parseXML(reader.result)), fileName); @@ -296,17 +293,17 @@ Dataloader.prototype = { $(this.parent.gui.loaders).append(this.localKMLLoaderTab); }, - + addLocalCSVLoader : function() { - $(this.parent.gui.loaderTypeSelect).append(""); - + $(this.parent.gui.loaderTypeSelect).append(""); + this.localCSVLoaderTab = document.createElement("div"); $(this.localCSVLoaderTab).attr("id","LocalCSVLoader"); - + this.csvFile = document.createElement("input"); $(this.csvFile).attr("type","file"); $(this.localCSVLoaderTab).append(this.csvFile); - + this.loadLocalCSVButton = document.createElement("button"); $(this.loadLocalCSVButton).text("load CSV"); $(this.localCSVLoaderTab).append(this.loadLocalCSVButton); @@ -317,13 +314,13 @@ Dataloader.prototype = { var file = filelist[0]; var fileName = file.name; var reader = new FileReader(); - + reader.onloadend = ($.proxy(function(theFile) { return function(e) { var json = GeoTemConfig.convertCsv(reader.result); var dataSet = new Dataset(GeoTemConfig.loadJson(json), fileName); if (dataSet != null) - this.distributeDataset(dataSet); + this.distributeDataset(dataSet); }; }(file),this)); @@ -333,12 +330,12 @@ Dataloader.prototype = { $(this.parent.gui.loaders).append(this.localCSVLoaderTab); }, - + addLocalStorageLoader : function() { var dataLoader = this; this.localStorageLoaderTab = document.createElement("div"); $(this.localStorageLoaderTab).attr("id","LocalStorageLoader"); - + var localDatasets = document.createElement("select"); $(this.localStorageLoaderTab).append(localDatasets); @@ -353,7 +350,7 @@ Dataloader.prototype = { $(localDatasets).append(""); } } - + //only show if there are datasets if (localStorageDatasetCount > 0) $(this.parent.gui.loaderTypeSelect).append(""); @@ -378,7 +375,7 @@ Dataloader.prototype = { $(this.parent.gui.loaders).append(this.localStorageLoaderTab); }, - + addLocalXLSXLoader : function() { //taken from http://oss.sheetjs.com/js-xlsx/ var fixdata = function(data) { @@ -387,16 +384,16 @@ Dataloader.prototype = { o+=String.fromCharCode.apply(null, new Uint8Array(data.slice(o.length))); return o; } - - $(this.parent.gui.loaderTypeSelect).append(""); - + + $(this.parent.gui.loaderTypeSelect).append(""); + this.LocalXLSXLoader = document.createElement("div"); $(this.LocalXLSXLoader).attr("id","LocalXLSXLoader"); - + this.xlsxFile = document.createElement("input"); $(this.xlsxFile).attr("type","file"); $(this.LocalXLSXLoader).append(this.xlsxFile); - + this.loadLocalXLSXButton = document.createElement("button"); $(this.loadLocalXLSXButton).text("load XLS/XLSX"); $(this.LocalXLSXLoader).append(this.loadLocalXLSXButton); @@ -407,7 +404,7 @@ Dataloader.prototype = { var file = filelist[0]; var fileName = file.name; var reader = new FileReader(); - + reader.onloadend = ($.proxy(function(theFile) { return function(e) { var workbook; @@ -421,10 +418,10 @@ Dataloader.prototype = { var csv = XLS.utils.sheet_to_csv(workbook.Sheets[workbook.SheetNames[0]]); var json = GeoTemConfig.convertCsv(csv); } - + var dataSet = new Dataset(GeoTemConfig.loadJson(json), fileName); if (dataSet != null) - this.distributeDataset(dataSet); + this.distributeDataset(dataSet); }; }(file),this)); diff --git a/js/Dataloader/DataloaderConfig.js b/js/Dataloader/DataloaderConfig.js index 0f550ba..f4ef9ad 100644 --- a/js/Dataloader/DataloaderConfig.js +++ b/js/Dataloader/DataloaderConfig.js @@ -84,7 +84,7 @@ function DataloaderConfig(options) { url: dl +"data/flickr/U2.kml" }, { - label: "Muse", + label: "Muse", url: dl +"data/flickr/Muse.kml" }, { header: "Political Data" }, diff --git a/js/Dataloader/DataloaderWidget.js b/js/Dataloader/DataloaderWidget.js index 038b61a..81cca6c 100644 --- a/js/Dataloader/DataloaderWidget.js +++ b/js/Dataloader/DataloaderWidget.js @@ -35,9 +35,9 @@ DataloaderWidget = function(core, div, options) { this.options = (new DataloaderConfig(options)).options; this.gui = new DataloaderGui(this, div, this.options); - + this.dataLoader = new Dataloader(this); - + this.datasets = []; } @@ -80,7 +80,7 @@ DataloaderWidget.prototype = { reset : function() { }, - + loadRenames : function(){ //load (optional!) attribute renames //each rename param is {latitude:..,longitude:..,place:..,date:..,timeSpanBegin:..,timeSpanEnd:..} @@ -103,15 +103,15 @@ DataloaderWidget.prototype = { if (typeof dataset === "undefined") return; - + var renameFunc = function(index,latAttr,lonAttr,placeAttr,dateAttr,timespanBeginAttr, timespanEndAttr,indexAttr){ var renameArray = []; - + if (typeof index === "undefined"){ index = 0; } - + if ((typeof latAttr !== "undefined") && (typeof lonAttr !== "undefined")){ renameArray.push({ oldColumn:latAttr, @@ -122,7 +122,7 @@ DataloaderWidget.prototype = { newColumn:"locations["+index+"].longitude" }); } - + if (typeof placeAttr !== "undefined"){ renameArray.push({ oldColumn:placeAttr, @@ -137,7 +137,7 @@ DataloaderWidget.prototype = { }); } - if ((typeof timespanBeginAttr !== "undefined") && + if ((typeof timespanBeginAttr !== "undefined") && (typeof timespanEndAttr !== "undefined")){ renameArray.push({ oldColumn:timespanBeginAttr, @@ -155,10 +155,10 @@ DataloaderWidget.prototype = { newColumn:"index" }); } - + GeoTemConfig.renameColumns(dataset,renameArray); }; - + var renames = JSON.parse(paramValue); if (renames instanceof Array){ @@ -173,7 +173,7 @@ DataloaderWidget.prototype = { } }); }, - + loadFilters : function(){ //load (optional!) filters //those will create a new(!) dataset, that only contains the filtered IDs @@ -191,10 +191,10 @@ DataloaderWidget.prototype = { } } dataset = datasets[datasetID]; - + if (typeof dataset === "undefined") return; - + var filterValues = function(paramValue){ var filter = JSON.parse(paramValue); var filteredObjects = []; @@ -207,7 +207,7 @@ DataloaderWidget.prototype = { var filteredDataset = new Dataset(filteredObjects, dataset.label + " (filtered)", dataset.url, dataset.type); datasets.push(filteredDataset); } - + if (paramValue instanceof Array){ for (var i=0; i < paramValue.length; i++){ filterValues(paramValue[i]); @@ -217,9 +217,9 @@ DataloaderWidget.prototype = { } } - }); + }); }, - + loadColors : function(){ //Load the (optional!) dataset colors var dataLoaderWidget = this; @@ -234,21 +234,21 @@ DataloaderWidget.prototype = { var colorsSelectedUnselected = paramValue.split(","); if (colorsSelectedUnselected.length > 2) return; - + var color1 = colorsSelectedUnselected[0]; if (color1.length != 6) return; - + color.r1 = parseInt(color1.substr(0,2),16); color.g1 = parseInt(color1.substr(2,2),16); color.b1 = parseInt(color1.substr(4,2),16); - + //check if a unselected color is given if (colorsSelectedUnselected.length == 2){ var color0 = colorsSelectedUnselected[1]; if (color0.length != 6) return; - + color.r0 = parseInt(color0.substr(0,2),16); color.g0 = parseInt(color0.substr(2,2),16); color.b0 = parseInt(color0.substr(4,2),16); @@ -258,14 +258,14 @@ DataloaderWidget.prototype = { color.g0 = Math.round(color.g1/2); color.b0 = Math.round(color.b1/2); } - + datasets[datasetID].color = color; - } + } } - } - }); + } + }); }, - + loadFromURL : function() { var dataLoaderWidget = this; dataLoaderWidget.datasets = []; @@ -276,9 +276,9 @@ DataloaderWidget.prototype = { $.each(parametersHash,function(paramName, paramValue){ parametersArray.push({paramName:paramName, paramValue:paramValue}); }); - + var parseParam = function(paramNr){ - + if (paramNr==parametersArray.length){ dataLoaderWidget.loadRenames(); dataLoaderWidget.loadFilters(); @@ -295,31 +295,33 @@ DataloaderWidget.prototype = { } } datasets = tempDatasets; - + if (datasets.length > 0){ dataLoaderWidget.dataLoader.distributeDatasets(datasets); } return; } - + var paramName = parametersArray[paramNr].paramName; var paramValue = parametersArray[paramNr].paramValue; - var datasetID = parseInt(paramName.replace(/\D/g,'')); - + //startsWith and endsWith defined in SIMILE Ajax (string.js) var fileName = dataLoaderWidget.dataLoader.getFileName(paramValue); var origURL = paramValue; - if (typeof GeoTemConfig.proxy != 'undefined') - paramValue = GeoTemConfig.proxy + paramValue; if (paramName.toLowerCase().startsWith("kml")){ + // Add proxy to KML data URL. + // FIXME Use direct download for KML files, too! + if (typeof GeoTemConfig.proxy != 'undefined') { + paramValue = GeoTemConfig.proxy + paramValue; + } GeoTemConfig.getKml(paramValue, function(kmlDoc){ - var dataSet = new Dataset(GeoTemConfig.loadKml(kmlDoc), fileName, origURL); + var dataSet = new Dataset(GeoTemConfig.loadKml(kmlDoc), fileName, origURL, "kml"); if (dataSet != null){ if (!isNaN(datasetID)){ datasets[datasetID] = dataSet; } else { - datasets.push(dataSet); + datasets.push(dataSet); } } setTimeout(function(){parseParam(paramNr+1)},1); @@ -327,25 +329,25 @@ DataloaderWidget.prototype = { } else if (paramName.toLowerCase().startsWith("csv")){ GeoTemConfig.getCsv(paramValue,function(json){ - var dataSet = new Dataset(GeoTemConfig.loadJson(json), fileName, origURL); + var dataSet = new Dataset(GeoTemConfig.loadJson(json), fileName, origURL, "csv"); if (dataSet != null){ if (!isNaN(datasetID)){ datasets[datasetID] = dataSet; } else { - datasets.push(dataSet); + datasets.push(dataSet); } } setTimeout(function(){parseParam(paramNr+1)},1); }); } else if (paramName.toLowerCase().startsWith("json")){ - GeoTemConfig.getJson(paramValue,function(json ){ - var dataSet = new Dataset(GeoTemConfig.loadJson(json), fileName, origURL); + GeoTemConfig.getJson(paramValue,function(json){ + var dataSet = new Dataset(GeoTemConfig.loadJson(json), fileName, origURL, "json"); if (dataSet != null){ if (!isNaN(datasetID)){ datasets[datasetID] = dataSet; } else { - datasets.push(dataSet); + datasets.push(dataSet); } } setTimeout(function(){parseParam(paramNr+1)},1); @@ -362,7 +364,7 @@ DataloaderWidget.prototype = { if (!isNaN(datasetID)){ datasets[datasetID] = dataSet; } else { - datasets.push(dataSet); + datasets.push(dataSet); } } setTimeout(function(){parseParam(paramNr+1)},1); @@ -373,25 +375,26 @@ DataloaderWidget.prototype = { for(var i = 0; i != data.length; ++i){ arr[i] = String.fromCharCode(data[i]); } - + var workbook; var json; if (paramName.toLowerCase().startsWith("xlsx")){ workbook = XLSX.read(arr.join(""), {type:"binary"}); var csv = XLSX.utils.sheet_to_csv(workbook.Sheets[workbook.SheetNames[0]]); var json = GeoTemConfig.convertCsv(csv); - } else { + var dataSet = new Dataset(GeoTemConfig.loadJson(json), fileName, origURL, "xlsx"); + } else { workbook = XLS.read(arr.join(""), {type:"binary"}); var csv = XLS.utils.sheet_to_csv(workbook.Sheets[workbook.SheetNames[0]]); var json = GeoTemConfig.convertCsv(csv); + var dataSet = new Dataset(GeoTemConfig.loadJson(json), fileName, origURL, "xls"); } - - var dataSet = new Dataset(GeoTemConfig.loadJson(json), fileName, origURL); + if (dataSet != null){ if (!isNaN(datasetID)){ datasets[datasetID] = dataSet; } else { - datasets.push(dataSet); + datasets.push(dataSet); } } setTimeout(function(){parseParam(paramNr+1)},1); @@ -400,7 +403,7 @@ DataloaderWidget.prototype = { setTimeout(function(){parseParam(paramNr+1)},1); } }; - + if (parametersArray.length>0){ parseParam(0) } diff --git a/js/FuzzyTimeline/FuzzyTimelineRangeSlider.js b/js/FuzzyTimeline/FuzzyTimelineRangeSlider.js index 5fc3bb0..b1a0af3 100644 --- a/js/FuzzyTimeline/FuzzyTimelineRangeSlider.js +++ b/js/FuzzyTimeline/FuzzyTimelineRangeSlider.js @@ -29,27 +29,27 @@ function FuzzyTimelineRangeSlider(parent) { var rangeSlider = this; - + this.parent = parent; this.options = parent.options; - + this.spans; - + this.datasets; - + this.sliderParentTable = this.parent.gui.sliderTable; var headerRow = $(""); var controlsRow = $(""); $(this.sliderParentTable).append(headerRow).append(controlsRow); - + headerRow.append("Time start"); this.rangeStart = document.createElement("select"); controlsRow.append($("").append(this.rangeStart)); - + headerRow.append("Time unit"); this.rangeDropdown = document.createElement("select"); controlsRow.append($("").append(this.rangeDropdown)); - + headerRow.append("Scaling"); this.scalingDropdown = document.createElement("select"); controlsRow.append($("").append(this.scalingDropdown)); @@ -67,8 +67,8 @@ function FuzzyTimelineRangeSlider(parent) { this.pauseAnimation = document.createElement("div"); $(this.pauseAnimation).addClass("smallButton pauseDisabled"); controlsRow.append($("").append(this.startAnimation).append(this.pauseAnimation)); - - headerRow.append("Dated Objects"); + + headerRow.append("Dated objects"); this.numberDatedObjects = 0; this.numberDatedObjectsDIV = document.createElement("div"); $(this.numberDatedObjectsDIV).addClass("ddbElementsCount"); @@ -105,10 +105,10 @@ FuzzyTimelineRangeSlider.prototype = { if ((typeof smallestSpan !== 'undefined') && (smallestSpan.asMilliseconds() === 1)) return false; }); - + //show number of objects that have a time in header $(rangeSlider.numberDatedObjectsDIV).empty().append(rangeSlider.numberDatedObjects + " results"); - + if (typeof smallestSpan === 'undefined') return; @@ -158,9 +158,9 @@ FuzzyTimelineRangeSlider.prototype = { )) rangeSlider.spans.push(fixedSpans[i]); } - + $(rangeSlider.rangeDropdown).empty(); - + $(rangeSlider.rangeDropdown).append(""); var index = 0; $(rangeSlider.spans).each(function(){ @@ -196,16 +196,16 @@ FuzzyTimelineRangeSlider.prototype = { $(rangeSlider.rangeDropdown).change(function( eventObject ){ var handlePosition = $(rangeSlider.rangeDropdown).find("option:selected").first().attr("index"); //if there is no index, "continuous" is selected - so the density plot will be drawn - + if (typeof handlePosition === "undefined"){ rangeSlider.parent.switchViewMode("density"); } else { rangeSlider.parent.switchViewMode("barchart"); } - + rangeSlider.parent.slidePositionChanged(rangeSlider.spans[handlePosition]); }); - + $(rangeSlider.rangeStart).empty(); //add start of timeline selections //TODO: add Months/Days/etc., atm there are only years @@ -225,24 +225,24 @@ FuzzyTimelineRangeSlider.prototype = { last = date; } $(starts).each(function(){ - $(rangeSlider.rangeStart).append(""); + $(rangeSlider.rangeStart).append(""); }); $(rangeSlider.rangeStart).change(function( eventObject ){ var handlePosition = rangeSlider.rangeStart.selectedIndex; var start = starts[handlePosition]; - + rangeSlider.parent.overallMin = moment().year(start); $(rangeSlider.rangeDropdown).change(); }); $(rangeSlider.rangeDropdown).change(); - + $(rangeSlider.startAnimation).click(function(){ if ($(rangeSlider.startAnimation).hasClass("playEnabled")){ $(rangeSlider.startAnimation).removeClass("playEnabled").addClass("playDisabled"); $(rangeSlider.pauseAnimation).removeClass("pauseDisabled").addClass("pauseEnabled"); - + rangeSlider.parent.startAnimation(); } }); @@ -252,12 +252,12 @@ FuzzyTimelineRangeSlider.prototype = { if ($(rangeSlider.pauseAnimation).hasClass("pauseEnabled")){ $(rangeSlider.startAnimation).removeClass("playDisabled").addClass("playEnabled"); $(rangeSlider.pauseAnimation).removeClass("pauseEnabled").addClass("pauseDisabled"); - + rangeSlider.parent.pauseAnimation(); } }); }, - + triggerHighlight : function(columnElement) { }, @@ -280,8 +280,8 @@ FuzzyTimelineRangeSlider.prototype = { reset : function() { }, - - show : function() { + + show : function() { }, hide : function() { diff --git a/js/GeoTemConfig.js b/js/GeoTemConfig.js index eb6c9ae..779b8fb 100644 --- a/js/GeoTemConfig.js +++ b/js/GeoTemConfig.js @@ -28,7 +28,6 @@ * @version date: 2012-07-27 */ - // credits: user76888, The Digital Gabeg (http://stackoverflow.com/questions/1539367) $.fn.cleanWhitespace = function() { textNodes = this.contents().filter( function() { @@ -37,6 +36,9 @@ $.fn.cleanWhitespace = function() { return this; }; +/* + * Configuration + */ GeoTemConfig = { debug : false, //show debug output (esp. regarding corrupt datasets) incompleteData : true, // show/hide data with either temporal or spatial metadata @@ -49,12 +51,18 @@ GeoTemConfig = { tableExportDataset : true, // export dataset to KML allowCustomColoring : false, // if DataObjects can have an own color (useful for weighted coloring) allowUserShapeAndColorChange: false, // if the user can change the shapes and color of datasets - // this turns MapConfig.useGraphics auto-on, but uses circles as default + // this turns MapConfig.useGraphics auto-on, but uses circles as + // default loadColorFromDataset : false, // if DataObject color should be loaded automatically (from column "color") allowColumnRenaming : true, - proxy : 'php/proxy.php?address=', //set this if a HTTP proxy shall be used (e.g. to bypass X-Domain problems) + proxy : '/php/proxy.php?address=', // set this if a HTTP proxy shall be used (e.g. to bypass + // X-Domain problems) + dariahOwnStorageURL : 'https://cdstar.de.dariah.eu/dariah/', // URL of DARIAH-DE OwnStorage + datasheetEditorURL : '/edit/index.html', // URL of the Datasheet Editor + dariahOwnStorageBearerPrefix : 'bearer ', + dariahOwnStorageLogIDPrefix : 'GEOBRO_', //colors for several datasets; rgb1 will be used for selected objects, rgb0 for unselected - colors : [{ + colors : [{ r1 : 255, g1 : 101, b1 : 0, @@ -212,6 +220,9 @@ if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { } } +/* + * + */ GeoTemConfig.getIndependentId = function(target){ if( target == 'map' ){ return ++GeoTemConfig.independentMapId; @@ -222,6 +233,9 @@ GeoTemConfig.getIndependentId = function(target){ return 0; }; +/* + * + */ GeoTemConfig.setHexColor = function(hex,index,fill){ var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); if( fill ){ @@ -236,6 +250,9 @@ GeoTemConfig.setHexColor = function(hex,index,fill){ } } +/* + * + */ GeoTemConfig.setRgbColor = function(r,g,b,index,fill){ if( fill ){ GeoTemConfig.colors[index].r0 = r; @@ -249,16 +266,24 @@ GeoTemConfig.setRgbColor = function(r,g,b,index,fill){ } } +/* + * + */ GeoTemConfig.configure = function(urlPrefix) { GeoTemConfig.urlPrefix = urlPrefix; GeoTemConfig.path = GeoTemConfig.urlPrefix + "images/"; } +/* + * + */ GeoTemConfig.applySettings = function(settings) { $.extend(this, settings); }; -//Keeps track of how many colors where assigned yet. +/* + * Keeps track of how many colors where assigned yet. + */ GeoTemConfig.assignedColorCount = 0; GeoTemConfig.getColor = function(id){ if (typeof GeoTemConfig.datasets[id].color === "undefined"){ @@ -311,6 +336,9 @@ GeoTemConfig.getColor = function(id){ return GeoTemConfig.datasets[id].color; }; +/* + * + */ GeoTemConfig.getAverageDatasetColor = function(id, objects){ var c = new Object(); var datasetColor = GeoTemConfig.getColor(id); @@ -360,12 +388,16 @@ GeoTemConfig.getAverageDatasetColor = function(id, objects){ return c; }; +/* + * + */ GeoTemConfig.getString = function(field) { if ( typeof Tooltips[GeoTemConfig.language] == 'undefined') { GeoTemConfig.language = 'en'; } return Tooltips[GeoTemConfig.language][field]; } + /** * returns the actual mouse position * @param {Event} e the mouseevent @@ -381,6 +413,7 @@ GeoTemConfig.getMousePosition = function(e) { left : e.pageX ? e.pageX : e.clientX }; } + /** * returns the json object of the file from the given url * @param {String} url the url of the file to load @@ -410,6 +443,9 @@ GeoTemConfig.getJson = function(url,asyncFunc) { } } +/* + * + */ GeoTemConfig.mergeObjects = function(set1, set2) { var inside = []; var newSet = []; @@ -433,20 +469,20 @@ GeoTemConfig.mergeObjects = function(set1, set2) { return newSet; }; +/* + * + */ GeoTemConfig.datasets = []; - GeoTemConfig.addDataset = function(newDataset){ GeoTemConfig.datasets.push(newDataset); Publisher.Publish('filterData', GeoTemConfig.datasets, null); }; - GeoTemConfig.addDatasets = function(newDatasets){ $(newDatasets).each(function(){ GeoTemConfig.datasets.push(this); }); Publisher.Publish('filterData', GeoTemConfig.datasets, null); }; - GeoTemConfig.removeDataset = function(index){ GeoTemConfig.datasets.splice(index,1); Publisher.Publish('filterData', GeoTemConfig.datasets, null); @@ -455,18 +491,26 @@ GeoTemConfig.removeDataset = function(index){ /** * converts the csv-file into json-format * - * @param {String} - * text + * @param {String} text Text to convert. */ GeoTemConfig.convertCsv = function(text){ + +// console.log("text --> ", text); + /* convert here from CSV to JSON */ var json = []; /* define expected csv table headers (first line) */ var expectedHeaders = new Array("Name","Address","Description","Longitude","Latitude","TimeStamp","TimeSpan:begin","TimeSpan:end","weight"); /* convert csv string to array of arrays using ucsv library */ var csvArray = CSV.csvToArray(text); + +// console.log("array --> ", csvArray); + /* get real used table headers from csv file (first line) */ var usedHeaders = csvArray[0]; + +// console.log("usedHeaders --> ", usedHeaders); + /* loop outer array, begin with second line */ for (var i = 1; i < csvArray.length; i++) { var innerArray = csvArray[i]; @@ -483,7 +527,6 @@ GeoTemConfig.convertCsv = function(text){ hasContent = true; } } - if (hasContent === true) break; } @@ -539,10 +582,13 @@ GeoTemConfig.convertCsv = function(text){ } dataObject["tableContent"] = tableContent; - json.push(dataObject); } +// console.log("json --> ", json); + + // TODO We should devide three cases here for not displaying the data: (i) proxy could not load file, (ii) file is empty or invalid and non-interpretable Geo-Browser CSV data, and (iii) file is a Geo-Browser CSV file (at least some of the expectedHeaders existing) and no content!! + return json; }; @@ -617,34 +663,49 @@ GeoTemConfig.getKmz = function(url,asyncFunc) { }; /** - * returns the JSON "object" - * from the csv file from the given url - * @param {String} url the url of the file to load + * Loads the CSV file from the given URL and converts it to KML. + * + * @param {String} url The url of the file to load. + * @param {boolean} asyncFunc Method to call if using async data loading. * @return xml dom object of given file */ -GeoTemConfig.getCsv = function(url,asyncFunc) { - var async = false; - if( asyncFunc ){ - async = true; - } - - //use XMLHttpRequest as synchronous behaviour - //is not supported in jQuery native $.get - var req = new XMLHttpRequest(); - req.open("GET",url,async); - //can only be set on asynchronous now - //req.responseType = "text"; - var json; - req.onload = function() { - json = GeoTemConfig.convertCsv(req.response); - if( asyncFunc ) - asyncFunc(json); - }; - req.send(); - - if( !async ){ - return json; - } +GeoTemConfig.getCsv = function(url, asyncFunc) { + + // For DARIAH-DE OwnStorage do load data directly... + if (url.includes(GeoTemConfig.dariahOwnStorageURL)) { + GeoTemConfig.loadFromDariahStorage(url, asyncFunc); + } + + // ...handle proxy requests otherwise. + else { + + // Check proxy setting and add proxy URL. + if (typeof GeoTemConfig.proxy != 'undefined') { + url = GeoTemConfig.proxy + url; + } + + var async = false; + if(asyncFunc) { + async = true; + } + + // Use XMLHttpRequest as synchronous behaviour (is not supported in jQuery native $.get) + var req = new XMLHttpRequest(); + req.open("GET", url, async); + + // Can only be set on asynchronous now + var json; + req.onload = function() { + json = GeoTemConfig.convertCsv(req.response); + if (asyncFunc) { + asyncFunc(json); + } + }; + req.send(); + if(!async) { + return json; + } + } }; /** @@ -1204,6 +1265,7 @@ GeoTemConfig.createCSVfromDataset = function(index){ } csvContent += "\""; }); + return(csvContent); }; /** @@ -1360,4 +1422,69 @@ GeoTemConfig.renameColumns = function(dataset, renames){ //set index dataset.objects[i].setIndex(index); } +} + +/** + * Load file from DARIAH-DE OwnStorage. + */ +GeoTemConfig.loadFromDariahStorage = function(url, asyncFunc) { + // Assemble bearer token and logID. + var token = GeoTemConfig.dariahOwnStorageBearerPrefix + sessionStorage.getItem('tok'); + var logID = GeoTemConfig.dariahOwnStorageLogIDPrefix + (new Date()).getMilliseconds(); + $.ajax({ + url: url, + type: 'GET', + headers: { 'Authorization': token, 'X-Transaction-ID': logID }, + success: function(data) { + var json = GeoTemConfig.convertCsv(data); + asyncFunc(json); + }, + error: function(xhr, textStatus, errorThrown) { + // Have we got a token already? If not, tell the user to authenticate first! + if (sessionStorage.getItem('tok') === null) { + var title = 'Error loading dataset: ' + xhr.status + ' ' + errorThrown + '!'; + var message = 'The dataset with URL ' + url + ' could not be loaded from the DARIAH-DE Storage! It seems the above resource is not yours or not shared yet! Please do login to view your dataset or share it in the Datasheet Editor!'; + alert(title + "\n\n" + message); + } + // If a token does exist and no read access is granted, just give the correct error. + else { + var title = 'Error loading dataset: ' + xhr.status + ' ' + errorThrown + '!'; + var message = 'The dataset with URL ' + url + ' could not be loaded from the DARIAH-DE Storage! It seems the above resource is not publicly available!'; + alert(title + "\n\n" + message); + } + } + }); }; + +/* + * Store file to DARIAH-DE OwnStorage. + */ +GeoTemConfig.storeToDariahStorage = function(postdata, asyncFunc) { + // Assemble bearer token and logID. + var token = GeoTemConfig.dariahOwnStorageBearerPrefix + sessionStorage.getItem('tok'); + var logID = GeoTemConfig.dariahOwnStorageLogIDPrefix + (new Date()).getMilliseconds(); + $.ajax({ + url: GeoTemConfig.dariahOwnStorageURL, + type: 'POST', + headers: { 'Authorization': token, 'X-Transaction-ID': logID }, + contentType: 'text/csv', + data: postdata, + success: function(data, status, xhr) { + var location = xhr.getResponseHeader('Location'); + var id = location.substring(location.lastIndexOf('/') + 1); + // Prevent getting false locations from storage, such as http instead of https and or productive locations from test storage... therefore set new dataset location. + var newLocation = GeoTemConfig.dariahOwnStorageURL + id; + asyncFunc(newLocation, id); + var title = 'Dataset has been stored to DARIAH-DE Storage!'; + var message = 'Your dataset has been successfully stored to the the DARIAH-DE Storage! It has got the ID ' + id + ' and URL: ' + newLocation; + alert(title + "\n\n" + message); + }, + error: function(xhr, textStatus, errorThrown) { + var title = 'Error storing dataset to the DARIAH-DE Storage: ' + xhr.status + ' ' + errorThrown + '!'; + var message = 'The dataset could not be stored to the DARIAH-DE Storage!'; + if (xhr.status == "401") { + message += " Please try logging in first and then re-load your local file. We apologise for the inconvenience!"; + } + alert(title + "\n\n" + message); } + }); +} diff --git a/js/Map/Binning.js b/js/Map/Binning.js index f2680a9..564afc4 100644 --- a/js/Map/Binning.js +++ b/js/Map/Binning.js @@ -746,4 +746,3 @@ Binning.prototype = { } } - diff --git a/js/Map/MapConfig.js b/js/Map/MapConfig.js index 1a7d993..fd34515 100644 --- a/js/Map/MapConfig.js +++ b/js/Map/MapConfig.js @@ -30,7 +30,11 @@ function MapConfig(options) { var gsurl = 'https://ref.de.dariah.eu/geoserver'; - var mpiwgurl = 'http://geoserver.mpiwg-berlin.mpg.de/geoserver'; + + var euroGraphicsAttribution = "© EuroGeographics for the administrative boundaries"; + var mapsForFreeAttribution = "© Maps for Free, released under Creative Commons CC0"; + var dareAttribution = "© Johan Åhlfeldt, Digital Atlas of the Roman Empire (DARE)"; + var thinkQuestAttribution = "© ThinkQuest Team C006628"; this.options = { mapWidth : false, // false or desired width css definition for the map @@ -42,16 +46,28 @@ function MapConfig(options) { name: '-----------------------------------', }, { - name: 'Contemporary map 2014', + name: 'Contemporary map of 2014', url: gsurl + '/eurostat/wms', layer: 'eurostat:CNTR_RG_03M_2014', - attribution: "© EuroGeographics for the administrative boundaries" + attribution: euroGraphicsAttribution }, { - name: 'Contemporary map 2013', + name: 'Contemporary map of 2013', url: gsurl + '/eurostat/wms', layer: 'eurostat:CNTR_RG_03M_2013', - attribution: "© EuroGeographics for the administrative boundaries" + attribution: euroGraphicsAttribution + }, + { + name: 'Contemporary map of 2010', + url: gsurl + '/eurostat/wms', + layer: 'eurostat:CNTR_RG_03M_2010', + attribution: euroGraphicsAttribution + }, + { + name: 'Contemporary map of 2006', + url: gsurl + '/eurostat/wms', + layer: 'eurostat:CNTR_RG_03M_2006 ', + attribution: euroGraphicsAttribution }, { name: '-----------------------------------', @@ -60,182 +76,155 @@ function MapConfig(options) { name: 'Maps-for-Free relief map', url: 'https://maps-for-free.com/layer/relief/z${z}/row${y}/${z}_${x}-${y}.jpg', type:'XYZ', - attribution: "© Maps for Free" + attribution: mapsForFreeAttribution }, { name: 'Digital Atlas of the Roman Empire', url: 'https://dh.gu.se/tiles/imperium/${z}/${x}/${y}.png', type:'XYZ', - attribution: "© Johan Åhlfeldt, Digital Atlas of the Roman Empire (DARE)" + attribution: dareAttribution }, { name: '-----------------------------------', }, - { - name: 'Historical map of 2010', - url: gsurl + '/eurostat/wms', - layer: 'eurostat:CNTR_RG_03M_2010', - attribution: "© EuroGeographics for the administrative boundaries" - }, - { - name: 'Historical map of 2006', - url: gsurl + '/eurostat/wms', - layer: 'eurostat:CNTR_RG_03M_2006 ', - attribution: "© EuroGeographics for the administrative boundaries" - }, { name: 'Historical map of 1994', url: gsurl + '/historic/wms', layer: 'historic:cntry1994', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 1949', url: gsurl + '/historic/wms', layer: 'historic:cntry1949', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 1938', url: gsurl + '/historic/wms', layer: 'historic:cntry1938', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 1920', url: gsurl + '/historic/wms', layer: 'historic:cntry1920', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 1914', url: gsurl + '/historic/wms', layer: 'historic:cntry1914', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 1880', url: gsurl + '/historic/wms', layer: 'historic:cntry1880', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 1815', url: gsurl + '/historic/wms', layer: 'historic:cntry1815', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 1783', url: gsurl + '/historic/wms', layer: 'historic:cntry1783', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 1715', url: gsurl + '/historic/wms', layer: 'historic:cntry1715', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 1650', url: gsurl + '/historic/wms', layer: 'historic:cntry1650', - attribution: "© ThinkQuest Team C006628" - }, + attribution: thinkQuestAttribution + }, { name: 'Historical map of 1530', url: gsurl + '/historic/wms', layer: 'historic:cntry1530', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 1492', url: gsurl + '/historic/wms', layer: 'historic:cntry1492', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 1279', url: gsurl + '/historic/wms', layer: 'historic:cntry1279', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 1000', url: gsurl + '/historic/wms', layer: 'historic:cntry1000', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 800', url: gsurl + '/historic/wms', layer: 'historic:cntry800', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 600', url: gsurl + '/historic/wms', layer: 'historic:cntry600', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 400', url: gsurl + '/historic/wms', layer: 'historic:cntry400', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 1 BC', url: gsurl + '/historic/wms', layer: 'historic:cntry1bc', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 200 BC', url: gsurl + '/historic/wms', layer: 'historic:cntry200bc', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 323 BC', url: gsurl + '/historic/wms', layer: 'historic:cntry323bc', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 500 BC', url: gsurl + '/historic/wms', layer: 'historic:cntry500bc', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 1000 BC', url: gsurl + '/historic/wms', layer: 'historic:cntry1000bc', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, { name: 'Historical map of 2000 BC', url: gsurl + '/historic/wms', layer: 'historic:cntry2000bc', - attribution: "© ThinkQuest Team C006628" + attribution: thinkQuestAttribution }, -// { -// name: '-----------------------------------', -// }, -// { -// name: 'CSHAPE borders 1994-12-15', -// url: mpiwgurl + '/mpiwg/wms', -// layer: 'mpiwg:borders_1994_12_15', -// attribution: "© ++TODO++" -// }, -// { -// name: 'Historical map 1957-03-06', -// url: gsurl + '/mpiwg/wms', -// layer: 'mpiwg:borders_1957_3_6Polygon', -// attribution: "© ++TODO++" -// }, ], legend : true, // if a legend at the bottom of the map should be shown or not mapMerge : false, // if the elements of distinct datasets should be merged into one set or not @@ -263,7 +252,7 @@ function MapConfig(options) { bingApiKey : 'none', // bing maps api key, see informations at http://bingmapsportal.com/ osmMaps : true, // enable/disable OSM maps osmMapsMapQuest : false, // enable/disable OSM maps with MapQuest tiles - baseLayer : 'Open Street Map', // initial layer to show (e.g. 'Google Streets') + baseLayer : 'OpenStreetMap', // initial layer to show (e.g. 'Google Streets') resetMap : true, // show/hide map reset button countrySelect : true, // show/hide map country selection control button polygonSelect : true, // show/hide map polygon selection control button diff --git a/js/Map/MapGui.js b/js/Map/MapGui.js index 9f538d6..2df9474 100644 --- a/js/Map/MapGui.js +++ b/js/Map/MapGui.js @@ -114,7 +114,7 @@ function MapGui(map, div, options, iid) { mapSum.appendChild(this.mapElements); tools.appendChild(mapSum); } - + this.lockTitle = document.createElement("td"); titles.appendChild(this.lockTitle); this.lockIcon = document.createElement("td"); @@ -236,16 +236,12 @@ function MapGui(map, div, options, iid) { this.mapWindow.appendChild(this.legendDiv); } - var linkForOsm = 'http://www.openstreetmap.org/'; - var linkForLicense = 'http://creativecommons.org/licenses/by-sa/2.0/'; this.osmLink = document.createElement("div"); this.osmLink.setAttribute('class', 'osmLink'); - this.osmLink.innerHTML = '(c) OpenStreetMap contributors, CC-BY-SA'; this.mapWindow.appendChild(this.osmLink); - this.osmMapQuestLink = document.createElement("div"); + this.osmMapQuestLink = document.createElement("div"); this.osmMapQuestLink.setAttribute('class', 'osmLink'); - this.osmMapQuestLink.innerHTML = '(c) Data, imagery and map information provided by MapQuest MapQuest OpenStreetMap contributors, CC-BY-SA'; this.mapWindow.appendChild(this.osmMapQuestLink); // var tooltip = document.createElement("div"); @@ -342,7 +338,7 @@ function MapGui(map, div, options, iid) { var stroke = 'rgb(' + c.r1 + ',' + c.g1 + ',' + c.b1 + ')'; var svg = ''; $(''+svg+'').appendTo(row); - } + } $(''+datasets[i].label+'').appendTo(row); } }; diff --git a/js/Map/MapWidget.js b/js/Map/MapWidget.js index c3e54f3..2f5c54f 100644 --- a/js/Map/MapWidget.js +++ b/js/Map/MapWidget.js @@ -541,7 +541,7 @@ MapWidget.prototype = { this.zoomSlider.setMaxAndLevels(1000, this.openlayersMap.getNumZoomLevels()); this.zoomSlider.setValue(this.getZoom()); } - + Publisher.Subscribe('mapChanged', this, function(mapName) { this.client.setBaseLayerByName(mapName); this.client.gui.setMap(); @@ -562,7 +562,7 @@ MapWidget.prototype = { layers[i].name, [ layers[i].url - ], + ], { sphericalMercator: true, transitionEffect: "resize", @@ -570,20 +570,20 @@ MapWidget.prototype = { numZoomLevels: 12, transparent : true, attribution: layers[i].attribution - }, + }, { isBaseLayer : true } ); } else { layer = new OpenLayers.Layer.WMS( - layers[i].name, layers[i].url, + layers[i].name, layers[i].url, { projection : "EPSG:4326", layers : layers[i].layer, transparent : "true", format : "image/png" - }, + }, { attribution: layers[i].attribution, isBaseLayer : true @@ -651,18 +651,18 @@ MapWidget.prototype = { this.baseLayers.push(aerial); } if (this.options.osmMaps) { - this.baseLayers.push(new OpenLayers.Layer.OSM('Open Street Map', '', { + this.baseLayers.push(new OpenLayers.Layer.OSM('OpenStreetMap', '', { sphericalMercator : true, zoomOffset : 1, resolutions : this.resolutions })); } if (this.options.osmMapsMapQuest) { - this.baseLayers.push(new OpenLayers.Layer.OSM('Open Street Map (MapQuest)', + this.baseLayers.push(new OpenLayers.Layer.OSM('OpenStreetMap (MapQuest)', ["http://otile1.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png", "http://otile2.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png", "http://otile3.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png", - "http://otile4.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png"], + "http://otile4.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.png"], { sphericalMercator : true, zoomOffset : 1, @@ -1101,7 +1101,7 @@ MapWidget.prototype = { hideEmptyCircles = true; } } - + if( !GeoTemConfig.highlightEvents ){ return; } @@ -1116,13 +1116,13 @@ MapWidget.prototype = { for (var i in points ) { for (var j in points[i] ) { var point = points[i][j]; - + if (hideEmptyCircles){ point.feature.style.display = 'none'; } else { point.feature.style.display = ''; - } - + } + this.updatePoint(points[i][j], polygon); } } @@ -1230,7 +1230,7 @@ MapWidget.prototype = { this.core.triggerSelection(this.selection); this.filterBar.reset(true); }, - + triggerMapChanged : function(mapName) { Publisher.Publish('mapChanged', mapName, this); }, @@ -1380,12 +1380,12 @@ MapWidget.prototype = { } this.openlayersMap.zoomTo(Math.floor(this.getZoom())); this.openlayersMap.setBaseLayer(this.baseLayers[index]); - if (this.baseLayers[index].name == 'Open Street Map') { + if (this.baseLayers[index].name == 'OpenStreetMap') { this.gui.osmLink.style.visibility = 'visible'; } else { this.gui.osmLink.style.visibility = 'hidden'; } - if (this.baseLayers[index].name == 'Open Street Map (MapQuest)') { + if (this.baseLayers[index].name == 'OpenStreetMap (MapQuest)') { this.gui.osmMapQuestLink.style.visibility = 'visible'; } else { this.gui.osmMapQuestLink.style.visibility = 'hidden'; @@ -1524,7 +1524,7 @@ MapWidget.prototype = { } } } else { - //if there are no points on the map, zoom to max + //if there are no points on the map, zoom to max this.openlayersMap.zoomTo(0); if (this.zoomSlider) { this.zoomSlider.setValue(this.getZoom()); diff --git a/js/Map/PlacenameTags.js b/js/Map/PlacenameTags.js index 6554dbb..ec489cb 100644 --- a/js/Map/PlacenameTags.js +++ b/js/Map/PlacenameTags.js @@ -32,7 +32,7 @@ function PlacenameTags(circle, map) { this.circle = circle; this.map = map; - this.placeLabels + this.placeLabels this.selectedLabel this.allLabel @@ -51,10 +51,11 @@ function PlacenameTags(circle, map) { var labels = []; var levelOfDetail = 0; - if (this.map.options.placenameTagsStyle === 'zoom') + if (this.map.options.placenameTagsStyle === 'zoom') { levelOfDetail = this.map.getLevelOfDetail(); + } - if (this.map.options.placenameTagsStyle === 'value'){ + if (this.map.options.placenameTagsStyle === 'value') { //find max level that _all_ elements have a value for var maxLevel; for (var i = 0; i < elements.length; i++) { diff --git a/js/Overlayloader/Overlayloader.js b/js/Overlayloader/Overlayloader.js index b6dc97f..7a23d5c 100644 --- a/js/Overlayloader/Overlayloader.js +++ b/js/Overlayloader/Overlayloader.js @@ -154,7 +154,7 @@ Overlayloader.prototype = { newOverlay.layers = []; var newLayer = new OpenLayers.Layer.XYZ( - "XYZ Layer", + "XYZ layer", [ xyzURL ], { @@ -179,7 +179,7 @@ Overlayloader.prototype = { }, addKMLLoader : function() { - $(this.parent.gui.loaderTypeSelect).append(""); + $(this.parent.gui.loaderTypeSelect).append(""); this.KMLLoaderTab = document.createElement("div"); $(this.KMLLoaderTab).attr("id","KMLLoader"); @@ -206,7 +206,7 @@ Overlayloader.prototype = { }, addKMZLoader : function() { - $(this.parent.gui.loaderTypeSelect).append(""); + $(this.parent.gui.loaderTypeSelect).append(""); this.KMZLoaderTab = document.createElement("div"); $(this.KMZLoaderTab).attr("id","KMZLoader"); @@ -251,7 +251,7 @@ Overlayloader.prototype = { $(this.ArcGISWMSLoaderTab).append(this.wmsLayer); this.loadArcGISWMSButton = document.createElement("button"); - $(this.loadArcGISWMSButton).text("load Layer"); + $(this.loadArcGISWMSButton).text("load layer"); $(this.ArcGISWMSLoaderTab).append(this.loadArcGISWMSButton); $(this.loadArcGISWMSButton).click($.proxy(function(){ @@ -267,7 +267,7 @@ Overlayloader.prototype = { }, addXYZLoader : function() { - $(this.parent.gui.loaderTypeSelect).append(""); + $(this.parent.gui.loaderTypeSelect).append(""); this.XYZLoaderTab = document.createElement("div"); $(this.XYZLoaderTab).attr("id","XYZLoader"); @@ -279,7 +279,7 @@ Overlayloader.prototype = { $(this.XYZLoaderTab).append(this.xyzURL); this.loadXYZButton = document.createElement("button"); - $(this.loadXYZButton).text("load Layer"); + $(this.loadXYZButton).text("load layer"); $(this.XYZLoaderTab).append(this.loadXYZButton); $(this.loadXYZButton).click($.proxy(function(){ @@ -301,7 +301,7 @@ Overlayloader.prototype = { $(this.RomanEmpireLoaderTab).attr("id","RomanEmpireLoader"); this.loadRomanEmpireButton = document.createElement("button"); - $(this.loadRomanEmpireButton).text("load Layer"); + $(this.loadRomanEmpireButton).text("load layer"); $(this.RomanEmpireLoaderTab).append(this.loadRomanEmpireButton); $(this.loadRomanEmpireButton).click($.proxy(function(){ @@ -312,13 +312,13 @@ Overlayloader.prototype = { }, addMapsForFreeWaterLayer : function() { - $(this.parent.gui.loaderTypeSelect).append(""); + $(this.parent.gui.loaderTypeSelect).append(""); this.MapsForFreeWaterTab = document.createElement("div"); $(this.MapsForFreeWaterTab).attr("id","MapsForFreeWaterLayerLoader"); this.loadMapsForFreeWaterLayerButton = document.createElement("button"); - $(this.loadMapsForFreeWaterLayerButton).text("load Layer"); + $(this.loadMapsForFreeWaterLayerButton).text("load layer"); $(this.MapsForFreeWaterTab).append(this.loadMapsForFreeWaterLayerButton); $(this.loadMapsForFreeWaterLayerButton).click($.proxy(function(){ @@ -347,7 +347,7 @@ Overlayloader.prototype = { $(this.ConfigLoaderTab).append(this.ConfigMapSelect); this.loadConfigMapButton = document.createElement("button"); - $(this.loadConfigMapButton).text("load Layer"); + $(this.loadConfigMapButton).text("load layer"); $(this.ConfigLoaderTab).append(this.loadConfigMapButton); $(this.loadConfigMapButton).click($.proxy(function(){ diff --git a/js/Storytelling/StorytellingWidget.js b/js/Storytelling/StorytellingWidget.js index b9c9d70..17d0684 100644 --- a/js/Storytelling/StorytellingWidget.js +++ b/js/Storytelling/StorytellingWidget.js @@ -70,96 +70,92 @@ StorytellingWidget.prototype = { $(storytellingWidget.datasets).each(function(){ var dataset = this; - if (magneticLinkParam.length > 0) + if (magneticLinkParam.length > 0) { magneticLinkParam += "&"; + } - var paragraph = $("

"); + // Get color of dataset and create

tag. + var color = 'rgb(' + dataset.color.r0 + ',' + dataset.color.g0 + ',' + dataset.color.b0 + ')'; + // Style color hack. Don't do it! :-D --fu + var paragraph = $("

"); paragraph.append(dataset.label); if (typeof dataset.url !== "undefined"){ - //TODO: makes only sense for KML or CSV URLs, so "type" of - //URL should be preserved (in dataset). - //startsWith and endsWith defined in SIMILE Ajax (string.js) - var type="csv"; - if (typeof dataset.type !== "undefined") + + // TODO: makes only sense for KML or CSV URLs, so "type" of + // URL should be preserved (in dataset). + // startsWith and endsWith defined in SIMILE Ajax (string.js) + var type = "csv"; + if (typeof dataset.type !== "undefined") { type = dataset.type; - else { - if (dataset.url.toLowerCase().endsWith("kml")) + } else { + if (dataset.url.toLowerCase().endsWith("kml")) { type = "kml"; + } } - magneticLinkParam += type+linkCount+"="; + magneticLinkParam += type+linkCount + "="; linkCount++; magneticLinkParam += dataset.url; - var tableLinkDiv = document.createElement('a'); - tableLinkDiv.title = dataset.url; + var tableLinkDiv = document.createElement('a'); + tableLinkDiv.title = 'Open/download dataset ' + dataset.label + ' directly from source location. Datasets from DARIAH-DE OwnStorage must be public or you need to be owner of the dataset.'; tableLinkDiv.href = dataset.url; tableLinkDiv.target = '_'; tableLinkDiv.setAttribute('class', 'externalLink'); paragraph.append(tableLinkDiv); + // Provide link to Datasheet Editor if stored in DARIAH-DE OwnStorage. + if (dataset.url.includes(GeoTemConfig.dariahOwnStorageURL)) { + var datasheetLinkDiv = document.createElement('a'); + $(datasheetLinkDiv).append("[open datasheet]"); + datasheetLinkDiv.title = 'Open datasheet ' + dataset.label + ' from DARIAH-DE OwnStorage in Datasheet Editor. The dataset must be public or you need to be owner of the dataset.'; + datasheetLinkDiv.href = GeoTemConfig.datasheetEditorURL + '?id=' + dataset.label; + datasheetLinkDiv.target = '_'; + paragraph.append(' '); + paragraph.append(datasheetLinkDiv); + } } else { if (storytellingWidget.options.dariahStorage){ var uploadToDARIAH = document.createElement('a'); - $(uploadToDARIAH).append(" [upload to DARIAH storage]"); - uploadToDARIAH.title = ""; + $(uploadToDARIAH).append(" [upload to DARIAH-DE Storage]"); + uploadToDARIAH.title = "Only CSV documents can be uploaded to the DARIAH-DE Storage, so you can edit them using the Datasheet Editor. If the dataset is not already in CSV format, it will be converted automatically and then be uploaded. The filename of your uploaded file will be lost and you have to login first! We apologise for the inconvenience!"; uploadToDARIAH.href = dataset.url; - var localDatasetIndex = new Number(datasetIndex); - $(uploadToDARIAH).click(function(){ + $(uploadToDARIAH).click(function(){ var csv = GeoTemConfig.createCSVfromDataset(localDatasetIndex); - // taken from dariah.storage.js - var storageURL = "https://geobrowser.de.dariah.eu/storage/" - $.ajax({ - url: storageURL, - type: 'POST', - contentType: 'text/csv', - data: csv, - success: function(data, status, xhr) { - var location = xhr.getResponseHeader('Location'); - // the dariah storage id - dsid = location.substring(location.lastIndexOf('/')+1); - - //add URL to dataset - storytellingWidget.datasets[localDatasetIndex].url = location; - storytellingWidget.datasets[localDatasetIndex].type = "csv"; - //refresh list - storytellingWidget.initWidget(storytellingWidget.datasets); - }, - error: function (data, text, error) { - alert('Could not create file in DARIAH storage: ' + text); - console.log(data); - console.log(text); - console.log(error); - } - }); + GeoTemConfig.storeToDariahStorage(csv, function(location, id) { + // Set (global) DSID. + dsid = id; + // Add URL to dataset. + storytellingWidget.datasets[localDatasetIndex].url = location; + storytellingWidget.datasets[localDatasetIndex].type = "csv"; + storytellingWidget.datasets[localDatasetIndex].label = dsid; + // Refresh list. + storytellingWidget.initWidget(storytellingWidget.datasets); + }); //discard link click-event return(false); }); paragraph.append(uploadToDARIAH); } // TODO: if layout is more usable, both options could be used ("else" removed) - else if (storytellingWidget.options.localStorage){ + else if (storytellingWidget.options.localStorage) { var saveToLocalStorage = document.createElement('a'); $(saveToLocalStorage).append(" [save to local storage]"); saveToLocalStorage.title = ""; saveToLocalStorage.href = dataset.url; - var localDatasetIndex = new Number(datasetIndex); $(saveToLocalStorage).click(function(){ var csv = GeoTemConfig.createCSVfromDataset(localDatasetIndex); - - var storageName = "GeoBrowser_dataset_"+GeoTemConfig.datasets[localDatasetIndex].label; + var storageName = "GeoBrowser_dataset_" + GeoTemConfig.datasets[localDatasetIndex].label; $.remember({ name:storageName, value:csv }); - //add URL to dataset storytellingWidget.datasets[localDatasetIndex].url = storageName; storytellingWidget.datasets[localDatasetIndex].type = "local"; //refresh list storytellingWidget.initWidget(storytellingWidget.datasets); - //discard link click-event return(false); }); @@ -176,18 +172,26 @@ StorytellingWidget.prototype = { }, createLink : function() { - $(this.gui.storytellingContainer).find('.magneticLink').remove(); + // Remove
Data History -
+ @@ -81,17 +81,17 @@ var mapDiv = document.getElementById("mapContainerDiv"); var map = new WidgetWrapper(); var mapWidget = new MapWidget(map,mapDiv,{ - mapTitle: "Publication Place" + mapTitle: "Publication place" }); var timeDiv = document.getElementById("plotContainerDiv"); var time = new WidgetWrapper(); var timeWidget = new FuzzyTimelineWidget(time,timeDiv,{ - timeTitle: "Publication Date" + timeTitle: "Publication date" }); var tableDiv = document.getElementById("tableContainerDiv"); var table = new WidgetWrapper(); var tableWidget = new TableWidget(table,tableDiv); - + var dataloaderDiv = document.getElementById("dataloaderContainerDiv"); var dataloader = new WidgetWrapper(); var dataloaderWidget = new DataloaderWidget(dataloader,dataloaderDiv); diff --git a/loader_devel.html b/loader_devel.html index 36f14cb..124396b 100644 --- a/loader_devel.html +++ b/loader_devel.html @@ -55,7 +55,7 @@
Data History -
+ @@ -83,17 +83,17 @@ var mapDiv = document.getElementById("mapContainerDiv"); var map = new WidgetWrapper(); var mapWidget = new MapWidget(map,mapDiv,{ - mapTitle: "Publication Place" + mapTitle: "Publication place" }); var timeDiv = document.getElementById("plotContainerDiv"); var time = new WidgetWrapper(); var timeWidget = new FuzzyTimelineWidget(time,timeDiv,{ - timeTitle: "Publication Date" + timeTitle: "Publication date" }); var tableDiv = document.getElementById("tableContainerDiv"); var table = new WidgetWrapper(); var tableWidget = new TableWidget(table,tableDiv); - + var dataloaderDiv = document.getElementById("dataloaderContainerDiv"); var dataloader = new WidgetWrapper(); var dataloaderWidget = new DataloaderWidget(dataloader,dataloaderDiv); diff --git a/loader_empty.html b/loader_empty.html index 413e8da..a715d99 100644 --- a/loader_empty.html +++ b/loader_empty.html @@ -54,7 +54,7 @@
Data History -
+ @@ -81,17 +81,17 @@ var mapDiv = document.getElementById("mapContainerDiv"); var map = new WidgetWrapper(); var mapWidget = new MapWidget(map,mapDiv,{ - mapTitle: "Publication Place" + mapTitle: "Publication place" }); var timeDiv = document.getElementById("plotContainerDiv"); var time = new WidgetWrapper(); var timeWidget = new FuzzyTimelineWidget(time,timeDiv,{ - timeTitle: "Publication Date" + timeTitle: "Publication date" }); var tableDiv = document.getElementById("tableContainerDiv"); var table = new WidgetWrapper(); var tableWidget = new TableWidget(table,tableDiv); - + var dataloaderDiv = document.getElementById("dataloaderContainerDiv"); var dataloader = new WidgetWrapper(); var dataloaderWidget = new DataloaderWidget(dataloader,dataloaderDiv); @@ -100,15 +100,15 @@ var overlayloader = new WidgetWrapper(); var overlayloaderWidget = new OverlayloaderWidget(overlayloader,overlayloaderDiv); overlayloaderWidget.attachMapWidget(mapWidget); - + var piechartDiv = document.getElementById("piechartContainerDiv"); var piechart = new WidgetWrapper(); var piechartWidget = new PieChartWidget(piechart,piechartDiv); - + var storytellingDiv = document.getElementById("storytellingContainerDiv"); var storytelling = new WidgetWrapper(); var storytellingWidget = new StorytellingWidget(storytelling,storytellingDiv); - + dataloaderWidget.loadFromURL(); diff --git a/minifier.html b/minifier.html index f7bb167..5b580b0 100644 --- a/minifier.html +++ b/minifier.html @@ -27,12 +27,12 @@ var mapDiv = document.getElementById("mapContainerDiv"); var map = new WidgetWrapper(); var mapWidget = new MapWidget(map,mapDiv,{ - mapTitle: "Publication Place" + mapTitle: "Publication place" }); var timeDiv = document.getElementById("plotContainerDiv"); var time = new WidgetWrapper(); var timeWidget = new TimeWidget(time,timeDiv,{ - timeTitle: "Publication Date" + timeTitle: "Publication date" }); var tableDiv = document.getElementById("tableContainerDiv"); var table = new WidgetWrapper(); diff --git a/php/download.php b/php/download.php index 38e1ac6..88f8d01 100644 --- a/php/download.php +++ b/php/download.php @@ -19,20 +19,20 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ - + if (!empty($_POST['file'])) { - + $file = $_POST['file']; $filesize = strlen($file); - + $mime = array('application/octet-stream'); - + header('Content-Type: '.$mime); header('Content-Disposition: attachment; filename="test.kml"'); header('Content-Transfer-Encoding: binary'); header('Content-Length: '.sprintf('%d', $filesize)); header('Expires: 0'); - + // check for IE only headers // credits to: cballou, http://stackoverflow.com/questions/2019964/php-form-download-to-zip if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) { @@ -41,7 +41,7 @@ } else { header('Pragma: no-cache'); } - + echo $file; } -?> \ No newline at end of file +?> diff --git a/php/proxy.php b/php/proxy.php deleted file mode 120000 index 9e77f0a..0000000 --- a/php/proxy.php +++ /dev/null @@ -1 +0,0 @@ -/etc/geobrowser/proxy.php \ No newline at end of file diff --git a/php/proxy.php b/php/proxy.php new file mode 100644 index 0000000..2b3dc77 --- /dev/null +++ b/php/proxy.php @@ -0,0 +1,76 @@ + $value){ + if ($key == 'address') + continue; + if ($isFirst == 1){ + $isFirst = 0; + $address .= "?"; + } else { + $address .= "&"; + } + $address .= $key . "=" . $value; + } + + $request_body = file_get_contents('php://input'); + + if (empty($request_body)){ + echo file_get_contents($address); + } else { + $opts = array('http' => + array( + 'method' => 'POST', + 'header' => 'Content-type: '.$_SERVER["CONTENT_TYPE"], + 'content' => $request_body + ) + ); + + $context = stream_context_create($opts); + + echo file_get_contents($address, false, $context); + } + } + } +?>