Changeset 37029 for gs3-installations


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

Location:
gs3-installations/mars/trunk/sites/mars/collect/amc-essentia
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gs3-installations/mars/trunk/sites/mars/collect/amc-essentia/etc/collectionConfig.xml

    r36966 r37029  
    157157        <xsl:otherwise>
    158158          <td valign="top">
    159         <gsf:link type="document">
     159        <gsf:link type="document" extraLinkArgs="renderWave=0">
    160160          <gsf:icon type="document"/>
    161161        </gsf:link>
     
    163163          <td>
    164164         
    165         <gsf:link type="document">
     165        <gsf:link type="document" extraLinkArgs="renderWave=0">
    166166              <gsf:metadata name="amc.title"/>
    167167          by <gsf:metadata name="amc.artist"/>
     
    326326            <gsf:template match="documentNode">
    327327                <td valign="top">
    328                     <gsf:link type="document">
     328                    <gsf:link type="document" extraLinkArgs="renderWave=0">
    329329                        <gsf:icon type="document"/>
    330330                    </gsf:link>
     
    339339                </td>
    340340                <td valign="top">
    341                   <gsf:link type="document">
     341                  <gsf:link type="document" extraLinkArgs="renderWave=0">
    342342                        <gsf:choose-metadata>
    343343                      <gsf:metadata name="dc.Title"/>
     
    550550              <gsf:script src="{$httpCollection}/js/av_document.js"/>
    551551
    552               <div id="metadata-documenttext" class="documenttext" style="padding-bottom: 20px; width:100%;">
     552              <div id="metadata-documenttext" class="documenttext" style="padding-bottom: 35px; width:100%;">
    553553                <style>
    554554                  .doc-metadata td { padding: 7px; }
     
    588588                <div id="ajax-loaded-assocfilepath" style="display: none;"><gsf:metadata name="assocfilepath" pos="first"/></div>
    589589
     590                <style>
     591                  #hide-av-chart {
     592                  display: none;
     593                  }
     594                 
     595                  span.display-view-modes, a.display-view-modes {
     596                    padding: 5px;
     597                  }
     598               
     599                  .display-view-modes:hover {
     600                    background-color: #b0b0b0;
     601                  }               
     602                </style>
    590603               
    591                 <div style="position: absolute; right: 24px; top: -18px; z-index: 1000; font-size: 90%; font-style:italic">
    592                   <a id="switch-to-waveform"    stylexx="display: none;" href="">Switch to Waveform</a>
    593                   <a id="switch-to-spectrogram" stylexx="display: none;" href="">Switch to Spectrogram</a>
     604                <div style="position: absolute; right: 24px; top: -23px; z-index: 1000; font-size: 90%; font-styleXX:italic">
     605                  <span style="display: inline-block">
     606                <a id="switch-to-waveform"    class="display-view-modes" stylexx="display: none;" href="">Switch to Waveform</a>
     607                <a id="switch-to-spectrogram" class="display-view-modes" stylexx="display: none;" href="">Switch to Spectrogram</a>
     608                  </span>
     609                  <span style="display: inline-block; width: 140px;">
     610                | <span id="show-av-chart" class="display-view-modes" onclick="return showAVChart();">Display AV Chart</span>
     611                  <span id="hide-av-chart" class="display-view-modes" onclick="return hideAVChart();">Hide AV Chart</span>
     612                  </span>
     613                  <span style="display: inline-block">
     614                | <span class="display-view-modes" onclick="alert('To be implemented')">&#x23fa; Record <i>your</i> AV experience</span>
     615                  </span>
    594616                </div>
    595617
     
    669691       
    670692        </div>
     693
     694
     695    <div id="av-chart-outerdiv" style="display: none;">
     696      <hr/>
     697      <div style="width: 500px; margin: auto;">
     698        <div id="av-chart-div" style="position: relative; height: 325px; width: 300px; margin: auto">
     699          <div style="position: absolute; top: 0; left: 0; width: 300px; height: 300px; pointer-events: none;">
     700        <canvas id="av-chart-canvas" style="XXwidth: 100%; height: 300px;">
     701          Your browser does not support the canvas element
     702        </canvas>
     703          </div>
     704          <img id="av-chart-img" width="300"
     705           style="cursor: crosshair; background-colorXX: #fefefe;"
     706           src="{$library_name}/sites/{$site_name}/collect/{$collName}/images/av-diagram-bw.svg" />
     707          <div>
     708        <i>Click inside the Arousal-Valence visualisation above to initiate an AV-based recommendation.</i>
     709          </div>
     710         
     711        </div>
     712      </div>
     713    </div>
    671714   
    672715    <gsf:variable name="mp3url"><xsl:value-of select="$httpCollection"/>/index/assoc/<xsl:value-of select="$assocFilePath"/>/audio.mp3</gsf:variable>
     
    762805              </form>
    763806              <div>
     807                <!--
    764808                <div id="av-chart-div" style="position: relative; height: 325px; width: 300px; float: right; display: none;">
    765809                  <div style="position: absolute; top: 0; left: 0; width: 300px; height: 300px; pointer-events: none;">
     
    776820
    777821                </div>
     822                -->
    778823                <div id="resultsAreaDiv" style="padding-top: 1rem; min-height: 325px; display: none;">
    779824                  <xsl:text> </xsl:text>
  • 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.