-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcon26.js
More file actions
174 lines (132 loc) · 3.88 KB
/
con26.js
File metadata and controls
174 lines (132 loc) · 3.88 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
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`
<style>
.question {
font-size: 20px;
margin: 5px auto;
max-width: 530px;
min-width: 530px;
display: block;
font-weight: bold;
}
.answer {
border-radius: 6px;
box-shadow: 0 1px 3px rgba(0,0,0,.2);
font-size: 16px;
margin: 5px auto;
max-width: 530px;
min-width: 530px;
display: block;
cursor: pointer;
border: 1px solid transparent;
}
.answer:hover {
border: 1px solid cornflowerblue;
background-color: aliceblue;
transition: .8s;
}
.answer-title {
padding-left: 10px;
}
</style>
<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);