New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
2018WP/FormCode (diff) – NEMO

Changes between Initial Version and Version 1 of 2018WP/FormCode


Ignore:
Timestamp:
2017-12-07T23:01:03+01:00 (6 years ago)
Author:
nicolasmartin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • 2018WP/FormCode

    v1 v1  
     1{{{#!html 
     2<form id="wp_action"> 
     3  <table> 
     4    <tbody> 
     5      <tr> 
     6        <td> 
     7          <fieldset style="height: 15em;"> 
     8            <legend> 
     9              Action name 
     10            </legend> 
     11            <table> 
     12              <tbody style="vertical-align: inherit;"> 
     13                <tr> 
     14                  <td> 
     15                    Scope 
     16                  </td> 
     17                  <td> 
     18                    <select id="realm" onchange="val()" required> 
     19                      <option value=""              ></option                       > 
     20                      <optgroup label="Institute"> 
     21                        <option value="CMCC"          >CMCC</option                   > 
     22                        <option value="CNRS"          >CNRS-INSU</option              > 
     23                        <option value="INGV"          >INGV</option                   > 
     24                        <option value="Mercator_Ocean">Mercator Océan</option         > 
     25                        <option value="Met_Office"    >Met Office</option             > 
     26                        <option value="NOC"           >NERC-NOC</option               > 
     27                      </optgroup> 
     28                      <optgroup label="Streams"  > 
     29                        <option value="AGRIF"         >AGRIF</option                  > 
     30                        <option value="ENHANCE"       >Enhancement</option            > 
     31                        <option value="HPC"           >HPC</option                    > 
     32                        <option value="PUBLI"         >Publication</option            > 
     33                        <option value="ROBUST"        >Robustness - Test Cases</option> 
     34                        <option value="SEAICE"        >Sea-Ice</option                > 
     35                        <option value="VALID"         >Validation</option             > 
     36                      </optgroup> 
     37                    </select> 
     38                    <br> 
     39                    <span class="hint">Institute for specific actions, Stream for shared actions</span> 
     40                  </td> 
     41                </tr> 
     42                <tr> 
     43                  <td> 
     44                    Number 
     45                  </td> 
     46                  <td> 
     47                    <select id="increment" onchange="val()"></select> 
     48                    <br> 
     49                    <span class="hint">Check the tables above to define open number</span> 
     50                  </td> 
     51                </tr> 
     52                <tr> 
     53                  <td> 
     54                    Suffix 
     55                  </td> 
     56                  <td> 
     57                    <input type="text" id="suffix" placeholder="Name(s)-Keyword(s)" required> 
     58                    <br> 
     59                    <span class="hint">Identify quickly PI(s) and field(s)</span> 
     60                  </td> 
     61                </tr> 
     62                <tr> 
     63                  <td> 
     64                    <em>Preview</em> 
     65                  </td> 
     66                  <td> 
     67                    <em id="name_preview"></em> 
     68                  </td> 
     69                </tr> 
     70              </tbody> 
     71            </table> 
     72          </fieldset> 
     73        <td> 
     74          <fieldset style="height: 15em; display: grid;"> 
     75            <legend> 
     76              Reset/Submit 
     77            </legend> 
     78            <input type="hidden" name="summary"     value=""               id="summary"> 
     79            <input type="hidden" name="type"        value="Task"                       > 
     80            <input type="hidden" name="milestone"   value="2018 WP"                    > 
     81            <input type="hidden" name="version"     value="trunk"                      > 
     82            <input type="hidden" name="action"      value="edit"                       > 
     83            <input type="hidden" name="template"    value="WorkPlanAction"             > 
     84            <table> 
     85              <tbody> 
     86                <tr> 
     87                  <td style="text-align: center;"> 
     88                    <button type="reset" onclick="resetForm();">Reset</button> 
     89                  </td> 
     90                  <td> 
     91                    <span class="hint">Clear form</span> 
     92                  </td> 
     93                </tr> 
     94                <tr> 
     95                  <td style="text-align: center;"> 
     96                    <input  type="submit" id="form_wiki"   value="Wiki"   formtarget="_blank" formaction="/nemo/wiki/2018WP/__REPLACE_DYNAMICALLY__"> 
     97                  </td> 
     98                  <td> 
     99                    <span class="hint">Create action page in a new tab</span> 
     100                  </td> 
     101                </tr> 
     102                <tr> 
     103                  <td style="text-align: center;"> 
     104                    <input  type="submit" id="form_ticket" value="Ticket" formtarget="_blank" formaction="/nemo/newticket"                              > 
     105                  </td> 
     106                  <td> 
     107                    <span class="hint">Create action ticket in a new tab</span> 
     108                  </td> 
     109                </tr> 
     110              </tbody> 
     111            </table> 
     112          </fieldset> 
     113        </td> 
     114      </tr> 
     115    </tbody> 
     116  </table> 
     117</form> 
     118 
     119<script type="text/javascript"> 
     120 
     121  // Global variable for action name 
     122  var action_name; 
     123 
     124  // Leading zeros for number 
     125  function padWithZeroes(n, width) { while ( n.length < width ) n = '0' + n; return n; } 
     126 
     127  // Auto-generated numbers sequence for select input 
     128  for(var i=1; i<=20; i++){ 
     129    var select = document.getElementById("increment"); var option = document.createElement("option"); 
     130    select.options.add(option); 
     131    option.text = i; option.value = padWithZeroes(i.toString(), 2); 
     132  } 
     133 
     134  // Build the real action name by concatenating the form inputs 
     135  function val() { 
     136    var realm = $("#realm").val(); var inc = $("#increment").val(); var suffix = $("#suffix").val(); 
     137    action_name = realm + '-' + inc + '_' + suffix; 
     138    $("#name_preview").text(action_name); $("#summary").val(action_name); 
     139  } 
     140 
     141  // Update name preview as typing 
     142  $("#suffix").keyup (function() { val(); }); 
     143 
     144  function resetForm(){ setTimeout(function(){ val(); }, 50); } 
     145 
     146  // Set wiki page name on the fly 
     147  $("#wp_action").submit(function() { 
     148    var form_action = $("#form_wiki").attr("formaction"); 
     149    form_action = form_action.replace("__REPLACE_DYNAMICALLY__", action_name); 
     150    $("#form_wiki").attr("formaction", form_action); 
     151  }); 
     152 
     153</script> 
     154}}}