-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcon29.js
More file actions
137 lines (103 loc) · 3.32 KB
/
con29.js
File metadata and controls
137 lines (103 loc) · 3.32 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import { html,LitElement} from 'https://cdn.jsdelivr.net/gh/lit/dist@2/all/lit-all.min.js';
// define the component
export class HelloWorld extends LitElement {
static properties = {
jsondata: {type: String},
value: {type: String},
};
_greet() {
debugger;
}
_answered(a)
{
debugger;
//set answer, set new question
window.document.questionJSON.questions[window.document.questionJSON.idx].answer = a.innerText;
window.document.questionJSON.idx++;
if (window.document.questionJSON.questions.length == window.document.questionJSON.idx)
{
$('.question-title').html("Thank you for answer the questions. Can you now submit the form.");
$('.answer').toggle();
} else {
$('.question-title').html((window.document.questionJSON.idx + 1) + ". - " + window.document.questionJSON.questions[window.document.questionJSON.idx].title);
}
}
static getData() {
return {
controlName: 'Hello World',
fallbackDisableSubmit: false,
version: '1.2',
properties: {
jsondata: {
type: 'string',
title: 'JSON Data',
description: 'JSON structure for the ',
maxLength: 999999,
},
value: {
type: 'string',
title: 'JSON Result',
description: 'JSON structure for the ',
maxLength: 999999,
}
}
};
}
// return a promise for contract changes.
static getMetaConfig() {
return {
controlName: 'Hello World',
fallbackDisableSubmit: false,
version: '1.2',
properties: {
jsondata: {
type: 'string',
title: 'JSON Data',
description: 'JSON structure for the ',
maxLength: 999999,
},
value: {
type: 'string',
title: 'JSON Result',
description: 'JSON structure for the ',
maxLength: 999999,
}
}
};
}
constructor() {
super();
// this.who = 'World';
//put JSON in dom and work of it.
//that way when we update it it won't refresh the control.
//
// this
debugger;
setTimeout(function() {
//JSON.parse($('hello-world').shadowRoot.querySelector('#data').textContent)
}, 2000);
}
render() {
debugger;
window.document.questionJSON = this.jsondata;
//try and pass this.jsondata.
//if there is an issue then set error message and set default JSON
//write out first question and answers
window.document.questionJSON = this.json;
window.document.questionJSON.idx = 0;
var container = "";
container += "<span class='question' idx='1'><p class='question-title'>1. - " + window.document.questionJSON.questions[0].title + "</p></span>";
for (let i = 0; i < window.document.questionJSON.answers.length; i++) {
container += "<span class='answer' @click=${this._answered(this)} idx='0'><p class='answer-title'>" + window.document.questionJSON.answers[i].title + "</p></span>"
}
}
return html`
<div id="jsondata" ></div>
<div id="data">${this.jsondata}</div>
<button @click=${this._answered(this)}>Greet</button>
${container}`;
}
}
// registering the web component
const elementName = 'hello-world';
customElements.define(elementName, HelloWorld);