Ignore:
Timestamp:
2011-06-27T11:07:20+12:00 (13 years ago)
Author:
sjb48
Message:

Working on document-level format editting

File:
1 edited

Legend:

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

    r24136 r24202  
    22console.log("Loading gui_div.js\n");
    33
    4 // var initialised_iframe = "false";
     4/* DOCUMENT SPECIFIC FUNCTIONS */
     5
     6function displayTOC(checkbox)
     7{
     8    if (checkbox.checked == true)
     9    {
     10        console.log("Show the TOC!");
     11        displaySideBar(true);
     12        $("#tableOfContents").css("display", "block");
     13    }
     14    else
     15    {
     16        console.log("Hide the TOC!");
     17        $("#tableOfContents").css("display", "none");
     18        if ($("#coverImage").css("display") == "none")
     19            displaySideBar(false);
     20    }
     21
     22    return;
     23}
     24
     25function displayBookCover(checkbox)
     26{
     27    if (checkbox.checked == true)
     28    {
     29        console.log("Show the book cover!");
     30        displaySideBar(true);
     31        $("#coverImage").css("display", "block");
     32    }
     33    else
     34    {
     35        console.log("Hide the book cover!");
     36        $("#coverImage").css("display", "none");
     37        if ($("#tableOfContents").css("display") == "none")
     38            displaySideBar(false);
     39    }
     40
     41    return;
     42}
     43
     44function displaySideBar(toggle)
     45{
     46    if (toggle == true)
     47    {
     48        console.log("Show the sidebar!");
     49        $("#rightSidebar").css("display", "block");
     50    }
     51    else
     52    {
     53        console.log("Hide the sidebar!");
     54        $("#rightSidebar").css("display", "none");
     55    }
     56
     57    return;
     58}
     59
     60
     61function checkDocumentRadio()
     62{
     63    var selection = $('input[name="documentChanges"]'); //document.quiz.colour;
     64
     65    for (i=0; i<selection.length; i++)
     66
     67        if (selection[i].checked == true)
     68            return selection[i].value;
     69
     70    return "this";
     71}
     72
     73function saveDocumentChanges()
     74{
     75    console.log("Saving changes to "+checkDocumentRadio());
     76}
     77
     78
     79
     80/* FUNCTIONS FOR FORMAT EDITING */                                                                   
    581
    682function onTextChange(item, text)
     
    2399    //item.setAttribute("selected","selected");
    24100}
    25 
    26101
    27102//function createFormatStatement()
     
    84159}
    85160
     161function checkClassifierRadio()
     162{
     163    var selection = $('input[name="classifiers"]'); //document.quiz.colour;
     164
     165    for (i=0; i<selection.length; i++)
     166
     167          if (selection[i].checked == true)
     168              return selection[i].value;
     169
     170    return "this";
     171
     172}
     173
    86174function updateFormatStatement()
    87175{
    88176    var formatStatement = getFormatStatement();
     177
     178    var thisOrAll = checkClassifierRadio();
     179    console.log(thisOrAll);
     180    var myurl = document.URL;
     181
     182    var collection_name = getSubstring(myurl, "&c", "&");
     183    var service_name = getSubstring(myurl, "&s", "&"); 
     184
     185    if(thisOrAll == "all")
     186        service_name = "AllClassifierBrowse";
     187
     188    var classifier_name = null;
     189
     190    if(service_name == "ClassifierBrowse")
     191        classifier_name = getSubstring(myurl, "&cl", "&");
     192
     193    var post_url = "http://localhost:8989/greenstone3/format?a=f&sa=update&c=" + collection_name +"&s=" + service_name;
     194
     195    if(classifier_name != null)
     196        post_url = post_url + "&cl=" + classifier_name;
     197
     198    $.post(post_url, {data: formatStatement}, function(data) {
     199        //$('.result').innerHTML = data; //html(data);
     200   
     201        // An error is returned because there is no valid XSLT for a format update action, there probably shouldn't be one so we ignore what the post returns.   
     202        console.log("Successfully updated");
     203        //console.log(data);
     204        }, 'html');
     205}
     206
     207function saveFormatStatement()
     208{
     209    var formatStatement = getFormatStatement();
     210    var thisOrAll = checkClassifierRadio();
    89211
    90212    var myurl = document.URL;
     
    94216    var classifier_name = null;
    95217
     218    if(thisOrAll == "all")
     219        service_name = "AllClassifierBrowse";
     220
    96221    if(service_name == "ClassifierBrowse")
    97222        classifier_name = getSubstring(myurl, "&cl", "&");
    98223
    99     var post_url = "http://localhost:8989/greenstone3/format?a=f&sa=update&c=" + collection_name +"&s=" + service_name;
     224    var post_url = "http://localhost:8989/greenstone3/format?a=f&sa=save&c=" + collection_name +"&s=" + service_name;
    100225
    101226    if(classifier_name != null)
     
    104229    $.post(post_url, {data: formatStatement}, function(data) {
    105230        //$('.result').innerHTML = data; //html(data);
    106         console.log("Success, we have received data");
    107         console.log(data);
     231       
     232        // An error is returned because there is no valid XSLT for a format update action, there probably shouldn't be one so we ignore what the post returns.   
     233        console.log("Successfully saved");
     234        //console.log(data);
    108235        }, 'html');
    109236}
    110237
    111 function saveFormatStatement()
    112 {
    113     var formatStatement = getFormatStatement();
    114 
     238function getXSLT(classname)
     239{
    115240    var myurl = document.URL;
    116241
    117242    var collection_name = getSubstring(myurl, "&c", "&");
    118     var service_name = getSubstring(myurl, "&s", "&");
    119     var classifier_name = null;
    120 
    121     if(service_name == "ClassifierBrowse")
    122         classifier_name = getSubstring(myurl, "&cl", "&");
    123 
    124     var post_url = "http://localhost:8989/greenstone3/format?a=f&sa=save&c=" + collection_name +"&s=" + service_name;
    125 
    126     if(classifier_name != null)
    127         post_url = post_url + "&cl=" + classifier_name;
    128 
    129     $.post(post_url, {data: formatStatement}, function(data) {
    130         //$('.result').innerHTML = data; //html(data);
    131         console.log("Success, we have received data");
    132         console.log(data);
    133         }, 'html');
     243    var document_id = getSubstring(myurl, "&d", "&");
     244    var document_type = getSubstring(myurl, "&dt", "&");
     245    var prev_action = getSubstring(myurl, "&p.a", "&");
     246    var prev_service = getSubstring(myurl, "&p.s", "&");
     247    //var classifier_name = null;
     248
     249    //if(service_name == "ClassifierBrowse")
     250    //    classifier_name = getSubstring(myurl, "&cl", "&");
     251
     252
     253    //var post_url = "http://localhost:8989/greenstone3/format?a=f&sa=getXSLT&c=" + collection_name +"&s=" + service_name+"&d=" + document_id + "&o=skinandlib";
     254    var post_url = "http://localhost:8989/greenstone3/format?a=d&c=" + collection_name + "&d=" + document_id + "&dt=" + document_type + "&p.a=" + prev_action + "&p.s=" + prev_service + "&o=skinandlib";
     255
     256    //if(classifier_name != null)
     257    //    post_url = post_url + "&cl=" + classifier_name;
     258
     259    $.post(post_url, {data: classname}, function(data) {
     260            //$('.result').innerHTML = data; //html(data);
     261            console.log("Success, we have received data");
     262            //console.log(data);
     263            classname = "." + classname;
     264            console.log(classname); //data.getElementsByTagName("div"));
     265            var content = $( data ).find(classname);
     266            console.log(content.xml());
     267            $("#XSLTcode").val(content.xml());
     268            }, 'xml');
    134269}
    135270
     
    344479    var CURRENT_SELECT_VALUE = "";
    345480
     481    /* DOCUMENT SPECIFIC FUNCTIONS */
     482
     483    $('.sectionHeader').click(function () {
     484        console.log('section Header click *');
     485        getXSLT("sectionHeader");
     486        return false; //don't event bubble
     487    });
     488
     489    $('.sectionContainer').click(function () {
     490        console.log('section Container click *');
     491        getXSLT("sectionContainer");
     492        return false; // don't event bubble
     493    });
     494
    346495    /*
    347496    var iframe = document.getElementById('iframe');
     
    567716    //$('.tr').resize_tables($(this)); //equalHeights();
    568717
     718    $('#sectionHeader').click(function () {
     719         console.log('section Header click *');
     720         return true;
     721    });
    569722   
    570     $('td').click(function () {
    571          console.log('td click *');
    572          return false;
     723    $('#sectionContainer').click(function () {
     724         console.log('section Container click *');
     725         return true;
    573726    });
    574727
Note: See TracChangeset for help on using the changeset viewer.