1- <!DOCTYPE html>
2- < html lang ="en ">
3-
4- < head >
5- < meta charset ="utf-8 ">
6- < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
7- < title > Comi-Combobox</ title >
8- < link rel ="icon " href ="icon.png " />
9- < script src ="lib/jquery-3.6.0.js "> </ script >
10- < script src ="webcc.min.js "> </ script >
11- < script src ="unified.interface.js "> </ script >
12-
13- < script >
14- var production = true ;
15-
16- function init ( result ) {
17- if ( result ) {
18- unifiedInterfaceInit ( ) ;
19- selectInit ( WebCC . Properties ) ;
20- } else {
21- console . log ( 'Comi-Combobox: Init without result.' ) ;
22- }
23- }
24-
25- window . onload = function ( ) {
26- ////////////////////////////////////////////////////////////////////////////////
27- // DEMO
28- if ( ! production ) {
29- WebCC . Properties = {
30-
31- current : "" ,
32- rows : [
33- [ "element1" ] ,
34- [ "element2" ] ,
35- [ "element3" ] ,
36- [ "element4" ]
37- ] ,
38- fontSize : 30
39- } ;
40- init ( true ) ;
41- }
42- ////////////////////////////////////////////////////////////////////////////////
43- // PRODUCTION
44- if ( production ) {
45- WebCC . start ( init , UnifiedInterface . HostListener , _extensions , _timeout ) ;
46- }
47- }
48- </ script >
49- < style >
50- select {
51- height : 30px ;
52- min-width : 200px ;
53- width : 100% ;
54- border-radius : 5px ;
55- font-family : 'Montserrat' ;
56- font-size : 15pt ;
57- }
58- </ style >
59- </ head >
60-
61- < body >
62- < select id ="dave-select " onchange ="selectOption() ">
63-
64- </ select >
65-
66-
67- < script >
68- var $sel = $ ( '#dave-select' ) ;
69-
70- var selectInit = function ( props ) {
71-
72- // load and parse rows
73- if ( props . hasOwnProperty ( 'rows' ) && props . rows != null ) {
74- if ( typeof props . rows === 'string' ) {
75- propsRows = JSON . parse ( props . rows ) ;
76- } else if ( Array . isArray ( props . rows ) ) {
77- propsRows = props . rows ;
78- } else {
79- console . log ( 'Comi-Select: WRONG FORMAT: rows' ) ;
80- }
81- } else {
82- return ;
83- }
84-
85- // clear select
86- $sel . empty ( ) ;
87-
88- // populate rows
89- if ( propsRows . length > 0 ) {
90- let $optionEmpty = $ ( '<option>' ) ;
91-
92- $optionEmpty . val ( '' ) ;
93- $optionEmpty . text ( '' ) ;
94- $sel . append ( $optionEmpty ) ;
95-
96- for ( let i = 0 ; i < propsRows . length ; i ++ ) {
97- let $option = $ ( '<option>' ) ;
98-
99- $option . val ( propsRows [ i ] ) ;
100- $option . text ( propsRows [ i ] ) ;
101-
102-
103- if ( props . current == propsRows [ i ] ) {
104- $option . prop ( "selected" , true )
105- }
106- $sel . append ( $option ) ;
107- }
108- }
109-
110-
111- }
112- function selectOption ( ) {
113- var $sel = $ ( '#dave-select' ) ;
114- var value = $sel . val ( ) ;
115- fireEvent ( "ev_selectElement" , $sel . val ( ) )
116- }
117-
118- // fire event to winCC
119- function fireEvent ( ev , args ) {
120- if ( WebCC && WebCC . Events ) {
121- WebCC . Events . fire ( ev , JSON . stringify ( args ) ) ;
122- }
123- }
124- </ script >
125-
126- </ body >
127-
1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+
4+ < head >
5+ < meta charset ="utf-8 ">
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
7+ < title > Select</ title >
8+ < link rel ="icon " href ="icon.png " />
9+ < script src ="lib/jquery-3.6.0.js "> </ script >
10+ < script src ="webcc.min.js "> </ script >
11+ < script src ="unified.interface.js "> </ script >
12+
13+ < script >
14+ var production = true ;
15+
16+ function init ( result ) {
17+ if ( result ) {
18+ unifiedInterfaceInit ( ) ;
19+ selectInit ( WebCC . Properties ) ;
20+ } else {
21+ console . log ( 'Select: Init without result.' ) ;
22+ }
23+ }
24+
25+ window . onload = function ( ) {
26+ if ( ! production ) {
27+ WebCC . Properties = {
28+ current : "element1" ,
29+ rows : [
30+ [ "element1" ] ,
31+ [ "element2" ] ,
32+ [ "element3" ] ,
33+ [ "element4" ]
34+ ]
35+ } ;
36+ init ( true ) ;
37+ }
38+ if ( production ) {
39+ WebCC . start ( init , UnifiedInterface . HostListener , _extensions , _timeout ) ;
40+ }
41+ }
42+ </ script >
43+ < style >
44+ select {
45+ height : 30px ;
46+ min-width : 200px ;
47+ width : 100% ;
48+ border-radius : 5px ;
49+ font-family : 'Montserrat' ;
50+ font-size : 15pt ;
51+ }
52+ </ style >
53+ </ head >
54+
55+ < body >
56+ < select id ="dave-select " onchange ="selectOption() ">
57+
58+ </ select >
59+
60+
61+ < script >
62+ var $sel = $ ( '#dave-select' ) ;
63+
64+ var selectInit = function ( props ) {
65+
66+ // load and parse rows
67+ if ( props . hasOwnProperty ( 'rows' ) && props . rows != null ) {
68+ if ( typeof props . rows === 'string' ) {
69+ propsRows = JSON . parse ( props . rows ) ;
70+ } else if ( Array . isArray ( props . rows ) ) {
71+ propsRows = props . rows ;
72+ } else {
73+ console . log ( 'Select: WRONG FORMAT: rows' ) ;
74+ }
75+ } else {
76+ return ;
77+ }
78+
79+ // clear select
80+ $sel . empty ( ) ;
81+
82+ // populate rows
83+ if ( propsRows . length > 0 ) {
84+ let $optionEmpty = $ ( '<option>' ) ;
85+ $optionEmpty . val ( '' ) ;
86+ $optionEmpty . text ( '' ) ;
87+ $sel . append ( $optionEmpty ) ;
88+
89+ for ( let i = 0 ; i < propsRows . length ; i ++ ) {
90+ let $option = $ ( '<option>' ) ;
91+
92+ $option . val ( propsRows [ i ] ) ;
93+ $option . text ( propsRows [ i ] ) ;
94+
95+
96+ if ( props . current == propsRows [ i ] ) {
97+ $option . prop ( "selected" , true )
98+ }
99+ $sel . append ( $option ) ;
100+ }
101+ }
102+
103+ }
104+ function selectOption ( ) {
105+ var $sel = $ ( '#dave-select' ) ;
106+ var value = $sel . val ( ) ;
107+ fireEvent ( "ev_selectElement" , $sel . val ( ) )
108+ }
109+
110+ // fire event to winCC
111+ function fireEvent ( ev , args ) {
112+ if ( WebCC && WebCC . Events ) {
113+ WebCC . Events . fire ( ev , JSON . stringify ( args ) ) ;
114+ }
115+ }
116+ </ script >
117+
118+ </ body >
119+
128120</ html >
0 commit comments