Changeset 3181


Ignore:
Timestamp:
07/23/13 17:54:14 (11 years ago)
Author:
sroth
Message:

Save user-specified REST URI value in nsPreferences variable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/serverDialogOverlay.xul

    r2782 r3181  
    11<?xml version="1.0" encoding="UTF-8" ?>
    2 <!-- TODO: move stylesheet sourcing to settingDialog.xul (test)  -->
    3 <?xml-stylesheet href="chrome://markingcollection/skin/annotator-skin/dasish.css" type="text/css"?>
    4 <!-- uncomment at a later stage, dtd file needs to be used for ENTITY translation -->
    5 <!-- <!DOCTYPE overlay SYSTEM "chrome://markingcollection/locale/markingcollection.dtd"> -->
    6 <overlay id="serverDialogOverlay"
    7          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    8          xmlns:html="http://www.w3.org/1999/xhtml">
     2<!DOCTYPE overlay [
     3<!ENTITY % markingcollectionDTD SYSTEM "chrome://markingcollection/locale/markingcollection.dtd" >
     4%markingcollectionDTD;
     5<!ENTITY % metaDTD SYSTEM "chrome://markingcollection/locale/marker.dtd" >
     6%metaDTD;
     7]>
     8<overlay
     9    id="serverDialogOverlay"
     10    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     11    xmlns:html="http://www.w3.org/1999/xhtml">
    912   
    1013    <script type="application/x-javascript" src="chrome://global/content/nsUserSettings.js" /> <!-- Required for access to the Preference Manager component. -->
     
    1215    <script type="application/x-javascript">
    1316    <![CDATA[
    14     // var def_title_mode;
    15     // var def_serverpathtext_mode;
    16     /*
    17      * var def_title_mode;
    18         var def_note_mode;
    19         function _markerDialogOverlayInit(aEvent){ ... }
    20        
    21         function _markerDialogOverlayDone(aEvent){ ... }
    22      */
    23    
    24     function _serverDialogOverlayServerSelectCommand(aEvent){
    25                 if(aEvent.target.id=="mcMarkerTitleFormat"){
    26                         document.getElementById("mcMarkerTitleFormatText").disabled = false;
    27                         document.getElementById("mcMarkerTitleFormatText").focus();
    28                 }else{
    29                         document.getElementById("mcMarkerTitleFormatText").disabled = true;
    30                         def_title_mode = aEvent.target.value;
    31                 }
    32                 nsPreferences.setUnicharPref("wiredmarker.marker.initdata.title", aEvent.target.value);
     17    var def_url_mode;
     18    function _serverDialogOverlayInit(aEvent) {
     19        var url_mode = nsPreferences.copyUnicharPref("wiredmarker.marker.initdata.url","WM_REST_DEFAULT");
     20        var url_format = nsPreferences.copyUnicharPref("wiredmarker.marker.initdata.url_format");
     21        document.getElementById("mcMarkerURLFormatText").disabled = true;
     22        switch(url_mode){
     23            case "WM_REST_DEFAULT":
     24                    document.getElementById("mcMarkerURLRadiogroup").selectedItem = document.getElementById("mcMarkerURLText");
     25                    break;
     26            case "WM_REST_UserDefined":
     27                    document.getElementById("mcMarkerURLRadiogroup").selectedItem = document.getElementById("mcMarkerURLFormat");
     28                    document.getElementById("mcMarkerURLFormatText").disabled = false;
     29                    break;
     30        }
     31        if(url_format) document.getElementById("mcMarkerURLFormatText").value = url_format;
     32       
     33        def_url_mode = url_mode;
    3334    }
    3435   
    35     // window.addEventListener("load", _markerDialogOverlayInit, false);
    36     // window.addEventListener("unload", _markerDialogOverlayDone, false);
     36    function _serverDialogOverlayDone(aEvent) {
     37        var value = document.getElementById("mcMarkerURLFormatText").value;
     38        value = value.replace(/^\s+/g,"").replace(/\s+$/g,"");
     39        if(value == "") nsPreferences.setUnicharPref("wiredmarker.marker.initdata.url", def_url_mode);
     40    }
    3741   
     42    function _markerDialogOverlayURLCommand(aEvent){
     43        if(aEvent.target.id=="mcMarkerURLFormat"){
     44                document.getElementById("mcMarkerURLFormatText").disabled = false;
     45                document.getElementById("mcMarkerURLFormatText").focus();
     46        }else{
     47                document.getElementById("mcMarkerURLFormatText").disabled = true;
     48                def_url_mode = aEvent.target.value;
     49        }
     50        nsPreferences.setUnicharPref("wiredmarker.marker.initdata.url", aEvent.target.value);
     51    }
    3852   
     53    function _markerDialogOverlayURLInput(aEvent){
     54        nsPreferences.setUnicharPref("wiredmarker.marker.initdata.url_format", aEvent.target.value);
     55    }
    3956   
     57    window.addEventListener("load", _serverDialogOverlayInit, false);
     58    window.addEventListener("unload", _serverDialogOverlayDone, false);
     59       
    4060    ]]>
    41     </script>
    42  
    43     <!-- +++ TODO +++ -->     
    44     <!-- TODO (script section above): if default is selected User-spec field cannot be written to; if user spec field radio is selected cursor gets to user spec textbox, textbox becomes writable (like in markerinitDataDialogOverlay.xul) -->   
    45     <!-- +++ END: TODO +++ --> 
     61    </script> 
    4662 
    4763    <!-- container used to display a set of tabbed pages of elements -->
     
    4965   
    5066        <!-- Create server top level tab in settings window. -->
    51         <tabs id="mcSettingTabs">
    52             <!-- use <!ENTITY markingcollection.server.tab "Server"> in markingcollection.dtd; i.e. label="&markingcollection.server.tab;"  -->
    53             <tab id="mcServerTab" label="Server" image="chrome://markingcollection/skin/annotator-skin/server.png"/>
     67        <tabs id="mcSettingTabs">     
     68            <tab id="mcServerTab" label="&markingcollection.server.tab;" image="chrome://markingcollection/skin/annotator-skin/server.png"/>
    5469        </tabs>         
    5570   
     
    6479                   
    6580                    <!-- caption appears along the top of the parent groupbox -->
    66                     <caption label="Select the back-end server for the annotation client" id="selectServerGbCaption"/>
     81                    <caption label="&markingcollection.server.groupbox.caption;" id="selectServerURLCaption"/>
    6782                       
    6883                    <!-- hbox element can contain any number of child elements, this container element defaults to horizontal orientation -->
    6984                    <hbox>
    7085                       
    71                         <!-- <radiogroup id="mcMarkerTitleRadiogroup" oncommand="_markerDialogOverlayTitleCommand(event);"> -->
    7286                        <!-- radiogroup element comprises a group of radio buttons, only one radio button inside the group can be selected at a time, defaults to vertical orientation -->
    73                         <radiogroup flex="1" id="mcServerRadiogroup" oncommand="_serverDialogOverlayServerSelectCommand(event);">
    74  
     87                        <radiogroup flex="1" id="mcMarkerURLRadiogroup" oncommand="_markerDialogOverlayURLCommand(event);">
    7588                            <grid>
    7689                               
     
    8396
    8497                                    <row>
    85                                         <radio id="defaultServerRadio" value="valid" label="Default" selected="true"/>
    86                                         <textbox id="defaultServerTextbox" value="http://pelle.ssd.gu.se:8080/exist/rest/db/annotation-framework/api/annotations.xql" readonly="true" onfocus="this.select()"/>
     98                                        <radio id="mcMarkerURLText" value="WM_REST_DEFAULT" label="&markingcollection.server.rest.default;" selected="true"/>
     99                                        <textbox value="http://pelle.ssd.gu.se:8080/exist/rest/db/annotation-framework/api/annotations.xql" readonly="true" onfocus="this.select()"/>
    87100                                    </row>
    88101                                       
    89102                                    <row>
    90                                         <radio id="userSpecifiedServerRadio" value="valid" label="User-specified"/>
    91                                         <textbox id="userSpecifiedServerTextbox" onfocus="this.select()"/>
     103                                        <radio id="mcMarkerURLFormat" value="WM_REST_UserDefined" label="&markingcollection.server.rest.userdefined;"/>
     104                                        <textbox id="mcMarkerURLFormatText" onfocus="this.select()" disabled="true" onchange="_markerDialogOverlayURLInput(event);"/>
    92105                                    </row>
    93106                                   
Note: See TracChangeset for help on using the changeset viewer.