diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-11-11 19:17:17 +0100 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-11-11 19:17:17 +0100 |
| commit | 7523a633d93a2506f74dea899e43a8ae4abe1ea3 (patch) | |
| tree | c366379b171263dc5fa7673981197e93c5f6f3f8 /static/halfnarp.js | |
| parent | bfa1dfa2b79396f8bcc549c3a506105d097ee0b0 (diff) | |
Serve 40C3
Diffstat (limited to 'static/halfnarp.js')
| -rw-r--r-- | static/halfnarp.js | 103 |
1 files changed, 80 insertions, 23 deletions
diff --git a/static/halfnarp.js b/static/halfnarp.js index e40c84e..aac34e4 100644 --- a/static/halfnarp.js +++ b/static/halfnarp.js | |||
| @@ -102,14 +102,35 @@ function redraw_calendar(myuid, ids) { | |||
| 102 | } | 102 | } |
| 103 | }); | 103 | }); |
| 104 | calendar += 'END:VCALENDAR\r\n'; | 104 | calendar += 'END:VCALENDAR\r\n'; |
| 105 | $('.export-url-a').attr( 'href', "data:text/calendar;filename=39C3.ics," + encodeURIComponent(calendar) ); | 105 | $('.export-url-a').attr( 'href', "data:text/calendar;filename=40C3.ics," + encodeURIComponent(calendar) ); |
| 106 | $('.export-url').removeClass( 'hidden' ); | 106 | $('.export-url').removeClass( 'hidden' ); |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | function update_event_state(elem) { | ||
| 110 | elem.setAttribute( | ||
| 111 | 'aria-pressed', | ||
| 112 | elem.classList.contains('selected') ? 'true' : 'false' | ||
| 113 | ); | ||
| 114 | } | ||
| 115 | |||
| 116 | function update_size_aria() { | ||
| 117 | document.querySelector('.vsmallboxes') | ||
| 118 | .setAttribute('aria-pressed', | ||
| 119 | document.body.classList.contains('size-small')); | ||
| 120 | |||
| 121 | document.querySelector('.vmediumboxes') | ||
| 122 | .setAttribute('aria-pressed', | ||
| 123 | document.body.classList.contains('size-medium')); | ||
| 124 | |||
| 125 | document.querySelector('.vlargeboxes') | ||
| 126 | .setAttribute('aria-pressed', | ||
| 127 | document.body.classList.contains('size-large')); | ||
| 128 | } | ||
| 129 | |||
| 109 | function do_the_halfnarp() { | 130 | function do_the_halfnarp() { |
| 110 | // var halfnarpAPI = 'talks_36C3.json'; | 131 | // var halfnarpAPI = 'talks_36C3.json'; |
| 111 | var halfnarpAPI = '/-/talkpreferences'; | 132 | var halfnarpAPI = '/-/talkpreferences'; |
| 112 | var halfnarpCorrs = 'corr_array_39c3.json'; | 133 | var halfnarpCorrs = 'corr_array_40c3.json'; |
| 113 | var halfnarpPubAPI = halfnarpAPI + '/public/'; | 134 | var halfnarpPubAPI = halfnarpAPI + '/public/'; |
| 114 | var isTouch = (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0)); | 135 | var isTouch = (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0)); |
| 115 | window.top.all_events = new Object(); | 136 | window.top.all_events = new Object(); |
| @@ -117,6 +138,8 @@ function do_the_halfnarp() { | |||
| 117 | var myuid, mypid, newfriend = new Object(); | 138 | var myuid, mypid, newfriend = new Object(); |
| 118 | var allhours = ['10', '11','12','13','14','15','16','17','18','19','20','21','22','23','00','01','02','03']; | 139 | var allhours = ['10', '11','12','13','14','15','16','17','18','19','20','21','22','23','00','01','02','03']; |
| 119 | 140 | ||
| 141 | update_size_aria(); | ||
| 142 | |||
| 120 | $('.narpr_done').click( function(ev) { | 143 | $('.narpr_done').click( function(ev) { |
| 121 | $('.narpr').toggleClass('hidden', true); | 144 | $('.narpr').toggleClass('hidden', true); |
| 122 | if (!window.narpr_alerted) { | 145 | if (!window.narpr_alerted) { |
| @@ -157,13 +180,17 @@ function do_the_halfnarp() { | |||
| 157 | $('.narpr').on({ 'touchend' : function(ev) { | 180 | $('.narpr').on({ 'touchend' : function(ev) { |
| 158 | if (!window.touch_valid) | 181 | if (!window.touch_valid) |
| 159 | return; | 182 | return; |
| 183 | var ev = $('#event_'+window.narpr_event); | ||
| 160 | if (window.touch_curX > window.touch_startX + 100) { | 184 | if (window.touch_curX > window.touch_startX + 100) { |
| 161 | $('#event_'+window.narpr_event).toggleClass('selected', true); | 185 | ev.toggleClass('selected', true); |
| 186 | update_event_state(ev[0]); | ||
| 162 | set_random_event(); | 187 | set_random_event(); |
| 163 | } | 188 | } |
| 164 | if (window.touch_curX < window.touch_startX - 100) { | 189 | if (window.touch_curX < window.touch_startX - 100) { |
| 165 | $('#event_'+window.narpr_event).toggleClass('selected', false); | 190 | |
| 166 | $('#event_'+window.narpr_event).toggleClass('rejected', true); | 191 | ev.toggleClass('selected', false); |
| 192 | ev.toggleClass('rejected', true); | ||
| 193 | update_event_state(ev[0]); | ||
| 167 | set_random_event(); | 194 | set_random_event(); |
| 168 | } | 195 | } |
| 169 | 196 | ||
| @@ -179,8 +206,8 @@ function do_the_halfnarp() { | |||
| 179 | return $(this).attr('event_id'); | 206 | return $(this).attr('event_id'); |
| 180 | }).get(); | 207 | }).get(); |
| 181 | try { | 208 | try { |
| 182 | localStorage['39C3-halfnarp'] = ids; | 209 | localStorage['40C3-halfnarp'] = ids; |
| 183 | myapi = localStorage.getItem('39C3-halfnarp-api'); | 210 | myapi = localStorage.getItem('40C3-halfnarp-api'); |
| 184 | if (myapi) { | 211 | if (myapi) { |
| 185 | myapi = myapi.replace(/.*?:\//g, ""); | 212 | myapi = myapi.replace(/.*?:\//g, ""); |
| 186 | myapi = 'https:/' + myapi.replace(/.*?:\//g, ""); | 213 | myapi = 'https:/' + myapi.replace(/.*?:\//g, ""); |
| @@ -207,9 +234,9 @@ function do_the_halfnarp() { | |||
| 207 | $('.info').text('submitted'); | 234 | $('.info').text('submitted'); |
| 208 | $('.info').removeClass('hidden'); | 235 | $('.info').removeClass('hidden'); |
| 209 | try { | 236 | try { |
| 210 | localStorage['39C3-halfnarp-api'] = data['update_url']; | 237 | localStorage['40C3-halfnarp-api'] = data['update_url']; |
| 211 | localStorage['39C3-halfnarp-pid'] = mypid = data['hashed_uid']; | 238 | localStorage['40C3-halfnarp-pid'] = mypid = data['hashed_uid']; |
| 212 | localStorage['39C3-halfnarp-uid'] = myuid = data['uid']; | 239 | localStorage['40C3-halfnarp-uid'] = myuid = data['uid']; |
| 213 | window.location.hash = mypid; | 240 | window.location.hash = mypid; |
| 214 | } catch(err) {} | 241 | } catch(err) {} |
| 215 | }, 'json' ).fail(function() { | 242 | }, 'json' ).fail(function() { |
| @@ -225,9 +252,9 @@ function do_the_halfnarp() { | |||
| 225 | contentType: "application/json", | 252 | contentType: "application/json", |
| 226 | dataType: 'json', | 253 | dataType: 'json', |
| 227 | }).done(function(data) { | 254 | }).done(function(data) { |
| 228 | localStorage['39C3-halfnarp-uid'] = myuid = data['uid']; | 255 | localStorage['40C3-halfnarp-uid'] = myuid = data['uid']; |
| 229 | if( localStorage['39C3-halfnarp-pid'] ) { | 256 | if( localStorage['40C3-halfnarp-pid'] ) { |
| 230 | window.location.hash = localStorage['39C3-halfnarp-pid']; | 257 | window.location.hash = localStorage['40C3-halfnarp-pid']; |
| 231 | } | 258 | } |
| 232 | $('.info').text('updated'); | 259 | $('.info').text('updated'); |
| 233 | $('.info').removeClass('hidden'); | 260 | $('.info').removeClass('hidden'); |
| @@ -254,28 +281,42 @@ function do_the_halfnarp() { | |||
| 254 | document.querySelectorAll('.event').forEach(elem => elem.style.display = "initial"); | 281 | document.querySelectorAll('.event').forEach(elem => elem.style.display = "initial"); |
| 255 | }; | 282 | }; |
| 256 | 283 | ||
| 284 | document.querySelectorAll( | ||
| 285 | '.vtrack, .vlang, .vsmallboxes, .vmediumboxes, .vlargeboxes' | ||
| 286 | ).forEach(function(elem) { | ||
| 287 | elem.addEventListener('keydown', function(event) { | ||
| 288 | if (event.key === 'Enter' || event.key === ' ') { | ||
| 289 | event.preventDefault(); | ||
| 290 | elem.click(); | ||
| 291 | } | ||
| 292 | }); | ||
| 293 | }); | ||
| 294 | |||
| 257 | /* Add click handlers for event div sizers */ | 295 | /* Add click handlers for event div sizers */ |
| 258 | document.querySelector('.vsmallboxes').onclick = function() { | 296 | document.querySelector('.vsmallboxes').onclick = function() { |
| 259 | document.body.classList.remove('size-medium', 'size-large'); | 297 | document.body.classList.remove('size-medium', 'size-large'); |
| 260 | document.body.classList.add('size-small'); | 298 | document.body.classList.add('size-small'); |
| 299 | update_size_aria(); | ||
| 261 | }; | 300 | }; |
| 262 | 301 | ||
| 263 | document.querySelector('.vmediumboxes').onclick = function() { | 302 | document.querySelector('.vmediumboxes').onclick = function() { |
| 264 | document.body.classList.remove('size-small', 'size-large'); | 303 | document.body.classList.remove('size-small', 'size-large'); |
| 265 | document.body.classList.add('size-medium'); | 304 | document.body.classList.add('size-medium'); |
| 305 | update_size_aria(); | ||
| 266 | }; | 306 | }; |
| 267 | 307 | ||
| 268 | document.querySelector('.vlargeboxes').onclick = function() { | 308 | document.querySelector('.vlargeboxes').onclick = function() { |
| 269 | document.body.classList.remove('size-small', 'size-medium'); | 309 | document.body.classList.remove('size-small', 'size-medium'); |
| 270 | document.body.classList.add('size-large'); | 310 | document.body.classList.add('size-large'); |
| 311 | update_size_aria(); | ||
| 271 | }; | 312 | }; |
| 272 | 313 | ||
| 273 | /* Add de-highlighter on touch interface devices */ | 314 | /* Add de-highlighter on touch interface devices */ |
| 274 | if( isTouch ) { | 315 | if( isTouch ) { |
| 275 | document.body.onclick = function() { | 316 | document.body.onclick = function() { |
| 276 | document.querySelector('.highlighted').forEach(elem => elem.classList.remove('highlighted')); | 317 | for (elem of document.querySelectorAll('.highlighted')) {elem.classList.remove('highlighted'); } |
| 277 | }; | 318 | }; |
| 278 | document.querySelector('.touch-only').forEach(elem => elem.classList.remove('hidden')); | 319 | for (elem of document.querySelectorAll('.touch-only')) { elem.classList.remove('hidden'); } |
| 279 | } | 320 | } |
| 280 | 321 | ||
| 281 | /* Add callbacks for view selector */ | 322 | /* Add callbacks for view selector */ |
| @@ -287,8 +328,16 @@ function do_the_halfnarp() { | |||
| 287 | document.querySelector('.vday4').onclick = function() { toggle_grid(4); }; | 328 | document.querySelector('.vday4').onclick = function() { toggle_grid(4); }; |
| 288 | document.querySelector('.vdays').onclick = function() { toggle_grid(5); }; | 329 | document.querySelector('.vdays').onclick = function() { toggle_grid(5); }; |
| 289 | } | 330 | } |
| 290 | document.querySelector('.vlang').onclick = function() { document.body.classList.toggle('languages'); }; | 331 | |
| 291 | document.querySelector('.vtrack').onclick = function() { document.body.classList.toggle('all-tracks'); }; | 332 | document.querySelector('.vlang').onclick = function() { |
| 333 | document.body.classList.toggle('languages'); | ||
| 334 | this.setAttribute('aria-pressed', document.body.classList.contains('languages')); | ||
| 335 | }; | ||
| 336 | document.querySelector('.vtrack').onclick = function() { | ||
| 337 | document.body.classList.toggle('all-tracks'); | ||
| 338 | this.setAttribute('aria-pressed', document.body.classList.contains('all-tracks')); | ||
| 339 | }; | ||
| 340 | |||
| 292 | document.querySelector('.vnarpr').onclick = function() { $('.narpr').toggleClass('hidden'); set_random_event(); }; | 341 | document.querySelector('.vnarpr').onclick = function() { $('.narpr').toggleClass('hidden'); set_random_event(); }; |
| 293 | 342 | ||
| 294 | if (0) { | 343 | if (0) { |
| @@ -311,10 +360,10 @@ function do_the_halfnarp() { | |||
| 311 | /* If we've been here before, try to get local preferences. They are authoratative */ | 360 | /* If we've been here before, try to get local preferences. They are authoratative */ |
| 312 | var selection = [], friends = { }; | 361 | var selection = [], friends = { }; |
| 313 | try { | 362 | try { |
| 314 | selection = localStorage['39C3-halfnarp'] || []; | 363 | selection = localStorage['40C3-halfnarp'] || []; |
| 315 | friends = localStorage['39C3-halfnarp-friends'] || { }; | 364 | friends = localStorage['40C3-halfnarp-friends'] || { }; |
| 316 | myuid = localStorage['39C3-halfnarp-uid'] || ''; | 365 | myuid = localStorage['40C3-halfnarp-uid'] || ''; |
| 317 | mypid = localStorage['39C3-halfnarp-pid'] || ''; | 366 | mypid = localStorage['40C3-halfnarp-pid'] || ''; |
| 318 | } catch(err) { | 367 | } catch(err) { |
| 319 | } | 368 | } |
| 320 | 369 | ||
| @@ -328,12 +377,16 @@ function do_the_halfnarp() { | |||
| 328 | /* Take copy of hidden event template div and select them, if they're in | 377 | /* Take copy of hidden event template div and select them, if they're in |
| 329 | list of previous prereferences */ | 378 | list of previous prereferences */ |
| 330 | var t = $( '#template' ).clone(true); | 379 | var t = $( '#template' ).clone(true); |
| 380 | t.attr({ role: 'button', tabindex: '0', 'aria-pressed': 'false' }); | ||
| 381 | t.on('keydown', function(event) { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); $(this).trigger('click'); } }); | ||
| 382 | |||
| 331 | var event_id = item.event_id.toString(); | 383 | var event_id = item.event_id.toString(); |
| 332 | t.addClass('event ' + ' lang_' + (item.language || 'en')); | 384 | t.addClass('event ' + ' lang_' + (item.language || 'en')); |
| 333 | t.attr('event_id', item.event_id.toString()); | 385 | t.attr('event_id', item.event_id.toString()); |
| 334 | t.attr('id', 'event_' + item.event_id.toString()); | 386 | t.attr('id', 'event_' + item.event_id.toString()); |
| 335 | if( selection && selection.indexOf(item.event_id) != -1 ) { | 387 | if( selection && selection.indexOf(item.event_id) != -1 ) { |
| 336 | t.addClass( 'selected' ); | 388 | t.addClass( 'selected' ); |
| 389 | update_event_state(t[0]); | ||
| 337 | } | 390 | } |
| 338 | 391 | ||
| 339 | /* Sort textual info into event div */ | 392 | /* Sort textual info into event div */ |
| @@ -357,7 +410,7 @@ function do_the_halfnarp() { | |||
| 357 | if( hour > 23) | 410 | if( hour > 23) |
| 358 | hour -= 24; | 411 | hour -= 24; |
| 359 | 412 | ||
| 360 | /* Fix up room for 39C3 */ | 413 | /* Fix up room for 40C3 */ |
| 361 | room = (item.room_id || '').toString().replace('1','room1').replace('2','room2').replace('3','room3'); | 414 | room = (item.room_id || '').toString().replace('1','room1').replace('2','room2').replace('3','room3'); |
| 362 | 415 | ||
| 363 | /* Apply attributes to sort events into calendar */ | 416 | /* Apply attributes to sort events into calendar */ |
| @@ -373,6 +426,7 @@ function do_the_halfnarp() { | |||
| 373 | if( isTouch ) { | 426 | if( isTouch ) { |
| 374 | if ( $( this ).hasClass('highlighted') ) { | 427 | if ( $( this ).hasClass('highlighted') ) { |
| 375 | $( this ).toggleClass('selected'); | 428 | $( this ).toggleClass('selected'); |
| 429 | update_event_state(this); | ||
| 376 | $('.info').addClass('hidden'); | 430 | $('.info').addClass('hidden'); |
| 377 | } else { | 431 | } else { |
| 378 | $('.highlighted').removeClass('highlighted'); | 432 | $('.highlighted').removeClass('highlighted'); |
| @@ -380,6 +434,7 @@ function do_the_halfnarp() { | |||
| 380 | } | 434 | } |
| 381 | } else { | 435 | } else { |
| 382 | $( this ).toggleClass('selected'); | 436 | $( this ).toggleClass('selected'); |
| 437 | update_event_state(this); | ||
| 383 | $('.info').addClass('hidden'); | 438 | $('.info').addClass('hidden'); |
| 384 | } | 439 | } |
| 385 | event.stopPropagation(); | 440 | event.stopPropagation(); |
| @@ -442,7 +497,7 @@ function do_the_halfnarp() { | |||
| 442 | $.getJSON( halfnarpPubAPI + friends.pid, { format: 'json' }) | 497 | $.getJSON( halfnarpPubAPI + friends.pid, { format: 'json' }) |
| 443 | .done(function( data ) { | 498 | .done(function( data ) { |
| 444 | friend.prefs = data.talk_ids; | 499 | friend.prefs = data.talk_ids; |
| 445 | localStorage['39C3-halfnarp-friends'] = friends; | 500 | localStorage['40C3-halfnarp-friends'] = friends; |
| 446 | update_friends(); | 501 | update_friends(); |
| 447 | }); | 502 | }); |
| 448 | } | 503 | } |
| @@ -476,6 +531,8 @@ function do_the_halfnarp() { | |||
| 476 | /* toggle_corr_mode(); */ | 531 | /* toggle_corr_mode(); */ |
| 477 | break; | 532 | break; |
| 478 | } | 533 | } |
| 534 | document.querySelector('.vlang').setAttribute('aria-pressed', document.body.classList.contains('languages')); | ||
| 535 | document.querySelector('.vtrack').setAttribute('aria-pressed', document.body.classList.contains('all-tracks')); | ||
| 479 | }; | 536 | }; |
| 480 | } | 537 | } |
| 481 | 538 | ||
