Adding client editor module to apex-pdp
[policy/apex-pdp.git] / client / client-editor / src / main / resources / webapp / js / ApexResultForm.js
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 function resultForm_activate(formParent, formHeading, formText) {
22     apexUtils_removeElement("newModelDivBackground");
23
24     var contentelement = document.createElement("resultFormDiv");
25     var formDiv = document.createElement("div");
26     var backgroundDiv = document.createElement("div");
27     backgroundDiv.setAttribute("id", "newModelDivBackground");
28     backgroundDiv.setAttribute("class", "newModelDivBackground");
29
30     backgroundDiv.appendChild(formDiv);
31     contentelement.appendChild(backgroundDiv);
32     formParent.appendChild(contentelement);
33
34     formDiv.setAttribute("id", "resultFormDiv");
35     formDiv.setAttribute("class", "resultFormDiv");
36
37     var headingSpan = document.createElement("span");
38     formDiv.appendChild(headingSpan);
39
40     headingSpan.setAttribute("class", "headingSpan");
41     headingSpan.innerHTML = formHeading;
42
43     var form = document.createElement("resultForm");
44     formDiv.appendChild(form);
45
46     form.setAttribute("id", "resultForm");
47     form.setAttribute("class", "form-style-1");
48     form.setAttribute("method", "post");
49
50     var ul = document.createElement("ul");
51     form.appendChild(ul);
52
53     var resultTextLI = document.createElement("li");
54     form.appendChild(resultTextLI);
55
56     var resultTextLabel = document.createElement("label");
57     resultTextLI.appendChild(resultTextLabel);
58     resultTextLabel.setAttribute("for", "resultFormTextArea");
59     resultTextLabel.innerHTML = "resultText: ";
60
61     var resultTextArea = document.createElement("textarea");
62     resultTextLI.appendChild(resultTextArea);
63
64     resultTextArea.setAttribute("id", "resultFormTextArea");
65     resultTextArea.setAttribute("resultText", "resultFormTextArea");
66     resultTextArea.setAttribute("class", "field-long field-textarea ebTextArea ebTextArea_width_full eb_scrollbar");
67     resultTextArea.setAttribute("readonly", "readonly");
68     resultTextArea.style.cursor = "text";
69
70     resultTextArea.value = formText;
71
72     var inputLI = document.createElement("li");
73     form.appendChild(inputLI);
74
75     var okInput = document.createElement("input");
76     inputLI.appendChild(okInput);
77
78     okInput.setAttribute("id", "generateDescription");
79     okInput.setAttribute("class", "okButton ebBtn");
80     okInput.setAttribute("type", "submit");
81     okInput.setAttribute("value", "OK");
82
83     okInput.onclick = resultForm_okPressed;
84 }
85
86 function resultForm_okPressed() {
87     apexUtils_removeElement("newModelDivBackground");
88 }