Changeset 24907

Show
Ignore:
Timestamp:
16.12.2011 13:42:28 (8 years ago)
Author:
sjb48
Message:

Tidied up format functionality.

Location:
main/trunk/greenstone3/web/interfaces/oran
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/oran/js/format_util.js

    r24900 r24907  
    22console.log("Loading format_util.js\n"); 
    33 
    4 // Ensures that a change to a text field is remembered 
     4/* Ensures that a change to a text field is remembered */ 
    55function onTextChange(item, text) 
    66{ 
     
    99} 
    1010 
    11 // Ensures that a change to a select field is remembered 
     11/* Ensures that a change to a select field is remembered */ 
    1212function onSelectChange(item) 
    1313{ 
     
    2424} 
    2525 
     26 
     27/* Get substring */ 
    2628function getSubstring(str, first, last) 
    2729{ 
     
    3436    var substring = str.substring(first_index, last_index); 
    3537 
    36     console.log(substring); 
    37  
    3838    return substring; 
    3939} 
     
    4141function getXSLT(classname) 
    4242{ 
     43    console.log("*** Function getXSLT ***"); 
    4344    var myurl = document.URL; 
    4445 
    45     //var collection_name = getSubstring(myurl, "&c", "&"); 
    4646    var document_id = getSubstring(myurl, "&d", "&"); 
    4747    var document_type = getSubstring(myurl, "&dt", "&"); 
    48     var prev_action = getSubstring(myurl, "&p.a", "&"); 
    49     console.log("Prev action: "+ prev_action); 
    50     var prev_service = getSubstring(myurl, "&p.s", "&"); 
    51     console.log("Prev service: "+ prev_service); 
    52  
    53     //var post_url = "http://localhost:8383/greenstone3/dev?a=d&c=" + collection_name + "&d=" + document_id + "&dt=" + document_type + "&p.a=" + prev_action + "&p.s=" + prev_service + "&o=skinandlib"; 
     48 
    5449    var post_url = host_info.pre_URL +"?a=d&c=" + host_info.collection_name + "&d=" + document_id + "&dt=" + document_type + "&o=skinandlib"; 
    5550 
    56     $.post(post_url, {data: classname}, function(data) { 
    57             console.log("Success, we have received data"); 
    58             console.log(data); 
     51    $.post(post_url, function(data) { 
     52            console.log("Success, we have received the XSLT for the relevant page part"); 
    5953            classname = "." + classname; 
    60             console.log(classname);  
    61             var content = $(data).find(classname); 
    62             console.log(content.innerXHTML()); 
    63             console.log(content.xml()); 
    64             console.log(content); 
     54            /* There seemed to be a problem with MIME types for the data received from the post. */  
     55            /* The best fix for now is to set the data type to text and then reparse as xml */ 
     56            xml = $.parseXML(data); 
     57            var content = $( xml ).find(classname); 
     58            /* The xml() function is provided by jquery.xml.js (included by formatmanager.xsl) */ 
    6559            $("#XSLTcode").val(content.xml()); 
    66             }, 'xml'); 
     60            }, 'text'); 
    6761} 
    6862 
     
    162156    CURRENT_SELECT_VALUE = ""; //global - gets set by ui.draggable 
    163157 
    164     console.log(gs.xsltParams.interface_name); 
    165     console.log(gs.collectionMetadata.httpPath); 
    166     console.log(document.URL); 
    167158    var r = /(https?:\/\/)?([\da-z\.-]+):(\d+)\/([\da-z]+)\/([\da-z]+)\?.*&c=([\da-z\.-]+).*/; 
    168159    var s = document.URL; 
     
    184175    host_info.pre_URL = "http://" + host_info.host_name + ":" + host_info.port + "/" + host_info.library + "/" + host_info.servlet; 
    185176    console.log("Pre URL: " + host_info.pre_URL); 
    186  
    187     /* 
    188     var collection = ""; 
    189      
    190     var regex = new RegExp("[?&]c="); 
    191     var matches = regex.exec(document.URL); 
    192     if(matches != null) 
    193     { 
    194         var startIndex = matches.index; 
    195         var endIndex = document.URL.indexOf("&", startIndex + 1); 
    196          
    197         if(endIndex == -1) 
    198         { 
    199             endIndex = document.URL.length; 
    200         } 
    201          
    202         collection = document.URL.substring(startIndex, endIndex); 
    203     } 
    204     */ 
    205177 
    206178    /* 
  • main/trunk/greenstone3/web/interfaces/oran/transform/layouts/formatmanager.xsl

    r24421 r24907  
    2222        <!-- Sam2's div code --> 
    2323 
    24         <script type="text/javascript" src="interfaces/oran/js/jquery-1.4.2.js"><xsl:text> </xsl:text></script> 
     24        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"><xsl:text> </xsl:text></script> 
     25        <!--<script type="text/javascript" src="interfaces/oran/js/jquery-1.4.2.js"><xsl:text> </xsl:text></script>--> 
     26        <!-- XML parsing doesn't seem to work properly jquery so jquery.xml.js is a fix for this --> 
     27        <script type="text/javascript" src="interfaces/oran/js/jquery.xml.js"><xsl:text> </xsl:text></script> 
    2528        <script type="text/javascript" src="interfaces/oran/js/jquery-ui-1.8.15/ui/jquery-ui-1.8.15.custom.js"><xsl:text> </xsl:text></script> 
    2629        <script type="text/javascript" src="interfaces/oran/js/jquery.selectboxes.js"><xsl:text> </xsl:text></script> 
    2730        <script type="text/javascript" src="interfaces/oran/js/innerxhtml.js"><xsl:text> </xsl:text></script> 
    28         <script type="text/javascript" src="interfaces/oran/js/jquery.xml.js"><xsl:text> </xsl:text></script> 
    29         <script type="text/javascript" src="interfaces/oran/js/gui_div.js"><xsl:text> </xsl:text></script> 
     31        <!--<script type="text/javascript" src="interfaces/oran/js/gui_div.js"><xsl:text> </xsl:text></script>--> 
     32        <script type="text/javascript" src="interfaces/oran/js/format_browse.js"><xsl:text> </xsl:text></script> 
     33        <script type="text/javascript" src="interfaces/oran/js/format_document.js"><xsl:text> </xsl:text></script> 
     34        <script type="text/javascript" src="interfaces/oran/js/format_util.js"><xsl:text> </xsl:text></script> 
     35        <script type="text/javascript" src="interfaces/oran/js/format_jquery_prototypes.js"><xsl:text> </xsl:text></script> 
    3036        
    3137        <xsl:call-template name="xml-to-gui-templates"> 
  • main/trunk/greenstone3/web/interfaces/oran/transform/layouts/header.xsl

    r24781 r24907  
    2727        <link rel="stylesheet" href="interfaces/{$interface_name}/style/core.css" type="text/css"/> 
    2828        <link rel="shortcut icon" href="favicon.ico"/>  
    29         <script type="text/javascript" src="interfaces/{$interface_name}/js/direct-edit.js"><xsl:text> </xsl:text></script> 
    30          
    31         <xsl:call-template name="init-seaweed"/> 
     29        <!--<script type="text/javascript" src="interfaces/{$interface_name}/js/direct-edit.js"><xsl:text> </xsl:text></script>--> 
     30         
     31        <!--<xsl:call-template name="init-seaweed"/>--> 
    3232        <xsl:call-template name="setup-gs-variable"/> 
    3333        <xsl:call-template name="additionalHeaderContent"/> 
  • main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui-templates.xsl

    r24420 r24907  
    4545 
    4646    <!-- ********** GSF:METADATA ********** --> 
     47    <!-- This element is now created on-the-fly in javascript --> 
     48    <!--     
    4749        <xsl:variable name="metadata"> 
    4850        <div class="gsf_metadata css_gsf_metadata block leaf" title="gsf:metadata"> 
     
    6163            gsf_metadata_element = <xsl:text disable-output-escaping="yes">'</xsl:text><xsl:copy-of select="$metadata"/><xsl:text disable-output-escaping="yes">';</xsl:text>  
    6264        </script> 
    63  
     65   --> 
    6466 
    6567    <!-- ********** GSF:LINK ********** -->