Add default texts for input fields with AJAX.
[Sone.git] / src / main / resources / templates / include / createSone.html
1 <script language="javascript">
2         $(document).ready(function() {
3                 registerInputTextareaSwap("#sone #create-sone input[name=name]", "WebInterface.DefaultText.CreateSoneName", "name", false);
4                 registerInputTextareaSwap("#sone #create-sone input[name=document-name]", "WebInterface.DefaultText.CreateSoneDocumentName", "document-name", false);
5                 registerInputTextareaSwap("#sone #create-sone input[name=insert-uri]", "WebInterface.DefaultText.CreateSoneInsertURI", "insert-uri", true);
6                 registerInputTextareaSwap("#sone #create-sone input[name=request-uri]", "WebInterface.DefaultText.CreateSoneRequestURI", "request-uri", true);
7
8                 /* hide all the labels. */
9                 $("#sone #create-sone label").hide();
10
11                 /* now hide the “advanced” section. */
12                 advancedSection = $("#sone #create-sone .advanced");
13                 advancedSection.hide();
14
15                 /* show a checkbox instead. */
16                 checkboxSection = $("<div></div>");
17                 checkbox = $("<input type=\"checkbox\" />").click(function() {
18                         if (this.checked) {
19                                 advancedSection.show();
20                                 $("#sone #create-sone button[name=create-random]").hide();
21                         } else {
22                                 advancedSection.hide();
23                                 $("#sone #create-sone button[name=create-random]").show();
24                         }
25                 })
26                 checkboxSection.append(checkbox).append("Show advanced settings");
27                 advancedSection.before(checkboxSection);
28         });
29 </script>
30
31 <form id="create-sone" action="createSone.html" method="post">
32         <input type="hidden" name="formPassword" value="<% formPassword|html>" />
33         <div<%if errorName> class="error"<%/if>>
34                 <label for="name"><%= Page.Login.CreateSone.Label.Name|l10n|html></label>
35                 <input type="text" name="name" value="<% name|html>"/>
36         </div>
37         <div>
38                 <label for="document-name"><%= Page.Login.CreateSone.Label.DocumentName|l10n|html></label>
39                 <input type="text" name="document-name" value="<% documentName|html>" />
40         </div>
41         <div>
42                 <button type="submit" name="create-random" value="1"><%= Page.Login.CreateSone.Button.CreateRandom|l10n|html></button>
43         </div>
44         <div class="advanced">
45                 <div<%if errorUri> class="error"<%/if>>
46                         <label for="insert-uri"><%= Page.Login.CreateSone.Label.RequestURI|l10n|html></label>
47                         <input type="text" name="insert-uri" value="<% insertUri|html>" />
48                 </div>
49                 <div<%if errorUri> class="error"<%/if>>
50                         <label for="insert-uri"><%= Page.Login.CreateSone.Label.InsertURI|l10n|html></label>
51                         <input type="text" name="insert-uri" value="<% requestUri|html>" />
52                 </div>
53                 <div>
54                         <button type="submit" name="create-from-uri" value="1"><%= Page.Login.CreateSone.Button.CreateFromURI|l10n|html></button>
55                 </div>
56         </div>
57 </form>