Ignore:
Timestamp:
2019-06-11T19:46:35+12:00 (5 years ago)
Author:
wy59
Message:

Major refactoring of map-scripts.js and classifier_scripts.js and document_scripts.js. Prior to this commit, there was some behaviour in map-scripts.js that was not straightforward: it was mimicking 'overriding' (function overrides don't exist in Javascript) and actually redefining the 2 functions httpRequest() already implemented in classifier_scripts, and toggleSection() already implemented in classifier_scripts and document_scripts. ToggleSection() was implemented differently in the 2 original js files, and the one that got called depended on whether we were in doc view or classifier view. The original solution kept to this function overriding way of doing things and was messy. But we've now gone with Dr Bainbridge's suggestion of having a global variable mapEnabled that is declared/defined at the top of map-scripts.js. We then test for its existence in classifier_scripts::toggleSection now, to determine if we can call the extra map-specific functions that map_scripts did when doing the 'overriding'. This changeover allowed us to get rid of the function overrides in map-scripts.js and cleaned up unnecessary behaviour and variables introduced into document_scripts in a recent commit merely to work with the function override way of doing things.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js

    r33128 r33146  
    11/** Javascript file for viewing documents */
    2 
    3 //-------TODO--------//
    4 // map-scripts.js needs these, but non-map viewing does not. Yet if we add these to map_scripts,
    5 // then in classifier mode, map_scripts will use classifier_scripts.js which already has these
    6 // So for now, we add them into this file for when map_scripts is in doc view mode and includes document_scripts.js.
    7 // It seems suboptimal, as these variables and function will be wasted when in regular non-map mode.
    8 // But unable to think of any other solution at present.
    9 var inProgress = new Array();
    10 var openClassifiers = new Array();
    11 var busy = false;
    12 
    13 
    14 
    15 function updateOpenClassifiers()
    16 {
    17     var oc = "";
    18     var first = true;
    19     for(var key in openClassifiers)
    20     {
    21         if(first)
    22         {
    23             first = false;
    24         }
    25         else
    26         {
    27             oc += ",";
    28         }
    29        
    30         oc += key;
    31     }
    32    
    33     if(oc != undefined)
    34     {
    35         window.location.hash = oc;
    36     }
    37 }
    38 
    39 //---------------//
    402
    413/** NOTE, this file uses inline templates which look for httpPath, assocfilepath, Source, Thumb, Title metadata. These need to be added into any xsl file that uses this javascript (using <gsf:metadata name="xx" hidden="true"/> if they are not already being collected. */
     
    187149}
    188150
    189 // TODO:
    190 // DO NOT "MERGE" _basicToggleSection into toggleSection!
    191 // map_scripts.js calls _basicToggleSection as it redefines toggleSection() to do (more) stuff.
     151
    192152function toggleSection(sectionID, callback, tocDisabled)
    193 {
    194     _basicToggleSection(sectionID, callback, tocDisabled); 
    195 }
    196 function _basicToggleSection(sectionID, callback, tocDisabled)
    197153{
    198154    var docElem = gs.jqGet("doc" + sectionID);
Note: See TracChangeset for help on using the changeset viewer.