Ignore:
Timestamp:
2022-12-15T11:22:13+13:00 (17 months ago)
Author:
davidb
Message:

Some debugging work around treatment of AV values; Some initial work in moving the AV-chart to a main central area, rather than being part of the AV-Recommendation area

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-installations/mars/trunk/sites/mars/collect/amc-essentia/js/av_document.js

    r36966 r37029  
    6767    */
    6868   
    69 function preSubmit(form)
     69
     70function displayClampedCurrentTimeAndAV()
    7071{
    7172    // Note, the Arousal and Valence feature window values used is:
     
    7576   
    7677    // clamp to ensure >= 6.0 secs
     78
    7779    var current_time = Math.max(6.0,wavesurfer.getCurrentTime());
    7880    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;
    8381   
    8482    var arousal_val = parseFloat($('#arousal-val').text());
    8583    var valence_val = parseFloat($('#valence-val').text());
    8684
    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
     93function 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);
    90117}
    91118
     
    176203    var new_doc_playervisual_url = new_doc_url_parts[0] + "&excerptid=playervisual-documenttext#" + new_doc_url_parts[1];
    177204
    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");
    180229
    181230    $.ajax({
     
    183232        url: new_doc_metadata_url,
    184233    })
     234        .always(function() {
     235        $('#metadata-documenttext').css("cursor","revert");
     236        })
     237
    185238        .fail(function(jqXHR,textStatus) {
    186239        console.error( "metadata-documenttext ajax request failed: " + textStatus);
     
    195248        url: new_doc_playervisual_url,
    196249    })
     250        .always(function() {
     251        $('#playervisual-documenttext').css("cursor","revert");
     252        })
    197253        .fail(function(jqXHR,textStatus) {
    198254        console.error( "playervisual-documenttext equest failed: " + textStatus);
    199255        })
    200256        .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 doc
    203        
    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);
    216257       
    217258        $('#playervisual-documenttext').replaceWith(html_result);
     
    223264        initWavesurferPlayer();
    224265
     266        wavesurfer.seekTo(frameOffset/AMC_SONG_DURATION);
     267       
    225268        postInitWavesurfer(wavesurfer);
    226269
     
    229272
    230273   
    231    
     274    $resultsTable_tr1.slideUp();
    232275   
    233276    //var arousal_val = $av_recommendation.data("arousalval");
     
    341384        recommendFromPos();
    342385    }
     386    displayClampedCurrentTimeAndAV();
    343387    });
    344388
     
    353397        //console.log("**** setting play seek @ " + frameOffset);
    354398        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!");
    357403        /*if (frameOffset>1.0) {
    358404        currentPosRunup = 1.0; // 1 second
    359         }*/
     405        }*/
     406    }
     407    else {
     408        recommendFromStart();
     409        displayClampedCurrentTimeAndAV();
    360410    }
    361411    });
     
    502552}
    503553
     554function showAVChart()
     555{
     556    $('#av-chart-outerdiv').slideDown();
     557    $('#show-av-chart').hide();
     558    $('#hide-av-chart').show();
     559
     560    return false;
     561}
     562
     563function hideAVChart()
     564{
     565    $('#av-chart-outerdiv').slideUp();
     566    $('#hide-av-chart').hide();
     567    $('#show-av-chart').show();
     568
     569    return false;
     570}
     571
    504572$(document).ready(function() {
    505573
Note: See TracChangeset for help on using the changeset viewer.