summaryrefslogtreecommitdiff
path: root/website/templates/canned_responses.html
blob: ad08ae0487be15438353fb7fdf03c20fed9c65ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<html>
  <head>
    <style>
      blockquote {
        margin: 1em;
        padding: 1ex;
        background-color: #EEE;
      }

      ul#list {
        list-style-type: none;
        padding: 0;
        margin: 0;
      }

      ul#list li {
      }

      td.evaltext {
      }

      td.evalform {
        vertical-align: top;
      }

      textarea#reply {
      }
    </style>
    <script src="jquery-2.2.3.min.js"></script>
    <script src="canned_responses.js"></script>
  </head>
  <body>

    <table class="eval">
      <tr>
        <td class="evalform">
          <form id="evalform">
            Submitter's name:
            <input type="text" name="submitter_name" id="submitter_name"
                   onchange="javascript:update_text(this);"><br/>

            Project Name:
            <input type="text" name="projname" id="projname"
                   onchange="javascript:update_text(this);"><br/>

            Savannah Request Number:
            <input type="text" name="regnum" id="regnum"
                   onchange="javascript:update_text(this);"><br/>

            <br/>
            <ul id="list">
            </ul>
          </form>
        </td>

        <td class="evaltext">
          Suggested Reply:
          <br/>
          <textarea name="reply" id="reply" cols="50" rows="50"></textarea>
        </td>

      </tr>
    </table>

    <script>
      function update_text()
      {
        var user_name = $("#submitter_name").val().trim();
        var project_name = $("#projname").val().trim();
        var reg_num = $("#regnum").val().trim();

        var s = "" ;
        if (user_name) {
          s = "Hello " + user_name + ",\n\n";
        } else {
          s = "Hello,\n\n" ;
        }

        var regurl = (reg_num)?("http://savannah.gnu.org/task/?"+reg_num):"(missing URL)";


        gnu_sv_eval_canned_responses.forEach(function(x){
          var id = "#cb_" + x.id ;
          var checked = $(id).is(':checked');
          if (checked) {
            s = s + x.long + "\n" ;
          }
        });

        s = s.replace("%projname%",project_name);
        s = s.replace("%regurl%",regurl);
      
        $("#reply").val(s);
      }

      $(document).ready(function(){

        var ol = $("#list");

        gnu_sv_eval_canned_responses.forEach(function(x){
          var html = "<li><label>" +
                     '<input type="checkbox" name="cb_' + x.id +
                             '" id="cb_' + x.id +
                             '" onchange="javascript:update_text(this);">' +
                     x.short +
                     '</label></li>';

          ol.append(html);
        });

      });

    </script>
  </body>
</html>