--- a/hdalab/js/gomina.js Thu Feb 02 12:03:07 2012 +0100
+++ b/hdalab/js/gomina.js Mon Feb 06 18:50:19 2012 +0100
@@ -9,6 +9,7 @@
tlGamma: 6,
heatGamma: 4,
displayedDates: [-5000,0,500,1000,1200,1400,1600,1700,1750,1800,1850,1900,1950,2010],
+ mappingLibrary: 'leaflet',
}
function yearToPx(year) {
@@ -42,9 +43,9 @@
+ '" />';
}
if (data.abstract) {
- _html += '<p>' + _(data.abstract).escape() + '</p>';
+ _html += '<p>' + _(data.abstract).escape().replace(/(^.{0,240})([\s]|$)(.*)/,'$1…') + '</p>';
}
- if (data.links) {
+/* if (data.links) {
var _lC = data.requested_label.toLowerCase();
var _t = data.links.map(function(d) {
return (d.subject.toLowerCase() == _lC) ? d.object : d.subject;
@@ -58,26 +59,27 @@
+ '</a></li>';
}).join('')
+ '</ul>';
- }
+ } */
$("#tagdata").html(_html);
});
- filterTag(_taglabel);
+ addFilter('tag', _taglabel);
$("#showlist").removeClass("actif");
}
-function filterTag(_tagLabel) {
+function addFilter(_type, _label) {
var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view];
if (_curView.type == 'filter') {
- _curView.tag.push(_tagLabel);
+ _curView[_type].push(_label);
+ console.log(_curView[_type]);
updateFilters();
debouncedSaveChanges();
}
}
-function removeFilter(_index) {
+function removeFilter(_type, _index) {
var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view];
if (_curView.type == 'filter') {
- _curView.tag.splice(_index,1);
+ _curView[_type].splice(_index,1);
updateFilters();
debouncedSaveChanges();
}
@@ -93,6 +95,9 @@
if (_curView.tag.length) {
_params.label = _curView.tag.join(',');
}
+ if (_curView.country.length) {
+ _params.country = _curView.country.join(',');
+ }
$.getJSON("filter.php", _params, updateDisplay);
}
}
@@ -141,12 +146,13 @@
return;
}
var _htmFilters = '',
- _fl = _curView.tag.length;
- if (!_curView.period && !_fl) {
+ _fl = _curView.tag.length,
+ _cl = _curView.country.length;
+ if (!_curView.period && !_fl && !_cl) {
_htmFilters = '<li class="nofilter">Aucun filtre</li>';
}
if (_curView.period) {
- _htmFilters += '<li class="filperiod"><span class="spyr" id="sp_0" onclick="changeSpan(this);">'
+ _htmFilters += '<li class="filperiod">Période : <span class="spyr" id="sp_0" onclick="changeSpan(this);">'
+ _curView.period[0]
+ '</span> à <span class="spyr" id="sp_1" onclick="changeSpan(this);">'
+ _curView.period[1]
@@ -166,11 +172,20 @@
"margin-left" : "0"
});
}
+ if (_cl) {
+ _htmFilters += _(_curView.country).map(function(_t, _i) {
+ return '<li class="filcountry">Pays : '
+ + ( gomNs.countryLabels[_t] || _t )
+ + '<a href="#" class="remfil" onclick="removeFilter(\'country\','
+ + _i
+ + '); return false;">[x]</a></li>';
+ }).join("");
+ }
if (_fl) {
_htmFilters += _(_curView.tag).map(function(_t, _i) {
- return '<li class="filtag">'
+ return '<li class="filtag">Tag : '
+ _t
- + '<a href="#" class="remfil" onclick="removeFilter('
+ + '<a href="#" class="remfil" onclick="removeFilter(\'tag\','
+ _i
+ '); return false;">[x]</a></li>';
}).join("");
@@ -183,14 +198,26 @@
if (contentdata && contentdata.length) {
var _htmlCl = '<ul id="contentlist">'
+ contentdata.map(function(_d) {
- var _html = '<li class="content-item"><h3>'
+ var _html = '<li class="content-item">'
+ + ( _d.latitude != null && _d.longitude != null ?
+ '<img class="maplet" src="http://maps.googleapis.com/maps/api/staticmap?center='
+ + _d.latitude
+ + ','
+ + _d.longitude
+ + '&zoom=8&size=128x200&maptype=terrain&markers=color:red%7C'
+ + _d.latitude
+ + ','
+ + _d.longitude
+ + '&sensor=false" />'
+ : '')
+ + '<h3>'
+ _d.title
+ '</h3><h4><a href="'
+ _d.url
+ '" target="_blank">'
+ _d.url
+ '</a></h4><p>'
- + _d.description
+ + _d.description.replace(/(^.{0,160})([\s]|$)(.*)/,'$1…')
+ '</p><ul class="content-tags">'
+ _d.tags.map(function(_t) {
return '<li class="content-tag-item"><a href="#" onclick="tagInfo($(this).text()); return false;"'
@@ -310,7 +337,7 @@
var _scores = _(data.tags).map(function(_d) { return parseInt(_d.score)}),
_maxTag = _(_scores).max(),
_minTag = Math.min(_(_scores).min(), _maxTag - 1),
- _scale = 20 / Math.sqrt(_maxTag - _minTag),
+ _scale = 10 / Math.sqrt(_maxTag - _minTag),
_htmlTc = '<ul id="tclist">'
+ _(data.tags).map(function(_d) {
return '<li style="font-size:'
@@ -329,16 +356,24 @@
}
displayContents(data.contents);
if (gomNs.countries && data.countries) {
- var _max = Math.max(1, _(data.countries).max(function(_c) { return _c.score}).score);
- _(data.countries).each(function(_c) {
- var _cc = gomNs.countries[_c.isocode];
- if (_cc) {
- var _gb = parseInt(255 * (1 - _c.score / _max ));
- _(_cc.gPolygons).each(function(_p) {
- _p.setOptions({
- "fillColor" : ( _c.score ? "rgb(255," + _gb + "," + _gb + ")" : "#7070a0" ),
+ var _max = Math.max(1, _(data.countries).max());
+ _(gomNs.countries).each(function(_country, _k) {
+ var _val = data.countries[_k] || 0,
+ _gb = parseInt(255 * (1 - _val / _max )),
+ _fill = ( _val ? "rgb(255," + _gb + "," + _gb + ")" : "#7070a0" );
+ switch(gomNs.mappingLibrary) {
+ case 'gmaps':
+ _(_country.gPolygons).each(function(_p) {
+ _p.setOptions({
+ "fillColor" : _fill
+ });
});
- });
+ break;
+ case 'leaflet':
+ _country.setStyle({
+ "fillColor" : _fill
+ })
+ break;
}
});
}
@@ -524,6 +559,7 @@
case 'filter':
_content.period = [ gomNs.minYear, gomNs.maxYear ];
_content.tag = [];
+ _content.country = [];
gomNs.sessiondata.view = gomNs.sessiondata.views.length;
break;
case 'list':
@@ -535,13 +571,25 @@
}
$(document).ready(function() {
- gomNs.map = new google.maps.Map(document.getElementById("map"),
- {
- center: new google.maps.LatLng(30, 0),
- zoom: 1,
- mapTypeId: google.maps.MapTypeId.SATELLITE
- });
- $.getJSON('lib/countries.geo.json', showCountries);
+ switch(gomNs.mappingLibrary) {
+ case 'gmaps':
+ gomNs.map = new google.maps.Map(document.getElementById("map"),
+ {
+ center: new google.maps.LatLng(30, 0),
+ zoom: 1,
+ mapTypeId: google.maps.MapTypeId.SATELLITE
+ });
+ $.getJSON('lib/countries.geo.json', showCountriesGmap);
+ break;
+ case 'leaflet':
+ gomNs.map = new L.Map('map', {
+ center: new L.LatLng(30, 0),
+ zoom: 1
+ });
+ gomNs.map.addLayer(new L.TileLayer("http://s3.amazonaws.com/com.modestmaps.bluemarble/{z}-r{y}-c{x}.jpg", {maxZoom: 9}));
+ $.getJSON('lib/countries.geo.json', showCountriesLeaflet);
+ break;
+ }
var _html = gomNs.displayedDates.map(function(_v) {
return '<li style="left: '
+ parseInt(yearToPx(_v))
@@ -609,10 +657,11 @@
_el.select();
}
});
- $("#titrevue").change(function() {
+ $("#titrevue").keyup(function() {
var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view];
_curView.name = $(this).val();
$("#view_" + gomNs.sessiondata.view + " a").html(_.escape(_curView.name))
+ $("#bloc_gestvue h2").html('Gérer la vue "' + _.escape(_curView.name) + '"');
debouncedSaveChanges();
});
$("#notes").click(function() {