Ignore:
Timestamp:
2010-12-14T17:15:30+13:00 (13 years ago)
Author:
sjb48
Message:

Working on saving a format statement to the config file. This looks like it should work but changes in FormatAction have caused major issues with Document/Node violations. This is because saving required the format statement as a Document rather than a string (which did work). Added a check to GSXML for xmlNodeToString to check that attrs is not null (attrs will be null unless the node is an element).

File:
1 edited

Legend:

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

    r23405 r23489  
    44var initialised_iframe = "false";
    55
    6 function createFormatStatement()
    7 {
    8 
     6//function createFormatStatement()
     7//{
     8
     9    //var formatDiv = document.getElementById('formatStatement');
     10    //var formatStatement = innerXHTML(formatDiv);
     11    //console.log(formatStatement);
     12
     13    // find collection name
     14
     15    //var myurl = document.URL;
     16    //console.log(myurl);
     17    //var first = myurl.indexOf("&c")+3;
     18    //var last = myurl.indexOf("&", first);
     19   
     20    //var collection_name = getSubstring(myurl, "&c", "&"); //myurl.substring(first,last); ///&c=(.*)&/.exec(myurl);
     21    //console.log(collection_name);
     22
     23    //first = myurl.indexOf("&s")+3;
     24    //last = myurl.indexOf("&", first);
     25
     26    //var service_name = myurl.substring(first,last);
     27    //console.log(service_name);
     28
     29    //var classifier_name = null;
     30
     31    //if(service_name == "ClassifierBrowse")
     32    //{
     33    //    first = myurl.indexOf("&cl")+4;
     34    //    last = myurl.indexOf("&", first);
     35
     36    //    classifier_name = myurl.substring(first,last);
     37    //    console.log(classifier_name);
     38    //}
     39
     40    //var myurl = 'http://localhost:8080/greenstone3/format?a=s&sa=s&t='+formatStatement;
     41
     42    //jQuery.post( url, [ data ], [ success(data, textStatus, XMLHttpRequest) ], [ dataType ] )
     43
     44    // How do I find out my collection name?
     45
     46function getSubstring(str, first, last)
     47{
     48    var first_index = str.indexOf(first)+first.length+1;
     49    var last_index = str.indexOf(last, first_index);
     50
     51    var substring = str.substring(first_index, last_index);
     52
     53    console.log(substring);
     54
     55    return substring;
     56}
     57   
     58function getFormatStatement()
     59{
    960    var formatDiv = document.getElementById('formatStatement');
    1061    var formatStatement = innerXHTML(formatDiv);
    11     //console.log(formatStatement);
    12 
    13     // find collection name
     62    return formatStatement;
     63}
     64
     65function updateFormatStatement()
     66{
     67    var formatStatement = getFormatStatement();
    1468
    1569    var myurl = document.URL;
    16     console.log(myurl);
    17     var first = myurl.indexOf("&c")+3;
    18     var last = myurl.indexOf("&", first);
    19    
    20     var collection_name = myurl.substring(first,last); ///&c=(.*)&/.exec(myurl);
    21     console.log(collection_name);
    22 
    23     first = myurl.indexOf("&s")+3;
    24     last = myurl.indexOf("&", first);
    25 
    26     var service_name = myurl.substring(first,last);
    27     console.log(service_name);
    28 
     70
     71    var collection_name = getSubstring(myurl, "&c", "&");
     72    var service_name = getSubstring(myurl, "&s", "&");
    2973    var classifier_name = null;
    3074
    3175    if(service_name == "ClassifierBrowse")
    32     {
    33         first = myurl.indexOf("&cl")+4;
    34         last = myurl.indexOf("&", first);
    35 
    36         classifier_name = myurl.substring(first,last);
    37         console.log(classifier_name);
    38     }
    39 
    40     //var myurl = 'http://localhost:8080/greenstone3/format?a=s&sa=s&t='+formatStatement;
    41 
    42     //jQuery.post( url, [ data ], [ success(data, textStatus, XMLHttpRequest) ], [ dataType ] )
    43 
    44     // How do I find out my collection name?
    45     var post_url = "http://localhost:8080/greenstone3/format?a=f&c=" + collection_name +"&s=" + service_name;
     76        classifier_name = getSubstring(myurl, "&cl", "&");
     77
     78    var post_url = "http://localhost:8080/greenstone3/format?a=f&sa=update&c=" + collection_name +"&s=" + service_name;
    4679
    4780    if(classifier_name != null)
     
    5386        console.log(data);
    5487        }, 'html');
     88}
     89
     90function saveFormatStatement()
     91{
     92    var formatStatement = getFormatStatement();
     93
     94    var myurl = document.URL;
     95
     96    var collection_name = getSubstring(myurl, "&c", "&");
     97    var service_name = getSubstring(myurl, "&s", "&");
     98    var classifier_name = null;
     99
     100    if(service_name == "ClassifierBrowse")
     101        classifier_name = getSubstring(myurl, "&cl", "&");
     102
     103    var post_url = "http://localhost:8080/greenstone3/format?a=f&sa=save&c=" + collection_name +"&s=" + service_name;
     104
     105    if(classifier_name != null)
     106        post_url = post_url + "&cl=" + classifier_name;
     107
     108    $.post(post_url, {data: formatStatement}, function(data) {
     109        //$('.result').innerHTML = data; //html(data);
     110        console.log("Success, we have received data");
     111        console.log(data);
     112        }, 'html');
     113}
    55114
    56115/*
     
    104163        */
    105164    //}
    106 }
     165//}
    107166
    108167function traverse(node, formatstring)
Note: See TracChangeset for help on using the changeset viewer.