| author | rougeronj |
| Tue, 16 Dec 2014 18:36:28 +0100 | |
| changeset 410 | 84f2039b6007 |
| parent 386 | 2ace68d1429b |
| child 460 | 135f5fd7d263 |
| permissions | -rw-r--r-- |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
/** |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
* @author raph |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
*/ |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
|
|
194
8c597db6fab0
correct german translation and allow translation string with tokens.
ymh <ymh.work@gmail.com>
parents:
175
diff
changeset
|
5 |
str_format = function() { |
|
8c597db6fab0
correct german translation and allow translation string with tokens.
ymh <ymh.work@gmail.com>
parents:
175
diff
changeset
|
6 |
var s = arguments[0]; |
|
8c597db6fab0
correct german translation and allow translation string with tokens.
ymh <ymh.work@gmail.com>
parents:
175
diff
changeset
|
7 |
for (var i = 0; i < arguments.length - 1; i++) { |
|
8c597db6fab0
correct german translation and allow translation string with tokens.
ymh <ymh.work@gmail.com>
parents:
175
diff
changeset
|
8 |
var reg = new RegExp("\\{" + i + "\\}", "gm"); |
|
8c597db6fab0
correct german translation and allow translation string with tokens.
ymh <ymh.work@gmail.com>
parents:
175
diff
changeset
|
9 |
s = s.replace(reg, arguments[i + 1]); |
|
8c597db6fab0
correct german translation and allow translation string with tokens.
ymh <ymh.work@gmail.com>
parents:
175
diff
changeset
|
10 |
} |
|
8c597db6fab0
correct german translation and allow translation string with tokens.
ymh <ymh.work@gmail.com>
parents:
175
diff
changeset
|
11 |
|
|
8c597db6fab0
correct german translation and allow translation string with tokens.
ymh <ymh.work@gmail.com>
parents:
175
diff
changeset
|
12 |
return s; |
|
8c597db6fab0
correct german translation and allow translation string with tokens.
ymh <ymh.work@gmail.com>
parents:
175
diff
changeset
|
13 |
} |
|
8c597db6fab0
correct german translation and allow translation string with tokens.
ymh <ymh.work@gmail.com>
parents:
175
diff
changeset
|
14 |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
var gomNs = { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
minYear: -5000, |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
maxYear: 2010, |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
tlPixels: 960, |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
tlGamma: 6, |
| 131 | 20 |
heatGamma: 2, |
21 |
displayedDates: [ -5000, 0, 500, 1000, 1200, 1400, 1600, 1700, 1750, 1800, 1850, 1900, 1950, 2010 ], |
|
| 127 | 22 |
mappingLibrary: 'leaflet', |
| 386 | 23 |
gradientStart: [ 252, 246, 210 ], |
|
410
84f2039b6007
Updates color of facette page + add shadow to renkan div for better integration in the page
rougeronj
parents:
386
diff
changeset
|
24 |
gradientEnd: [ 5, 104, 5 ], |
| 386 | 25 |
zeroColor: [ 220, 220 ,220 ], |
| 135 | 26 |
languageCode: 'fr' |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
|
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
function yearToPx(year) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
return gomNs.tlPixels * Math.pow( ( year - gomNs.minYear ) / ( gomNs.maxYear - gomNs.minYear ), gomNs.tlGamma ); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
31 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
|
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
function pxToYear(px) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
34 |
return gomNs.minYear + ( gomNs.maxYear - gomNs.minYear ) * Math.pow( px / gomNs.tlPixels, 1 / gomNs.tlGamma ); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
36 |
|
| 131 | 37 |
function getGradient(_pos) { |
38 |
if (_pos == 0) { |
|
39 |
var _rgb = gomNs.zeroColor; |
|
40 |
} else { |
|
41 |
var _rgb = [], |
|
42 |
_exp = Math.pow(_pos, 1/gomNs.heatGamma); |
|
43 |
for (var i=0; i<3; i++) { |
|
44 |
_rgb.push(Math.floor(_exp*gomNs.gradientEnd[i] + (1-_exp)*gomNs.gradientStart[i])); |
|
45 |
} |
|
46 |
} |
|
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
47 |
return "rgb(" + _rgb.join(",") + ")"; |
| 131 | 48 |
} |
49 |
||
50 |
function polygon_to_gmap(polycoords, dbpedia_uri) { |
|
51 |
var _opts = { |
|
52 |
strokeColor: "#000000", |
|
53 |
strokeWeight: .5, |
|
54 |
fillColor: "rgb(" + gomNs.zeroColor.join(",") + ")", |
|
55 |
fillOpacity: 1 |
|
56 |
} |
|
57 |
_opts.paths = polycoords.map(function(path) { |
|
58 |
return path.map(function(coord) { |
|
59 |
return new google.maps.LatLng(coord[1], coord[0]); |
|
60 |
}); |
|
61 |
}); |
|
62 |
var _polygon = new google.maps.Polygon(_opts); |
|
63 |
_polygon.setMap(gomNs.map); |
|
64 |
google.maps.event.addListener(_polygon, 'click', function(a,b) { |
|
65 |
addFilter('country', dbpedia_uri); |
|
66 |
}) |
|
67 |
return _polygon; |
|
68 |
} |
|
69 |
||
70 |
function showCountriesGmap(geoJson) { |
|
71 |
gomNs.countries = {}; |
|
72 |
_(geoJson.features).each(function(feature) { |
|
73 |
var _el = { "properties" : feature.properties }; |
|
74 |
if (feature.id == 'ATA') { |
|
75 |
_el.gPolygons = []; |
|
76 |
} else { |
|
77 |
switch(feature.geometry.type) { |
|
78 |
case('Polygon'): |
|
79 |
_el.gPolygons = [ polygon_to_gmap(feature.geometry.coordinates, feature.properties.dbpedia_uri) ]; |
|
80 |
break; |
|
81 |
case('MultiPolygon'): |
|
82 |
_el.gPolygons = feature.geometry.coordinates.map(function(polygon) { |
|
83 |
return polygon_to_gmap(polygon, feature.properties.dbpedia_uri); |
|
84 |
}) |
|
85 |
break; |
|
86 |
} |
|
87 |
} |
|
88 |
gomNs.countries[feature.properties.dbpedia_uri] = _el; |
|
89 |
}); |
|
90 |
} |
|
91 |
||
92 |
function showCountriesLeaflet(geoJson) { |
|
93 |
gomNs.countries = {}; |
|
94 |
var gJ = new L.GeoJSON(); |
|
95 |
gJ.on('featureparse', function(_f) { |
|
96 |
var isocode = _f.id; |
|
97 |
_f.layer.setStyle({ |
|
98 |
color: "#000000", |
|
99 |
weight: .5, |
|
100 |
fillOpacity: 1, |
|
101 |
fillColor: "rgb(" + gomNs.zeroColor.join(",") + ")" |
|
102 |
}); |
|
103 |
_f.layer.on('click', function() { |
|
104 |
addFilter('country', _f.properties.dbpedia_uri); |
|
105 |
}); |
|
106 |
gomNs.countries[_f.properties.dbpedia_uri] = { |
|
107 |
"properties" : _f.properties, |
|
108 |
"layer" : _f.layer |
|
109 |
} |
|
110 |
}); |
|
111 |
gJ.addGeoJSON(geoJson); |
|
112 |
gomNs.map.addLayer(gJ); |
|
113 |
} |
|
114 |
||
| 127 | 115 |
function addFilter(_type, _label) { |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
116 |
var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
117 |
if (_curView.type == 'filter') { |
| 135 | 118 |
if (_curView[_type].indexOf(_label) < 0) { |
119 |
_curView[_type].push(_label); |
|
120 |
} |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
121 |
updateFilters(); |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
122 |
//debouncedSaveChanges(); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
123 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
124 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
125 |
|
| 127 | 126 |
function removeFilter(_type, _index) { |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
127 |
var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
128 |
if (_curView.type == 'filter') { |
| 127 | 129 |
_curView[_type].splice(_index,1); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
130 |
updateFilters(); |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
131 |
//debouncedSaveChanges(); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
132 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
133 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
134 |
|
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
135 |
function getUpdates() { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
136 |
var _params = {}, |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
137 |
_curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
138 |
if (_curView.type == 'filter') { |
| 127 | 139 |
if (!(_curView.period[0] == gomNs.minYear && _curView.period[1] == gomNs.maxYear)) { |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
140 |
_params.period = _curView.period.join(','); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
141 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
142 |
if (_curView.tag.length) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
143 |
_params.label = _curView.tag.join(','); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
144 |
} |
| 127 | 145 |
if (_curView.country.length) { |
| 287 | 146 |
_params.country = decodeURIComponent(_curView.country.join(',')); |
| 127 | 147 |
} |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
148 |
$.getJSON(gomNs.urls['filter'], _params, updateDisplay); |
| 127 | 149 |
animLoad(); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
150 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
151 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
152 |
|
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
153 |
var debouncedGetUpdates = _.debounce(getUpdates, 300); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
154 |
|
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
155 |
function updatePeriod(_n, _val) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
156 |
var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
157 |
if (_curView.type == 'filter') { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
158 |
var _int = parseInt(_val); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
159 |
if (_int != NaN) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
160 |
if ((_n == 1 && _val >= _curView.period[0]) || (_n == 0 && _val <= _curView.period[1])) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
161 |
_curView.period[_n] = _int; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
162 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
163 |
updateFilters(); |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
164 |
//debouncedSaveChanges(); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
165 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
166 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
167 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
168 |
|
| 127 | 169 |
function removePeriod() { |
170 |
var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
|
171 |
if (_curView.type == 'filter') { |
|
172 |
_curView.period[0] = gomNs.minYear; |
|
173 |
_curView.period[1] = gomNs.maxYear; |
|
174 |
updateFilters(); |
|
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
175 |
//debouncedSaveChanges(); |
| 127 | 176 |
} |
177 |
} |
|
178 |
||
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
179 |
function changeSpan(_this) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
180 |
var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
181 |
if (_curView.type == 'filter') { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
182 |
if (!$(_this).children().length) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
183 |
var _el = document.createElement('input'), |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
184 |
_n = _this.id.split('_')[1]; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
185 |
_el.value = _curView.period[_n]; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
186 |
_el.style.width = $(_this).width() + 'px'; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
187 |
$(_el).focusout(function() { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
188 |
updatePeriod(_n, this.value); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
189 |
}).keypress(function(e) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
190 |
if (e.keyCode == 13) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
191 |
updatePeriod(_n, this.value); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
192 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
193 |
}); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
194 |
$(_this).html(_el); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
195 |
_el.focus(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
196 |
_el.select(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
197 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
198 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
199 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
200 |
|
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
201 |
function updateFilters(initial) { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
202 |
if(typeof initial==="undefined"){ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
203 |
initial = false; |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
204 |
} |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
205 |
var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
206 |
if (_curView.type != 'filter') { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
207 |
return; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
208 |
} |
| 338 | 209 |
// Prepare renkan link |
210 |
var url_renkan = $("#renkan-link").attr("href"); |
|
211 |
url_renkan = ((url_renkan.lastIndexOf("?")>=0) ? (url_renkan.substr(0, url_renkan.lastIndexOf("?"))) : url_renkan) + "?"; |
|
212 |
// Filter |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
213 |
var _htmFilters = '', |
| 127 | 214 |
_fl = _curView.tag.length, |
215 |
_cl = _curView.country.length; |
|
216 |
if (_curView.period[0] == gomNs.minYear && _curView.period[1] == gomNs.maxYear) { |
|
| 135 | 217 |
_htmFilters += '<li class="filperiod">'+gettext("Toutes periodes")+'</li>'; |
| 127 | 218 |
} else { |
| 135 | 219 |
_htmFilters += '<li class="filperiod">'+gettext("Periode :")+' <span class="spyr" id="sp_0" onclick="changeSpan(this);">' |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
220 |
+ _curView.period[0] |
| 135 | 221 |
+ '</span> ' + gettext('a')+' <span class="spyr" id="sp_1" onclick="changeSpan(this);">' |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
222 |
+ _curView.period[1] |
| 127 | 223 |
+ '</span><a href="#" class="remfil" onclick="removePeriod(); return false;">[x]</a></li>'; |
| 338 | 224 |
url_renkan += "period=" + _curView.period[0] + "," + _curView.period[1] |
| 127 | 225 |
} |
226 |
$("#handle_0").css({ |
|
227 |
"left" : yearToPx(_curView.period[0])+"px", |
|
228 |
}).attr("year", _curView.period[0]) |
|
229 |
.find(".handleinner") |
|
230 |
.css({ |
|
231 |
"margin-left" : "-20px" |
|
232 |
}); |
|
233 |
$("#handle_1").css({ |
|
234 |
"left" : yearToPx(_curView.period[1])+"px", |
|
235 |
}).attr("year", _curView.period[1]) |
|
236 |
.find(".handleinner") |
|
237 |
.css({ |
|
238 |
"margin-left" : "0" |
|
239 |
}); |
|
240 |
if (_cl) { |
|
| 338 | 241 |
url_renkan += "&country="; |
| 127 | 242 |
_htmFilters += _(_curView.country).map(function(_t, _i) { |
| 289 | 243 |
// dbpedia uri for renkan url |
244 |
url_renkan += "," + ( (typeof gomNs.countries == "object" && typeof gomNs.countries[_t] == "object") ? _t : decodeURIComponent(_t.match('[^/]+$')[0]).replace('_',' ')); |
|
245 |
// label for interface |
|
|
288
0bb9c29cd41d
renkan first step : link, views and get put for json
cavaliet
parents:
287
diff
changeset
|
246 |
var country_label = ( (typeof gomNs.countries == "object" && typeof gomNs.countries[_t] == "object") ? gomNs.countries[_t].properties.labels[gomNs.languageCode] : decodeURIComponent(_t.match('[^/]+$')[0]).replace('_',' ')); |
| 135 | 247 |
return '<li class="filcountry">'+gettext('Pays :')+' ' |
|
288
0bb9c29cd41d
renkan first step : link, views and get put for json
cavaliet
parents:
287
diff
changeset
|
248 |
+ country_label |
| 127 | 249 |
+ '<a href="#" class="remfil" onclick="removeFilter(\'country\',' |
250 |
+ _i |
|
251 |
+ '); return false;">[x]</a></li>'; |
|
252 |
}).join(""); |
|
|
288
0bb9c29cd41d
renkan first step : link, views and get put for json
cavaliet
parents:
287
diff
changeset
|
253 |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
254 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
255 |
if (_fl) { |
| 289 | 256 |
url_renkan += "&label="; |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
257 |
_htmFilters += _(_curView.tag).map(function(_t, _i) { |
|
288
0bb9c29cd41d
renkan first step : link, views and get put for json
cavaliet
parents:
287
diff
changeset
|
258 |
url_renkan += "," + _t; |
| 135 | 259 |
return '<li class="filtag">'+gettext('Tag :')+' ' |
260 |
+ '<span class="filtag_label">'+_t+'</span>' |
|
| 127 | 261 |
+ '<a href="#" class="remfil" onclick="removeFilter(\'tag\',' |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
262 |
+ _i |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
263 |
+ '); return false;">[x]</a></li>'; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
264 |
}).join(""); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
265 |
} |
|
288
0bb9c29cd41d
renkan first step : link, views and get put for json
cavaliet
parents:
287
diff
changeset
|
266 |
$("#renkan-link").attr("href",url_renkan); |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
267 |
if(!initial){ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
268 |
history.replaceState(null, null, url_renkan.substr(url_renkan.lastIndexOf("?"))); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
269 |
} |
| 145 | 270 |
$("#filters").html(_htmFilters).hide(); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
271 |
debouncedGetUpdates(); |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
272 |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
273 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
274 |
|
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
275 |
function displayContents(contentdata) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
276 |
if (contentdata && contentdata.length) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
277 |
var _htmlCl = '<ul id="contentlist">' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
278 |
+ contentdata.map(function(_d) { |
| 253 | 279 |
var _dsurl = gomNs.urls.datasheet.replace(/ID$/,_d.hda_id); |
280 |
var _html = '<li class="content-item"><h3><a href="' |
|
281 |
+ _dsurl |
|
282 |
+ '">' |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
283 |
+ _d.title |
| 314 | 284 |
+ '</a> <a class="mind-map-icon" href="' + gomNs.urls.renkan + '?notice=' + _d.hda_id + '" target="_blank">placeholder</a></h3>' |
| 127 | 285 |
+ ( typeof _d.coords == "object" ? |
286 |
'<div class="maplet"><img src="http://maps.googleapis.com/maps/api/staticmap?center=47,1.5&zoom=4&size=160x160&maptype=roadmap&markers=color:red%7C' |
|
287 |
+ _d.coords.latitude |
|
288 |
+ ',' |
|
289 |
+ _d.coords.longitude |
|
| 239 | 290 |
+ '&sensor=false" /><h4>' |
291 |
+ gettext('Localisation :') |
|
292 |
+ ' ' |
|
| 127 | 293 |
+ _d.coords.city_name |
294 |
+ '</h4></div>' |
|
295 |
: '') |
|
296 |
+ '<h4><a href="' |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
297 |
+ _d.url |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
298 |
+ '" target="_blank">' |
| 127 | 299 |
+ _d.url.replace(/(^.{40}).+(.{30}$)/m,'$1 … $2') |
| 253 | 300 |
+ '</a></h4><p><a href="' |
301 |
+ _dsurl |
|
302 |
+ '">' |
|
| 127 | 303 |
+ _d.description.replace(/(^.{0,160})([\s]|$)(.*)/,'$1…') |
| 253 | 304 |
+ '</a></p><ul class="content-tags">' |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
305 |
+ _d.tags.map(function(_t) { |
| 235 | 306 |
return '<li class="content-tag-item"><a href="#" onclick="addFilter(\'tag\', this.getAttribute(\'original-label\')); return false;" original-label="' |
| 168 | 307 |
+ _t.label |
308 |
+ '"' |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
309 |
+ (_t.match ? ' class="tagmatch"' : '') |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
310 |
+ '>' |
| 135 | 311 |
+ _t.translated_label |
| 315 | 312 |
+ '</a>' |
| 386 | 313 |
+ ' <a class="mind-map-icon-white" href="' + gomNs.urls.renkan + '?label=' + _t.label + '" target="_blank">placeholder</a></h3>' |
| 315 | 314 |
+ '</li>'; |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
315 |
}).join('') |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
316 |
/*+ '</ul><h4>'+gettext("Annotations")+'</h4><div class="content-annotation" contentid="' |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
317 |
+ _d.id |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
318 |
+ '">' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
319 |
+ ( gomNs.sessiondata.annotations[_d.id] && gomNs.sessiondata.annotations[_d.id].texte |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
320 |
? '<ul><li>' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
321 |
+ _.escape(gomNs.sessiondata.annotations[_d.id].texte).replace(/\n/gm,"</li><li>") |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
322 |
+ '</li>' |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
323 |
: ( gomNs.write_allowed ? '<ul><li>'+gettext("Annoter ce contenu")+'...</li></ul>' : '' ) )*/ |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
324 |
+ '</div>'; |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
325 |
/*if (gomNs.write_allowed) { |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
326 |
_(gomNs.sessiondata.views).each(function(_view, _k) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
327 |
if (_view.type == 'list') { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
328 |
_html += '<p><a href="#" class="addremlist" contentid="' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
329 |
+ _d.id |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
330 |
+ '" viewid="' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
331 |
+ _k |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
332 |
+ '">' |
|
194
8c597db6fab0
correct german translation and allow translation string with tokens.
ymh <ymh.work@gmail.com>
parents:
175
diff
changeset
|
333 |
+ str_format(( _view.list.indexOf(_d.id) == -1 ? gettext('Ajouter a {0}') : gettext('Retirer de {0}') ),'"'+ _.escape(_view.name)+ '"') |
|
8c597db6fab0
correct german translation and allow translation string with tokens.
ymh <ymh.work@gmail.com>
parents:
175
diff
changeset
|
334 |
+ '</a></p>' |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
335 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
336 |
}); |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
337 |
}*/ |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
338 |
_html += '</li>'; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
339 |
return _html; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
340 |
}).join('') |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
341 |
+ '</ul>'; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
342 |
$("#contents").html(_htmlCl).scrollTop(0); |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
343 |
/*$("a.addremlist").click(function() { |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
344 |
var _id = $(this).attr("contentid"), |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
345 |
_vid = |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
346 |
_view = gomNs.sessiondata.views[$(this).attr("viewid")], |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
347 |
_io = _view.list.indexOf(_id); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
348 |
if ( _io == -1) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
349 |
_view.list.push(_id); |
|
194
8c597db6fab0
correct german translation and allow translation string with tokens.
ymh <ymh.work@gmail.com>
parents:
175
diff
changeset
|
350 |
$(this).html(str_format(gettext('Retirer de {0}'),'"' + _.escape(_view.name) + '"' )); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
351 |
} else { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
352 |
_view.list.splice(_io, 1); |
|
194
8c597db6fab0
correct german translation and allow translation string with tokens.
ymh <ymh.work@gmail.com>
parents:
175
diff
changeset
|
353 |
$(this).html(str_format(gettext('Ajouter a {0}'),'"' + _.escape(_view.name) + '"')); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
354 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
355 |
if (gomNs.sessiondata.view == 1) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
356 |
showView(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
357 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
358 |
debouncedSaveChanges(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
359 |
return false; |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
360 |
});*/ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
361 |
/*if (gomNs.write_allowed) { |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
362 |
$("div.content-annotation").click(function() { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
363 |
if (this.children[0].tagName == 'UL') { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
364 |
var _el = document.createElement('textarea'), |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
365 |
_id = $(this).attr("contentid"); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
366 |
_el.innerHTML = (gomNs.sessiondata.annotations[_id] && gomNs.sessiondata.annotations[_id].texte) ? gomNs.sessiondata.annotations[_id].texte : ''; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
367 |
$(_el).focusout(function() { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
368 |
var _id = this.parentNode.attributes.contentid.nodeValue; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
369 |
if (!gomNs.sessiondata.annotations[_id]) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
370 |
gomNs.sessiondata.annotations[_id] = {}; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
371 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
372 |
gomNs.sessiondata.annotations[_id].texte = this.value; |
| 135 | 373 |
this.parentNode.innerHTML = '<ul><li>' + (this.value.length ? _.escape(gomNs.sessiondata.annotations[_id].texte).replace(/\n/gm,"</li><li>") : gettext('Annoter ce contenu')+'...' ) + '</ul>'; |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
374 |
debouncedSaveChanges(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
375 |
}); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
376 |
$(this).html(_el); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
377 |
_el.focus(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
378 |
_el.select(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
379 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
380 |
}); |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
381 |
}*/ |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
382 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
383 |
else { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
384 |
$("#contents").html(""); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
385 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
386 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
387 |
|
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
388 |
function updateDisplay(data) { |
| 127 | 389 |
animStop(); |
| 135 | 390 |
|
391 |
// translate filters |
|
392 |
$('.filtag_label').each(function(index, elt) { |
|
393 |
txt = $(this).text(); |
|
394 |
if(txt in data.tagtranslations) { |
|
395 |
$(this).text(data.tagtranslations[txt]); |
|
396 |
} |
|
397 |
}); |
|
| 145 | 398 |
$("#filters").show(); |
| 135 | 399 |
|
400 |
|
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
401 |
if (gomNs.dhmPaper) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
402 |
gomNs.dhmPaper.clear(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
403 |
} else { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
404 |
gomNs.dhmPaper = new Raphael("dateheat"); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
405 |
} |
| 135 | 406 |
$("#contentcount").html('<b>'+data.count+'</b> ' + ngettext('notice', 'notices', data.count)); |
| 131 | 407 |
if (!data.sparkline.length || data.sparkline[0].year != gomNs.minYear) { |
408 |
data.sparkline.splice(0,0,{"year": gomNs.minYear, "score": 0}); |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
409 |
} |
| 131 | 410 |
var _maxheat = _(data.sparkline).max(function(_d) { return parseInt(_d.score); }).score; |
411 |
_(data.sparkline).each(function(_d, _i) { |
|
412 |
var _nxt = (_i == data.sparkline.length - 1) ? (gomNs.maxYear + 1) : data.sparkline[_i + 1].year, |
|
413 |
_x1 = yearToPx(_d.year), |
|
414 |
_x2 = yearToPx(_nxt), |
|
415 |
_heat = _d.score / _maxheat; |
|
416 |
gomNs.dhmPaper.rect(_x1, 0, _x2 - _x1, 20).attr({ |
|
417 |
"fill" : getGradient(_heat), |
|
418 |
"stroke" : "none" |
|
419 |
}) |
|
420 |
}); |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
421 |
if (gomNs.sessiondata.view == 0) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
422 |
var _h0 = $("#handle_0").position().left, |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
423 |
_h1 = $("#handle_1").position().left; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
424 |
gomNs.dhmPaper.rect(Math.min(_h0, _h1) - 1, 0, Math.abs(_h0 - _h1) + 2, 20).attr({ |
| 132 | 425 |
"stroke" : "#cc0066", |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
426 |
"stroke-width" : "3" |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
427 |
}); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
428 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
429 |
if (data.tags.length) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
430 |
var _scores = _(data.tags).map(function(_d) { return parseInt(_d.score)}), |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
431 |
_maxTag = _(_scores).max(), |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
432 |
_minTag = Math.min(_(_scores).min(), _maxTag - 1), |
| 127 | 433 |
_scale = 10 / Math.sqrt(_maxTag - _minTag), |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
434 |
_htmlTc = '<ul id="tclist">' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
435 |
+ _(data.tags).map(function(_d) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
436 |
return '<li style="font-size:' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
437 |
+ parseInt(10 + _scale * Math.sqrt(_d.score - _minTag)) |
| 250 | 438 |
+ 'px;"><a href="#" onclick="addFilter(\'tag\', this.getAttribute(\'original-label\')); return false;" original-label="' |
| 168 | 439 |
+ _d.label |
440 |
+'"' |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
441 |
+ (_d.match ? ' class="tagmatch"' : '') |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
442 |
+ '>' |
| 135 | 443 |
+ _d.translated_label |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
444 |
+ '</a></li>'; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
445 |
}).join('') |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
446 |
+ '</ul>'; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
447 |
$("#tagcloud").html(_htmlTc); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
448 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
449 |
else { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
450 |
$("#tagcloud").html("<h4>Pas de mots-clés trouvés</h4>"); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
451 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
452 |
displayContents(data.contents); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
453 |
if (gomNs.countries && data.countries) { |
| 127 | 454 |
var _max = Math.max(1, _(data.countries).max()); |
455 |
_(gomNs.countries).each(function(_country, _k) { |
|
| 287 | 456 |
_k = decodeURIComponent(_k); |
| 127 | 457 |
var _val = data.countries[_k] || 0, |
| 131 | 458 |
_fill = getGradient(_val/_max); |
| 127 | 459 |
switch(gomNs.mappingLibrary) { |
460 |
case 'gmaps': |
|
461 |
_(_country.gPolygons).each(function(_p) { |
|
462 |
_p.setOptions({ |
|
463 |
"fillColor" : _fill, |
|
| 131 | 464 |
"fillOpacity" : 1 |
| 127 | 465 |
}); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
466 |
}); |
| 127 | 467 |
break; |
468 |
case 'leaflet': |
|
469 |
_country.layer.setStyle({ |
|
470 |
"fillColor" : _fill, |
|
| 131 | 471 |
"fillOpacity" : 1 |
| 127 | 472 |
}) |
473 |
break; |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
474 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
475 |
}); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
476 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
477 |
if (data.disciplines) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
478 |
var _disc = data.disciplines.filter(function(_d) { |
| 131 | 479 |
return +_d.score > 0; |
480 |
}), |
|
481 |
_max = _disc.reduce(function(_a, _b) { |
|
482 |
return Math.max(_a,_b.score) |
|
483 |
}, 1); |
|
484 |
$("#disciplines").html( |
|
485 |
'<ul class="disc-ul">' |
|
486 |
+ _disc.map(function(_d) { |
|
487 |
var _col = getGradient(_d.score / _max); |
|
| 250 | 488 |
return '<li class="disc-li" onclick="addFilter(\'tag\', this.getAttribute(\'original-label\')); return false;" original-label="' |
| 168 | 489 |
+ _d.label |
490 |
+ '"><div class="disc-label"><a href="#">' |
|
| 135 | 491 |
+ _d.translated_label |
| 132 | 492 |
+ '</a></div><div class="disc-bar" style="background:' |
| 131 | 493 |
+ _col |
494 |
+ '; width:' |
|
495 |
+ Math.floor(120 * (_d.score / _max)) |
|
496 |
+ 'px">' |
|
497 |
}).join("") |
|
498 |
+ '</ul>' |
|
499 |
) |
|
500 |
|
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
501 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
502 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
503 |
|
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
504 |
/*function saveChanges() { |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
505 |
if (gomNs.sessionid && gomNs.sessionkey) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
506 |
$.getJSON(gomNs.urls['session_info'], { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
507 |
"sessionid" : gomNs.sessionid, |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
508 |
"sessionkey" : gomNs.sessionkey, |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
509 |
"data" : JSON.stringify(gomNs.sessiondata), |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
510 |
}); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
511 |
} |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
512 |
}*/ |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
513 |
|
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
514 |
//var debouncedSaveChanges = _.debounce(saveChanges, 3000); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
515 |
|
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
516 |
/*function changeView(nview) { |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
517 |
var _curView = gomNs.sessiondata.views[nview]; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
518 |
if (_curView.type == 'list' && (!_curView.list || !_curView.list.length)) { |
| 135 | 519 |
alert(gettext("La liste de contenus est vide ! Ajoutez des contenus pour afficher la liste !")); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
520 |
} else { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
521 |
gomNs.sessiondata.view = nview; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
522 |
debouncedSaveChanges(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
523 |
showView(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
524 |
} |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
525 |
}*/ |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
526 |
|
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
527 |
function showView(initial) { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
528 |
if(typeof initial==="undefined"){ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
529 |
initial = false; |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
530 |
} |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
531 |
$(".lienvue").removeClass("actif"); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
532 |
$("#view_" + gomNs.sessiondata.view).addClass("actif"); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
533 |
var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
534 |
$("#titrevue").val(_curView.name); |
| 135 | 535 |
$("#bloc_gestvue h2").html(gettext('Gerer la vue')+' "' + _.escape(_curView.name) + '"'); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
536 |
$("div.bloc").show(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
537 |
$("#widgetlist input").prop("checked",true); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
538 |
_(_curView.hiddenWidgets).each(function(_w) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
539 |
$("#chbx_" + _w).prop("checked",false); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
540 |
$("#" + _w).hide(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
541 |
}); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
542 |
$("#notes").html( _curView.notes |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
543 |
? '<ul><li>' + _.escape(_curView.notes).replace(/\n/gm,"</li><li>") + '</li></ul>' |
| 135 | 544 |
: ( gomNs.write_allowed ? '<ul><li>'+gettext('Annoter cette vue')+'...</li></ul>' : '' ) ); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
545 |
switch(_curView.type) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
546 |
case 'list': |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
547 |
$("#bandefiltre, .handle").hide(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
548 |
$.getJSON(gomNs.urls['filter'], { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
549 |
contentlist: _curView.list.join(',') |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
550 |
}, updateDisplay); |
| 127 | 551 |
animLoad(); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
552 |
break; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
553 |
case 'filter': |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
554 |
$("#bandefiltre, .handle").show(); |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
555 |
updateFilters(initial); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
556 |
break; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
557 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
558 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
559 |
|
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
560 |
/*function displayViewList() { |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
561 |
$("#ongletsvues").html(gomNs.sessiondata.views.map(function(_v, _k) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
562 |
return '<li class="lienvue" id="view_' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
563 |
+ _k |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
564 |
+ '" onclick="changeView(' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
565 |
+ _k |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
566 |
+ '); return false;"><a href="#">' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
567 |
+ _.escape(_v.name) |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
568 |
+ '</a></li>'; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
569 |
}).join("")) |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
570 |
}*/ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
571 |
|
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
572 |
|
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
573 |
function getURLParameter(name) { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
574 |
return decodeURI( |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
575 |
(RegExp(name + '=' + '(.+?)(&|$)').exec(document.location.search)||[,null])[1] |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
576 |
); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
577 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
578 |
|
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
579 |
function getInitialView() { |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
580 |
var _urlParam = { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
581 |
period: [ gomNs.minYear, gomNs.maxYear ], |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
582 |
country: [], |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
583 |
tag: [] |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
584 |
}; |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
585 |
if (document.location.search) { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
586 |
var p = decodeURIComponent(getURLParameter("period")); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
587 |
if(p!="null"){ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
588 |
p = p.split(","); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
589 |
} |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
590 |
else{ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
591 |
p = [ gomNs.minYear, gomNs.maxYear ]; |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
592 |
} |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
593 |
var c = decodeURIComponent(getURLParameter("country")); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
594 |
if(c!="null"){ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
595 |
c = c.split(","); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
596 |
c = c.filter(function(n){ return n!="" }); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
597 |
} |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
598 |
else{ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
599 |
c = []; |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
600 |
} |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
601 |
var t = decodeURIComponent(getURLParameter("label")); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
602 |
if(t!="null"){ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
603 |
t = t.split(","); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
604 |
t = t.filter(function(n){ return n!="" }); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
605 |
} |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
606 |
else{ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
607 |
t = []; |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
608 |
} |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
609 |
_urlParam.period = p; |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
610 |
_urlParam.country = c; |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
611 |
_urlParam.tag = t; |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
612 |
} |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
613 |
// Not getting session info anymore, build data object |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
614 |
var data = { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
615 |
data: { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
616 |
view: 0, |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
617 |
views: [ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
618 |
{ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
619 |
type: "filter", |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
620 |
period: _urlParam.period, |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
621 |
country: _urlParam.country, |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
622 |
tag: _urlParam.tag |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
623 |
} |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
624 |
] |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
625 |
} |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
626 |
}; |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
627 |
|
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
628 |
/*gomNs.sessionid = data.sessionid; |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
629 |
if (data.sessionkey) { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
630 |
gomNs.sessionkey = data.sessionkey; |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
631 |
} |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
632 |
gomNs.write_allowed = data.write_allowed; |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
633 |
if (data.write_allowed) { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
634 |
$("#partagerw").show(); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
635 |
} else { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
636 |
$("#partagerw").hide(); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
637 |
}*/ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
638 |
//var _baseUrl = document.location.href.split("#")[0]; |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
639 |
//gomNs.hash = "#" + data.sessionid + (data.sessionkey ? (':' + data.sessionkey) : ''); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
640 |
//document.location.hash = gomNs.hash; |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
641 |
gomNs.sessiondata = typeof data.data == "string" ? JSON.parse(data.data) : (typeof data.data == "object" ? data.data : {}); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
642 |
/*if (!gomNs.sessiondata.title) { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
643 |
gomNs.sessiondata.title = gettext('Nouvelle session'); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
644 |
}*/ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
645 |
if (!gomNs.sessiondata.views) { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
646 |
gomNs.sessiondata.views = []; |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
647 |
} |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
648 |
/*if (!gomNs.sessiondata.views.length) { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
649 |
addView( 'filter', gettext('Mes resultats de recherche') ); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
650 |
addView( 'list', gettext('Ma liste') ); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
651 |
} |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
652 |
if (!gomNs.sessiondata.annotations) { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
653 |
gomNs.sessiondata.annotations = {}; |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
654 |
} |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
655 |
if (data.write_allowed) { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
656 |
$("#bloc_gestvue").show(); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
657 |
} else { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
658 |
$("#bloc_gestvue").hide(); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
659 |
} |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
660 |
$("#sessionname").html(_.escape(gomNs.sessiondata.title) |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
661 |
+ ( data.write_allowed ? '' : '<span class="lectseul"> ('+gettext("lecture seule")+')</span>' ) ); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
662 |
gomNs.hrefinterval = setInterval(function() { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
663 |
if (document.location.hash != gomNs.hash) { |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
664 |
clearInterval(gomNs.hrefinterval); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
665 |
getInitialView(); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
666 |
} |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
667 |
}, 500);*/ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
668 |
//displayViewList(); |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
669 |
showView(true); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
670 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
671 |
|
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
672 |
/*function changeSessionTitle(title) { |
|
171
0c96f2c5603e
correct bug of escaping session name
ymh <ymh.work@gmail.com>
parents:
168
diff
changeset
|
673 |
gomNs.sessiondata.title = title; |
|
0c96f2c5603e
correct bug of escaping session name
ymh <ymh.work@gmail.com>
parents:
168
diff
changeset
|
674 |
$("#sessionname").html(_.escape(gomNs.sessiondata.title)); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
675 |
debouncedSaveChanges(); |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
676 |
}*/ |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
677 |
|
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
678 |
/*function addView(viewtype, viewname) { |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
679 |
var _content = { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
680 |
type: viewtype, |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
681 |
name: viewname, |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
682 |
hiddenWidgets: [], |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
683 |
}; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
684 |
switch(viewtype) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
685 |
case 'filter': |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
686 |
_content.period = [ gomNs.minYear, gomNs.maxYear ]; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
687 |
_content.tag = []; |
| 127 | 688 |
_content.country = []; |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
689 |
gomNs.sessiondata.view = gomNs.sessiondata.views.length; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
690 |
break; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
691 |
case 'list': |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
692 |
_content.list = []; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
693 |
break; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
694 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
695 |
gomNs.sessiondata.views.push(_content); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
696 |
debouncedSaveChanges(); |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
697 |
}*/ |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
698 |
|
| 127 | 699 |
function animLoad() { |
| 132 | 700 |
var _d = $("#waiting"), |
| 127 | 701 |
_w = _d.width(), |
702 |
_h = _d.height(), |
|
703 |
_r = .33*Math.min(_w,_h), |
|
704 |
_count = 24, |
|
705 |
_html = '', |
|
706 |
_f = 2* Math.PI / _count; |
|
707 |
_d.empty().show(); |
|
708 |
for (var _i = 0; _i < _count; _i++) { |
|
709 |
var _x = Math.floor(Math.sin(_i * _f)*_r + _w/2), |
|
710 |
_y = Math.floor(-Math.cos(_i * _f)*_r + _h/2), |
|
711 |
_el = document.createElement('div'); |
|
| 132 | 712 |
_el.className = 'waittick'; |
| 127 | 713 |
_d.append(_el); |
714 |
$(_el).css({ |
|
715 |
"left": _x + "px", |
|
| 132 | 716 |
"top": _y + "px" |
| 127 | 717 |
}).delay(200*_i).fadeIn(400).delay(600 + 200* _i).fadeOut(); |
718 |
} |
|
719 |
} |
|
720 |
||
721 |
function animStop() { |
|
| 132 | 722 |
$("#waiting").empty().fadeOut(); |
| 127 | 723 |
} |
| 250 | 724 |
function ellipse(_text, _length) { |
725 |
var _rgxp = new RegExp('(^.{0,' + _length + '})([\s]|$)(.*)') |
|
726 |
return _text.replace(/(\n|\r|\r\n)/mg,' ').trim().replace(_rgxp,'$1…') |
|
727 |
} |
|
728 |
||
729 |
function highlightText(_text, _search) { |
|
730 |
var _rgxp = new RegExp('(' + _search.replace(/(\W)/g, '\\$1') + ')','gi'); |
|
731 |
return _text.replace(_rgxp, '<strong>$1</strong>'); |
|
732 |
} |
|
733 |
||
734 |
function wikipediaUrl(_text) { |
|
735 |
return "http://" + gomNs.languageCode + ".wikipedia.org/wiki/" + encodeURI(_text.replace(/ /g,'_')) |
|
736 |
} |
|
737 |
||
738 |
wpTemplate = _.template( |
|
739 |
'<h4 class="wptitle"><% print(highlightText(item.label, inputvalue)); %></h4><% if (item.thumbnail) { %><img class="wpimg" src="<%-item.thumbnail%>" /><% };' |
|
740 |
+ ' if (item.abstract) { %><p class="wpabstract"><% print(ellipse(item.abstract,250))%></p><p class="wpsource"><a href="<% print(wikipediaUrl(item.label)) %>" target="_blank"><% print(gettext("Source : Wikipédia")) %></a></p><% }; %><div class="clear"></div>' |
|
741 |
); |
|
742 |
||
743 |
acTemplate = _.template( |
|
744 |
'<a><span class="acnb"><%- item.nb %></span><h4 class="actitle"><% print(highlightText(item.label, inputvalue)); %></h4></a>' |
|
745 |
); |
|
| 127 | 746 |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
747 |
$(document).ready(function() { |
| 127 | 748 |
switch(gomNs.mappingLibrary) { |
749 |
case 'gmaps': |
|
750 |
gomNs.map = new google.maps.Map(document.getElementById("map"), |
|
751 |
{ |
|
752 |
center: new google.maps.LatLng(30, 0), |
|
753 |
zoom: 1, |
|
754 |
mapTypeId: google.maps.MapTypeId.SATELLITE |
|
755 |
}); |
|
756 |
$.getJSON(gomNs.urls['countries'], showCountriesGmap); |
|
757 |
break; |
|
758 |
case 'leaflet': |
|
759 |
gomNs.map = new L.Map('map', { |
|
760 |
center: new L.LatLng(30, 0), |
|
761 |
zoom: 1 |
|
762 |
}); |
|
| 131 | 763 |
//gomNs.map.addLayer(new L.TileLayer("http://s3.amazonaws.com/com.modestmaps.bluemarble/{z}-r{y}-c{x}.jpg", {maxZoom: 9})); |
| 127 | 764 |
$.getJSON(gomNs.urls['countries'], showCountriesLeaflet); |
765 |
break; |
|
766 |
} |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
767 |
var _html = gomNs.displayedDates.map(function(_v) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
768 |
return '<li style="left: ' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
769 |
+ parseInt(yearToPx(_v)) |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
770 |
+ 'px"><div class="datelabel">' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
771 |
+ _v |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
772 |
+ '</div></li>' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
773 |
}).join(''); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
774 |
$("#dates").html(_html); |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
775 |
/*$("#apartager").click(function() { |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
776 |
var _pu = $("#partageurls"); |
| 132 | 777 |
if (_pu.is(":visible")) { |
778 |
$(this).removeClass("actif"); |
|
779 |
} else { |
|
780 |
$(this).addClass("actif"); |
|
781 |
$("#partagero").addClass("actif"); |
|
782 |
$("#partagerw").removeClass("actif"); |
|
783 |
var _url = document.location.href.split("#")[0] + "#" + gomNs.sessionid; |
|
| 151 | 784 |
$("#zc-partageinput").val( _url.replace(/^(.{30}).{3,1000}(.{20})$/,'$1 … $2') ); |
| 132 | 785 |
} |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
786 |
$(this).attr("class",_pu.is(":visible") ? "" : "actif"); |
| 132 | 787 |
_pu.slideToggle(function() { |
788 |
if ($(this).is(":visible")) { |
|
789 |
if (typeof gomNs.clip == "undefined") { |
|
790 |
gomNs.clip = new ZeroClipboard.Client(); |
|
791 |
gomNs.clip.setHandCursor( true ); |
|
792 |
gomNs.clip.glue('zc-partageinput'); |
|
793 |
} |
|
794 |
gomNs.clip.show(); |
|
795 |
gomNs.clip.setText( _url ); |
|
796 |
} else { |
|
797 |
gomNs.clip.hide(); |
|
798 |
} |
|
799 |
}); |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
800 |
return false; |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
801 |
});*/ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
802 |
/*$("#partagero").click(function() { |
| 132 | 803 |
$("#partagero").addClass("actif"); |
804 |
$("#partagerw").removeClass("actif"); |
|
805 |
var _url = document.location.href.split("#")[0] + "#" + gomNs.sessionid; |
|
| 151 | 806 |
$("#zc-partageinput").val( _url.replace(/^(.{30}).{3,1000}(.{20})$/,'$1 … $2') ); |
| 132 | 807 |
gomNs.clip.setText( _url ); |
808 |
return false; |
|
809 |
}); |
|
810 |
$("#partagerw").click(function() { |
|
811 |
$("#partagerw").addClass("actif"); |
|
812 |
$("#partagero").removeClass("actif"); |
|
813 |
var _url = document.location.href.split("#")[0] + gomNs.hash; |
|
| 151 | 814 |
$("#zc-partageinput").val( _url.replace(/^(.{30}).{3,1000}(.{20})$/,'$1 … $2') ); |
| 132 | 815 |
gomNs.clip.setText( _url ); |
816 |
return false; |
|
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
817 |
});*/ |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
818 |
$(".handle").draggable({ |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
819 |
"axis" : "x", |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
820 |
"containment" : "parent", |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
821 |
"drag": function() { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
822 |
$(this).attr("year",parseInt(pxToYear($(this).position().left))); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
823 |
var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
824 |
if (_curView.type == 'filter') { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
825 |
var _h0 = $("#handle_0"), |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
826 |
_h1 = $("#handle_1"), |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
827 |
_h0v = parseInt(_h0.attr("year")), |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
828 |
_h1v = parseInt(_h1.attr("year")); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
829 |
_curView.period = [ Math.min(_h0v, _h1v), Math.max(_h0v, _h1v)]; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
830 |
_h0.find(".handleinner").css({ |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
831 |
"margin-left" : (_h0v>_h1v ? "0" : "-20px") |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
832 |
}) |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
833 |
_h1.find(".handleinner").css({ |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
834 |
"margin-left" : (_h1v>_h0v ? "0" : "-20px") |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
835 |
}) |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
836 |
updateFilters(); |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
837 |
//debouncedSaveChanges(); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
838 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
839 |
} |
| 235 | 840 |
}); |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
841 |
/*$("#sessionname").click(function() { |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
842 |
if (gomNs.write_allowed && !$(this).children().length) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
843 |
var _el = document.createElement('input'); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
844 |
_el.value = gomNs.sessiondata.title; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
845 |
$(_el).focusout(function() { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
846 |
changeSessionTitle(this.value); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
847 |
}).keypress(function(e) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
848 |
if (e.keyCode == 13) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
849 |
changeSessionTitle(this.value); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
850 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
851 |
}); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
852 |
$(this).html(_el); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
853 |
_el.focus(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
854 |
_el.select(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
855 |
} |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
856 |
});*/ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
857 |
/*$("#titrevue").keyup(function() { |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
858 |
var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
859 |
_curView.name = $(this).val(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
860 |
$("#view_" + gomNs.sessiondata.view + " a").html(_.escape(_curView.name)) |
| 135 | 861 |
$("#bloc_gestvue h2").html(gettext('Gerer la vue')+' "' + _.escape(_curView.name) + '"'); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
862 |
debouncedSaveChanges(); |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
863 |
});*/ |
|
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
864 |
/*$("#notes").click(function() { |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
865 |
if (gomNs.write_allowed) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
866 |
if (this.children[0].tagName == 'UL') { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
867 |
var _el = document.createElement('textarea'), |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
868 |
_curView = gomNs.sessiondata.views[gomNs.sessiondata.view]; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
869 |
_el.innerHTML = _curView.notes ? _curView.notes : ''; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
870 |
$(_el).focusout(function() { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
871 |
_curView.notes = this.value; |
| 135 | 872 |
this.parentNode.innerHTML = '<ul><li>' + (this.value.length ? _.escape(_curView.notes).replace(/\n/gm,"</li><li>") : gettext('Annoter cette vue')+'...' ) + '</ul>'; |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
873 |
debouncedSaveChanges(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
874 |
}); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
875 |
$(this).html(_el); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
876 |
_el.focus(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
877 |
_el.select(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
878 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
879 |
} |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
880 |
});*/ |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
881 |
getInitialView(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
882 |
$(".barrebloc").click(function() { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
883 |
$(this).next().slideToggle(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
884 |
}); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
885 |
gomNs.widgetList = []; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
886 |
var _html = '<ul id="widgetlist">'; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
887 |
$("div.bloc").each(function() { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
888 |
gomNs.widgetList.push(this.id); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
889 |
_html += '<li><input type="checkbox" id="chbx_' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
890 |
+ this.id |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
891 |
+ '" /><label>' + $(this).find("h2").html() + '</label></li>' |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
892 |
}); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
893 |
_html + '</ul>'; |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
894 |
/*$("#gestvue").append(_html); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
895 |
$("#nouvellevue").click(function() { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
896 |
$("#plusdevues").slideToggle(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
897 |
return false; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
898 |
}) |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
899 |
$("#widgetlist input").change(function() { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
900 |
var _newWL = []; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
901 |
$("#widgetlist input").each(function(_k, _e) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
902 |
var _id = _e.id.substr(5); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
903 |
if (!$(_e).prop("checked")) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
904 |
$("#" + _id).hide(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
905 |
_newWL.push(_id); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
906 |
} else { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
907 |
$("#" + _id).show(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
908 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
909 |
}); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
910 |
gomNs.sessiondata.views[gomNs.sessiondata.view].hiddenWidgets = _newWL; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
911 |
debouncedSaveChanges(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
912 |
}); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
913 |
$("#nouv_resrech").click(function() { |
| 135 | 914 |
var _txt = prompt(gettext("Comment souhaitez-vous nommer votre nouvelle vue ?"),gettext("Nouveaux resultats de recherche")); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
915 |
if (_txt !== null) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
916 |
addView('filter', _txt); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
917 |
displayViewList(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
918 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
919 |
return false; |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
920 |
}); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
921 |
$("#nouv_liste").click(function() { |
| 135 | 922 |
var _txt = prompt(gettext("Comment souhaitez-vous nommer votre nouvelle vue ?"),gettext("Nouvelle liste")); |
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
923 |
if (_txt !== null) { |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
924 |
addView('list', _txt); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
925 |
displayViewList(); |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
926 |
} |
|
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
927 |
return false; |
|
341
9a854bb09f34
big change : facette urls manages with location search parameters, and not anymore with session info.
cavaliet
parents:
338
diff
changeset
|
928 |
});*/ |
| 250 | 929 |
$(" #tagform ").submit(function() { |
930 |
return false; |
|
931 |
}); |
|
932 |
var cache = {}, /*CACHE => http://jqueryui.com/demos/autocomplete/#remote-with-cache */ |
|
933 |
lastXhr; |
|
934 |
$( "#tagsearch" ).autocomplete({ |
|
935 |
source: function( request, response ) { |
|
936 |
var term = request.term; |
|
937 |
if ( term in cache ) { |
|
938 |
$("#tagsearch").removeClass("waiting"); |
|
939 |
response( cache[ term ] ); |
|
940 |
return; |
|
941 |
} |
|
942 |
$("#tagsearch").addClass("waiting"); |
|
943 |
lastXhr = $.getJSON( gomNs.urls['tag_search'], request, function( data, status, xhr ) { |
|
944 |
cache[ term ] = data; |
|
945 |
if ( xhr === lastXhr ) { |
|
946 |
response( data ); |
|
947 |
$("#tagsearch").removeClass("waiting"); |
|
948 |
} |
|
949 |
}); |
|
950 |
}, |
|
951 |
minLength: ( gomNs.languageCode == 'ja' ? 1 : 2 ), |
|
952 |
focus: function( event, ui ) { |
|
953 |
$(".wpinfo").html(wpTemplate({ |
|
954 |
item: ui.item, |
|
955 |
inputvalue: $("#tagsearch").val() |
|
956 |
})); |
|
957 |
}, |
|
958 |
select: function( event, ui ) { |
|
959 |
addFilter('tag', ui.item.original_label); |
|
960 |
} |
|
961 |
}) |
|
| 284 | 962 |
.data("ui-autocomplete")._renderItem = function(ul, item) { |
| 250 | 963 |
var _contents = acTemplate({ |
964 |
item: item, |
|
965 |
inputvalue: $("#tagsearch").val() |
|
966 |
}); |
|
967 |
return $( "<li>" ) |
|
968 |
.data( "item.autocomplete", item ) |
|
969 |
.html( _contents ) |
|
970 |
.appendTo( ul ); |
|
971 |
}; |
|
|
119
e3ebe3545f72
first implementation of django version.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
972 |
}); |