- Timestamp:
- 2022-12-15T11:22:13+13:00 (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-installations/mars/trunk/sites/mars/collect/amc-essentia/js/av_document.js
r36966 r37029 67 67 */ 68 68 69 function preSubmit(form) 69 70 function displayClampedCurrentTimeAndAV() 70 71 { 71 72 // Note, the Arousal and Valence feature window values used is: … … 75 76 76 77 // clamp to ensure >= 6.0 secs 78 77 79 var current_time = Math.max(6.0,wavesurfer.getCurrentTime()); 78 80 var current_time_1dp = current_time.toFixed(1); 79 AVEnsurePaused();80 81 weka_segment = Math.round(current_time/3) * 3;82 form.elements["s1.offset"].value = weka_segment;83 81 84 82 var arousal_val = parseFloat($('#arousal-val').text()); 85 83 var valence_val = parseFloat($('#valence-val').text()); 86 84 87 $('#makeRecommendationFrom-AV').html(`(@${current_time_1dp} secs: arousal=${arousal_val}, valence=${valence_val})`); 88 89 return submitAVRecommendation(form, arousal_val,valence_val, current_time); 85 var arousal_val_str = (arousal_val>0) ? "+"+arousal_val : ""+arousal_val; 86 var valence_val_str = (valence_val>0) ? "+"+valence_val : ""+valence_val; 87 88 $('#makeRecommendationFrom-AV').html(`(@${current_time_1dp} secs: arousal = ${arousal_val_str}, valence = ${valence_val_str})`); 89 90 return current_time; 91 } 92 93 function preSubmit(form) 94 { 95 // Note, the Arousal and Valence feature window values used is: 96 // 6 secs + 50% overlap 97 // So the Weka computed AV values are spaced out: 98 // 6s, 9s, 12s, ... 99 100 // clamp to ensure >= 6.0 secs 101 //var current_time = Math.max(6.0,wavesurfer.getCurrentTime()); 102 //var current_time_1dp = current_time.toFixed(1); 103 104 var clamped_current_time = displayClampedCurrentTimeAndAV(); 105 106 AVEnsurePaused(); 107 108 weka_segment = Math.round(clamped_current_time/3) * 3; 109 form.elements["s1.offset"].value = weka_segment; 110 111 var arousal_val = parseFloat($('#arousal-val').text()); 112 var valence_val = parseFloat($('#valence-val').text()); 113 114 //$('#makeRecommendationFrom-AV').html(`(@${current_time_1dp} secs: arousal=${arousal_val}, valence=${valence_val})`); 115 116 return submitAVRecommendation(form, arousal_val,valence_val, clamped_current_time); 90 117 } 91 118 … … 176 203 var new_doc_playervisual_url = new_doc_url_parts[0] + "&excerptid=playervisual-documenttext#" + new_doc_url_parts[1]; 177 204 178 console.log("new doc metadata url = " + new_doc_metadata_url); 179 console.log("new doc playervisual url = " + new_doc_playervisual_url); 205 //console.log("new doc metadata url = " + new_doc_metadata_url); 206 //console.log("new doc playervisual url = " + new_doc_playervisual_url); 207 208 209 // current URL ends with collect/amc-essentia/document/ds_51017_15513?p.frameOffset=... 210 // Need to remove old '/document/ds_...' and replace with new doc 211 212 const current_doc_url_str = window.location.href; 213 214 console.log(current_doc_url_str); 215 var push_doc_url_str = current_doc_url_str.replace(/document\/\w+\?/,"document/"+doc_id+"?"); 216 console.log("new doc url str = " + push_doc_url_str); 217 const push_doc_url = new URL(push_doc_url_str); 218 219 var frameOffset = $av_recommendation.data("frameoffset"); 220 push_doc_url.searchParams.set('p.frameOffset', frameOffset); 221 push_doc_url.searchParams.set('d', doc_id); 222 window.history.pushState({}, '', push_doc_url); 223 //window.history.replaceState({}, '', push_doc_url); 224 225 226 227 $('#metadata-documenttext').css("cursor","wait"); 228 $('#playervisual-documenttext').css("cursor","wait"); 180 229 181 230 $.ajax({ … … 183 232 url: new_doc_metadata_url, 184 233 }) 234 .always(function() { 235 $('#metadata-documenttext').css("cursor","revert"); 236 }) 237 185 238 .fail(function(jqXHR,textStatus) { 186 239 console.error( "metadata-documenttext ajax request failed: " + textStatus); … … 195 248 url: new_doc_playervisual_url, 196 249 }) 250 .always(function() { 251 $('#playervisual-documenttext').css("cursor","revert"); 252 }) 197 253 .fail(function(jqXHR,textStatus) { 198 254 console.error( "playervisual-documenttext equest failed: " + textStatus); 199 255 }) 200 256 .done(function(html_result) { 201 // current URL ends with collect/amc-essentia/document/ds_51017_15513?p.frameOffset=...202 // Need to remove old '/document/ds_...' and replace with new doc203 204 const current_doc_url_str = window.location.href;205 206 console.log(current_doc_url_str);207 var new_doc_url_str = current_doc_url_str.replace(/document\/\w+\?/,"document/"+doc_id+"?");208 console.log("new doc url str = " + new_doc_url_str);209 const new_doc_url = new URL(new_doc_url_str);210 211 var frameOffset = $av_recommendation.data("frameoffset");212 new_doc_url.searchParams.set('p.frameOffset', frameOffset);213 new_doc_url.searchParams.set('d', doc_id);214 window.history.pushState({}, '', new_doc_url);215 //window.history.replaceState({}, '', new_doc_url);216 257 217 258 $('#playervisual-documenttext').replaceWith(html_result); … … 223 264 initWavesurferPlayer(); 224 265 266 wavesurfer.seekTo(frameOffset/AMC_SONG_DURATION); 267 225 268 postInitWavesurfer(wavesurfer); 226 269 … … 229 272 230 273 231 274 $resultsTable_tr1.slideUp(); 232 275 233 276 //var arousal_val = $av_recommendation.data("arousalval"); … … 341 384 recommendFromPos(); 342 385 } 386 displayClampedCurrentTimeAndAV(); 343 387 }); 344 388 … … 353 397 //console.log("**** setting play seek @ " + frameOffset); 354 398 wavesurfer.seekTo(frameOffset/AMC_SONG_DURATION); 355 356 console.log("av_document.js keeping 'currentPosRunup' at 0"); 399 recommendFromPos(); 400 displayClampedCurrentTimeAndAV(); 401 402 console.log("av_document.js: **** Keeping 'currentPosRunup' at 0 for now!"); 357 403 /*if (frameOffset>1.0) { 358 404 currentPosRunup = 1.0; // 1 second 359 }*/ 405 }*/ 406 } 407 else { 408 recommendFromStart(); 409 displayClampedCurrentTimeAndAV(); 360 410 } 361 411 }); … … 502 552 } 503 553 554 function showAVChart() 555 { 556 $('#av-chart-outerdiv').slideDown(); 557 $('#show-av-chart').hide(); 558 $('#hide-av-chart').show(); 559 560 return false; 561 } 562 563 function hideAVChart() 564 { 565 $('#av-chart-outerdiv').slideUp(); 566 $('#hide-av-chart').hide(); 567 $('#show-av-chart').show(); 568 569 return false; 570 } 571 504 572 $(document).ready(function() { 505 573
Note:
See TracChangeset
for help on using the changeset viewer.