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+
128+ </ html >
0 commit comments