| changeset 118 | fdf808d7d374 |
| parent 117 | dc6c3ac62efa |
| child 123 | 94fc5f5b5cfd |
| 117:dc6c3ac62efa | 118:fdf808d7d374 |
|---|---|
7 maxYear: 2010, |
7 maxYear: 2010, |
8 tlPixels: 960, |
8 tlPixels: 960, |
9 tlGamma: 6, |
9 tlGamma: 6, |
10 heatGamma: 4, |
10 heatGamma: 4, |
11 displayedDates: [-5000,0,500,1000,1200,1400,1600,1700,1750,1800,1850,1900,1950,2010], |
11 displayedDates: [-5000,0,500,1000,1200,1400,1600,1700,1750,1800,1850,1900,1950,2010], |
12 mappingLibrary: 'leaflet', |
|
12 } |
13 } |
13 |
14 |
14 function yearToPx(year) { |
15 function yearToPx(year) { |
15 return gomNs.tlPixels * Math.pow( ( year - gomNs.minYear ) / ( gomNs.maxYear - gomNs.minYear ), gomNs.tlGamma ); |
16 return gomNs.tlPixels * Math.pow( ( year - gomNs.minYear ) / ( gomNs.maxYear - gomNs.minYear ), gomNs.tlGamma ); |
16 } |
17 } |
40 _html += '<img id="img_wikipedia" src="' |
41 _html += '<img id="img_wikipedia" src="' |
41 + data.thumbnail |
42 + data.thumbnail |
42 + '" />'; |
43 + '" />'; |
43 } |
44 } |
44 if (data.abstract) { |
45 if (data.abstract) { |
45 _html += '<p>' + _(data.abstract).escape() + '</p>'; |
46 _html += '<p>' + _(data.abstract).escape().replace(/(^.{0,240})([\s]|$)(.*)/,'$1…') + '</p>'; |
46 } |
47 } |
47 if (data.links) { |
48 /* if (data.links) { |
48 var _lC = data.requested_label.toLowerCase(); |
49 var _lC = data.requested_label.toLowerCase(); |
49 var _t = data.links.map(function(d) { |
50 var _t = data.links.map(function(d) { |
50 return (d.subject.toLowerCase() == _lC) ? d.object : d.subject; |
51 return (d.subject.toLowerCase() == _lC) ? d.object : d.subject; |
51 }); |
52 }); |
52 _t.sort(); |
53 _t.sort(); |
56 return '<li class="content-tag-item"><a href="#" onclick="tagInfo($(this).text()); return false;">' |
57 return '<li class="content-tag-item"><a href="#" onclick="tagInfo($(this).text()); return false;">' |
57 + d |
58 + d |
58 + '</a></li>'; |
59 + '</a></li>'; |
59 }).join('') |
60 }).join('') |
60 + '</ul>'; |
61 + '</ul>'; |
61 } |
62 } */ |
62 $("#tagdata").html(_html); |
63 $("#tagdata").html(_html); |
63 }); |
64 }); |
64 filterTag(_taglabel); |
65 addFilter('tag', _taglabel); |
65 $("#showlist").removeClass("actif"); |
66 $("#showlist").removeClass("actif"); |
66 } |
67 } |
67 |
68 |
68 function filterTag(_tagLabel) { |
69 function addFilter(_type, _label) { |
69 var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
70 var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
70 if (_curView.type == 'filter') { |
71 if (_curView.type == 'filter') { |
71 _curView.tag.push(_tagLabel); |
72 _curView[_type].push(_label); |
73 console.log(_curView[_type]); |
|
72 updateFilters(); |
74 updateFilters(); |
73 debouncedSaveChanges(); |
75 debouncedSaveChanges(); |
74 } |
76 } |
75 } |
77 } |
76 |
78 |
77 function removeFilter(_index) { |
79 function removeFilter(_type, _index) { |
78 var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
80 var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
79 if (_curView.type == 'filter') { |
81 if (_curView.type == 'filter') { |
80 _curView.tag.splice(_index,1); |
82 _curView[_type].splice(_index,1); |
81 updateFilters(); |
83 updateFilters(); |
82 debouncedSaveChanges(); |
84 debouncedSaveChanges(); |
83 } |
85 } |
84 } |
86 } |
85 |
87 |
90 if (_curView.period && !(_curView.period[0] == gomNs.minYear && _curView.period[1] == gomNs.maxYear)) { |
92 if (_curView.period && !(_curView.period[0] == gomNs.minYear && _curView.period[1] == gomNs.maxYear)) { |
91 _params.period = _curView.period.join(','); |
93 _params.period = _curView.period.join(','); |
92 } |
94 } |
93 if (_curView.tag.length) { |
95 if (_curView.tag.length) { |
94 _params.label = _curView.tag.join(','); |
96 _params.label = _curView.tag.join(','); |
97 } |
|
98 if (_curView.country.length) { |
|
99 _params.country = _curView.country.join(','); |
|
95 } |
100 } |
96 $.getJSON("filter.php", _params, updateDisplay); |
101 $.getJSON("filter.php", _params, updateDisplay); |
97 } |
102 } |
98 } |
103 } |
99 |
104 |
139 var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
144 var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
140 if (_curView.type != 'filter') { |
145 if (_curView.type != 'filter') { |
141 return; |
146 return; |
142 } |
147 } |
143 var _htmFilters = '', |
148 var _htmFilters = '', |
144 _fl = _curView.tag.length; |
149 _fl = _curView.tag.length, |
145 if (!_curView.period && !_fl) { |
150 _cl = _curView.country.length; |
151 if (!_curView.period && !_fl && !_cl) { |
|
146 _htmFilters = '<li class="nofilter">Aucun filtre</li>'; |
152 _htmFilters = '<li class="nofilter">Aucun filtre</li>'; |
147 } |
153 } |
148 if (_curView.period) { |
154 if (_curView.period) { |
149 _htmFilters += '<li class="filperiod"><span class="spyr" id="sp_0" onclick="changeSpan(this);">' |
155 _htmFilters += '<li class="filperiod">Période : <span class="spyr" id="sp_0" onclick="changeSpan(this);">' |
150 + _curView.period[0] |
156 + _curView.period[0] |
151 + '</span> à <span class="spyr" id="sp_1" onclick="changeSpan(this);">' |
157 + '</span> à <span class="spyr" id="sp_1" onclick="changeSpan(this);">' |
152 + _curView.period[1] |
158 + _curView.period[1] |
153 + '</span></li>'; |
159 + '</span></li>'; |
154 $("#handle_0").css({ |
160 $("#handle_0").css({ |
164 .find(".handleinner") |
170 .find(".handleinner") |
165 .css({ |
171 .css({ |
166 "margin-left" : "0" |
172 "margin-left" : "0" |
167 }); |
173 }); |
168 } |
174 } |
175 if (_cl) { |
|
176 _htmFilters += _(_curView.country).map(function(_t, _i) { |
|
177 return '<li class="filcountry">Pays : ' |
|
178 + ( gomNs.countryLabels[_t] || _t ) |
|
179 + '<a href="#" class="remfil" onclick="removeFilter(\'country\',' |
|
180 + _i |
|
181 + '); return false;">[x]</a></li>'; |
|
182 }).join(""); |
|
183 } |
|
169 if (_fl) { |
184 if (_fl) { |
170 _htmFilters += _(_curView.tag).map(function(_t, _i) { |
185 _htmFilters += _(_curView.tag).map(function(_t, _i) { |
171 return '<li class="filtag">' |
186 return '<li class="filtag">Tag : ' |
172 + _t |
187 + _t |
173 + '<a href="#" class="remfil" onclick="removeFilter(' |
188 + '<a href="#" class="remfil" onclick="removeFilter(\'tag\',' |
174 + _i |
189 + _i |
175 + '); return false;">[x]</a></li>'; |
190 + '); return false;">[x]</a></li>'; |
176 }).join(""); |
191 }).join(""); |
177 } |
192 } |
178 $("#filters").html(_htmFilters); |
193 $("#filters").html(_htmFilters); |
181 |
196 |
182 function displayContents(contentdata) { |
197 function displayContents(contentdata) { |
183 if (contentdata && contentdata.length) { |
198 if (contentdata && contentdata.length) { |
184 var _htmlCl = '<ul id="contentlist">' |
199 var _htmlCl = '<ul id="contentlist">' |
185 + contentdata.map(function(_d) { |
200 + contentdata.map(function(_d) { |
186 var _html = '<li class="content-item"><h3>' |
201 var _html = '<li class="content-item">' |
202 + ( _d.latitude != null && _d.longitude != null ? |
|
203 '<img class="maplet" src="http://maps.googleapis.com/maps/api/staticmap?center=' |
|
204 + _d.latitude |
|
205 + ',' |
|
206 + _d.longitude |
|
207 + '&zoom=8&size=128x200&maptype=terrain&markers=color:red%7C' |
|
208 + _d.latitude |
|
209 + ',' |
|
210 + _d.longitude |
|
211 + '&sensor=false" />' |
|
212 : '') |
|
213 + '<h3>' |
|
187 + _d.title |
214 + _d.title |
188 + '</h3><h4><a href="' |
215 + '</h3><h4><a href="' |
189 + _d.url |
216 + _d.url |
190 + '" target="_blank">' |
217 + '" target="_blank">' |
191 + _d.url |
218 + _d.url |
192 + '</a></h4><p>' |
219 + '</a></h4><p>' |
193 + _d.description |
220 + _d.description.replace(/(^.{0,160})([\s]|$)(.*)/,'$1…') |
194 + '</p><ul class="content-tags">' |
221 + '</p><ul class="content-tags">' |
195 + _d.tags.map(function(_t) { |
222 + _d.tags.map(function(_t) { |
196 return '<li class="content-tag-item"><a href="#" onclick="tagInfo($(this).text()); return false;"' |
223 return '<li class="content-tag-item"><a href="#" onclick="tagInfo($(this).text()); return false;"' |
197 + (_t.match ? ' class="tagmatch"' : '') |
224 + (_t.match ? ' class="tagmatch"' : '') |
198 + '>' |
225 + '>' |
308 } |
335 } |
309 if (data.tags.length) { |
336 if (data.tags.length) { |
310 var _scores = _(data.tags).map(function(_d) { return parseInt(_d.score)}), |
337 var _scores = _(data.tags).map(function(_d) { return parseInt(_d.score)}), |
311 _maxTag = _(_scores).max(), |
338 _maxTag = _(_scores).max(), |
312 _minTag = Math.min(_(_scores).min(), _maxTag - 1), |
339 _minTag = Math.min(_(_scores).min(), _maxTag - 1), |
313 _scale = 20 / Math.sqrt(_maxTag - _minTag), |
340 _scale = 10 / Math.sqrt(_maxTag - _minTag), |
314 _htmlTc = '<ul id="tclist">' |
341 _htmlTc = '<ul id="tclist">' |
315 + _(data.tags).map(function(_d) { |
342 + _(data.tags).map(function(_d) { |
316 return '<li style="font-size:' |
343 return '<li style="font-size:' |
317 + parseInt(10 + _scale * Math.sqrt(_d.score - _minTag)) |
344 + parseInt(10 + _scale * Math.sqrt(_d.score - _minTag)) |
318 + 'px;"><a href="#" onclick="tagInfo($(this).text()); return false;"' |
345 + 'px;"><a href="#" onclick="tagInfo($(this).text()); return false;"' |
327 else { |
354 else { |
328 $("#tagcloud").html("<h4>Pas de mots-clés trouvés</h4>"); |
355 $("#tagcloud").html("<h4>Pas de mots-clés trouvés</h4>"); |
329 } |
356 } |
330 displayContents(data.contents); |
357 displayContents(data.contents); |
331 if (gomNs.countries && data.countries) { |
358 if (gomNs.countries && data.countries) { |
332 var _max = Math.max(1, _(data.countries).max(function(_c) { return _c.score}).score); |
359 var _max = Math.max(1, _(data.countries).max()); |
333 _(data.countries).each(function(_c) { |
360 _(gomNs.countries).each(function(_country, _k) { |
334 var _cc = gomNs.countries[_c.isocode]; |
361 var _val = data.countries[_k] || 0, |
335 if (_cc) { |
362 _gb = parseInt(255 * (1 - _val / _max )), |
336 var _gb = parseInt(255 * (1 - _c.score / _max )); |
363 _fill = ( _val ? "rgb(255," + _gb + "," + _gb + ")" : "#7070a0" ); |
337 _(_cc.gPolygons).each(function(_p) { |
364 switch(gomNs.mappingLibrary) { |
338 _p.setOptions({ |
365 case 'gmaps': |
339 "fillColor" : ( _c.score ? "rgb(255," + _gb + "," + _gb + ")" : "#7070a0" ), |
366 _(_country.gPolygons).each(function(_p) { |
367 _p.setOptions({ |
|
368 "fillColor" : _fill |
|
369 }); |
|
340 }); |
370 }); |
341 }); |
371 break; |
372 case 'leaflet': |
|
373 _country.setStyle({ |
|
374 "fillColor" : _fill |
|
375 }) |
|
376 break; |
|
342 } |
377 } |
343 }); |
378 }); |
344 } |
379 } |
345 if (data.disciplines) { |
380 if (data.disciplines) { |
346 var _disc = data.disciplines.filter(function(_d) { |
381 var _disc = data.disciplines.filter(function(_d) { |
522 }; |
557 }; |
523 switch(viewtype) { |
558 switch(viewtype) { |
524 case 'filter': |
559 case 'filter': |
525 _content.period = [ gomNs.minYear, gomNs.maxYear ]; |
560 _content.period = [ gomNs.minYear, gomNs.maxYear ]; |
526 _content.tag = []; |
561 _content.tag = []; |
562 _content.country = []; |
|
527 gomNs.sessiondata.view = gomNs.sessiondata.views.length; |
563 gomNs.sessiondata.view = gomNs.sessiondata.views.length; |
528 break; |
564 break; |
529 case 'list': |
565 case 'list': |
530 _content.list = []; |
566 _content.list = []; |
531 break; |
567 break; |
533 gomNs.sessiondata.views.push(_content); |
569 gomNs.sessiondata.views.push(_content); |
534 debouncedSaveChanges(); |
570 debouncedSaveChanges(); |
535 } |
571 } |
536 |
572 |
537 $(document).ready(function() { |
573 $(document).ready(function() { |
538 gomNs.map = new google.maps.Map(document.getElementById("map"), |
574 switch(gomNs.mappingLibrary) { |
539 { |
575 case 'gmaps': |
540 center: new google.maps.LatLng(30, 0), |
576 gomNs.map = new google.maps.Map(document.getElementById("map"), |
541 zoom: 1, |
577 { |
542 mapTypeId: google.maps.MapTypeId.SATELLITE |
578 center: new google.maps.LatLng(30, 0), |
543 }); |
579 zoom: 1, |
544 $.getJSON('lib/countries.geo.json', showCountries); |
580 mapTypeId: google.maps.MapTypeId.SATELLITE |
581 }); |
|
582 $.getJSON('lib/countries.geo.json', showCountriesGmap); |
|
583 break; |
|
584 case 'leaflet': |
|
585 gomNs.map = new L.Map('map', { |
|
586 center: new L.LatLng(30, 0), |
|
587 zoom: 1 |
|
588 }); |
|
589 gomNs.map.addLayer(new L.TileLayer("http://s3.amazonaws.com/com.modestmaps.bluemarble/{z}-r{y}-c{x}.jpg", {maxZoom: 9})); |
|
590 $.getJSON('lib/countries.geo.json', showCountriesLeaflet); |
|
591 break; |
|
592 } |
|
545 var _html = gomNs.displayedDates.map(function(_v) { |
593 var _html = gomNs.displayedDates.map(function(_v) { |
546 return '<li style="left: ' |
594 return '<li style="left: ' |
547 + parseInt(yearToPx(_v)) |
595 + parseInt(yearToPx(_v)) |
548 + 'px"><div class="datelabel">' |
596 + 'px"><div class="datelabel">' |
549 + _v |
597 + _v |
607 $(this).html(_el); |
655 $(this).html(_el); |
608 _el.focus(); |
656 _el.focus(); |
609 _el.select(); |
657 _el.select(); |
610 } |
658 } |
611 }); |
659 }); |
612 $("#titrevue").change(function() { |
660 $("#titrevue").keyup(function() { |
613 var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
661 var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
614 _curView.name = $(this).val(); |
662 _curView.name = $(this).val(); |
615 $("#view_" + gomNs.sessiondata.view + " a").html(_.escape(_curView.name)) |
663 $("#view_" + gomNs.sessiondata.view + " a").html(_.escape(_curView.name)) |
664 $("#bloc_gestvue h2").html('Gérer la vue "' + _.escape(_curView.name) + '"'); |
|
616 debouncedSaveChanges(); |
665 debouncedSaveChanges(); |
617 }); |
666 }); |
618 $("#notes").click(function() { |
667 $("#notes").click(function() { |
619 if (gomNs.write_allowed) { |
668 if (gomNs.write_allowed) { |
620 if (this.children[0].tagName == 'UL') { |
669 if (this.children[0].tagName == 'UL') { |