blob: 9c81bf0c778f1dc2086d8651cca3e5f7430ccfe9 [file] [log] [blame]
Leo Reppd162b2e2021-06-30 13:51:07 +02001requirejs.config({
2 baseUrl: '../js/src'
3});
4 // here alwaysmenu instead of normal menu, then + alwaysEntry
5require(['containermenu','menu/item', 'menu/prefix', 'menu/lengthField', 'selectMenu', 'hint/item', 'hint/lengthField',
6'container/container', 'container/containeritem'
7 ],
8function (containerMenuClass, itemClass, prefixClass, lengthFieldClass, selectMenuClass, hintItemClass, hintLengthField, containerClass, containerItemClass) {
9
10 /**
11 * Create own menu item class.
12 */
13 var OwnMenuItemClass = {
14 create : function (params) {
15 return Object.create(itemClass).upgradeTo(this)._init(params);
16 },
17
18 // content function
19 content : function (content) {
20 if (arguments.length === 1) {
21 this._content = content;
22 };
23 return this._content;
24 },
25
26 // enter or click
27 onclick : function () {
28 console.log(this._name);
29 },
30
31 // right arrow
32 further : function () {
33 console.log("Further: " + this._name);
34 },
35
36 // initialize item
37 _init : function (params) {
38 if (params[0] === undefined)
39 throw new Error("Missing parameters");
40
41 this._name = params[0];
42 this._content = document.createTextNode(this._name);
43 this._lcField = ' ' + this.content().textContent.toLowerCase();
44 this._i=0;
45 return this;
46 }
47 };
48
49
50 /**
51 * Create own conainerItem class.
52 */
53 var OwnContainerItemClass = {
54 create : function () {
55 var obj = containerItemClass.create()
56 .upgradeTo(this);
57 //._init();
58 obj.value="";
59 return obj;
60 },
61 add : function (letter) {
62 this.value+=letter;
63 },
64 clear : function () {
65 this.value = "";
66 },
67 further : function () {
68 this.value = this.value + this.value;
69 },
70 onclick : function () {
71 console.log('ContainerItem' + this.value);
72 console.log(this._i);
73 this._menu.limit(this._i);
74 this._menu.show();
75 },
76 element : function () {
77 // already defined
78 if (this._el !== undefined) return this._el;
79
80 // Create list item
81 const li = document.createElement("li");
82 li.innerHTML="CI";
83
84 // Connect action
85 if (this["onclick"] !== undefined) {
86 li["onclick"] = this.onclick.bind(this);
87 };
88 return this._el = li;
89 }
90 };
91 //List of items.
92 var ExampleItemList = new Array;
93 ExampleItemList.push(OwnContainerItemClass.create());
94 ExampleItemList.push(OwnContainerItemClass.create());
95 ExampleItemList[0].value = "Example Item 1";
96 ExampleItemList[0]._i = 3;
97 ExampleItemList[1]._i = 4;
98
99 //Own container class.
100 var OwnContainerClass = {
101 create : function (listOfContainerItems, params) {
102 console.log(containerClass);
103 return containerClass.create(listOfContainerItems, params)
104 .upgradeTo(this);
105 }
106 //Dont know what you would want to add though
107 // You could add the containerItemClass parameter here *if* you really wanted to.
108 };
109
110 /**
111 * Create own menu class.
112 */
113
114 var OwnMenu = {
115 create : function (list) {
116 const params = {
117 itemClass : OwnMenuItemClass,
118 prefixClass : prefixClass,
119 lengthFieldClass : lengthFieldClass,
120 containerClass : OwnContainerClass,
121 containerItemClass : OwnContainerItemClass
122 };
123 console.log("Am now in OwnMenu create",containerMenuClass);
124 console.log(ExampleItemList); // we learn, that it definetly has all the functions defined in alwaysmenu.js
125 var obj = containerMenuClass.create(list,params,ExampleItemList)
126 .upgradeTo(this);
127 //._init(list, params);
128 obj._firstActive = true;
129 console.log("OwnMenu Element",obj._el);
130 return obj;
131 }
132 };
133
134 var list = [
135 ["Constituency"],
136 ["Lemma"],
137 ["Morphology"],
138 ["Part-of-Speech"],
139 ["Syntax"]
140 ];
141
142 /**
143 var list = [
144 ['Titel', 'title', 'string'],
145 ['Untertitel', 'subTitle', 'string'],
146 ['Beschreibung', 'desc', 'string'],
147 ['Veröffentlichungsdatum', 'pubDate', 'date'],
148 ['Länge', 'length', 'integer'],
149 ['Autor', 'author', 'string'],
150 ['Genre', 'genre', 'string'],
151 ['corpusID', 'corpusID', 'string'],
152 ['docID', 'docID', 'string'],
153 ['textID', 'textID', 'string']
154 ];
155 */
156
157 var menu = OwnMenu.create(list);
158
159 /**
160 var largeMenu = OwnMenu.create([
161 // http://www.ids-mannheim.de/cosmas2/projekt/referenz/stts/morph.html
162 // http://nachhalt.sfb632.uni-potsdam.de/owl-docu/stts.html
163 // "$.", "$(", "$,"
164 ["ADJA","ADJA ", "Attributive Adjective"],
165 ["ADJD","ADJD ", "Predicative Adjective"],
166 ["ADV","ADV ", "Adverb"],
167 ["APPO","APPO ", "Postposition"],
168 ["APPR","APPR ", "Preposition"],
169 ["APPRART","APPRART ", "Preposition with Determiner"],
170 ["APZR","APZR ","Right Circumposition"],
171 ["ART","ART ", "Determiner"],
172 ["CARD","CARD ", "Cardinal Number"],
173 ["FM","FM ", "Foreign Material"],
174 ["ITJ","ITJ ", "Interjection"],
175 ["KOKOM","KOKOM ", "Comparison Particle"],
176 ["KON","KON ", "Coordinating Conjuncion"],
177 ["KOUI","KOUI ", "Subordinating Conjunction with 'zu'"],
178 ["KOUS","KOUS ", "Subordinating Conjunction with Sentence"],
179 ["NE","NE ", "Named Entity"],
180 ["NN","NN ", "Normal Nomina"],
181 ["PAV", "PAV ", "Pronominal Adverb"],
182 ["PDAT","PDAT ","Attributive Demonstrative Pronoun"],
183 ["PDS","PDS ", "Substitutive Demonstrative Pronoun"],
184 ["PIAT","PIAT ", "Attributive Indefinite Pronoun without Determiner"],
185 ["PIDAT","PIDAT ", "Attributive Indefinite Pronoun with Determiner"],
186 ["PIS","PIS ", "Substitutive Indefinite Pronoun"],
187 ["PPER","PPER ", "Personal Pronoun"],
188 ["PPOSAT","PPOSAT ", "Attributive Possessive Pronoun"],
189 ["PPOSS","PPOSS ", "Substitutive Possessive Pronoun"],
190 ["PRELAT","PRELAT ", "Attributive Relative Pronoun"],
191 ["PRELS","PRELS ", "Substitutive Relative Pronoun"],
192 ["PRF","PRF ", "Reflexive Pronoun"],
193 ["PROAV","PROAV ", "Pronominal Adverb"],
194 ["PTKA","PTKA ","Particle with Adjective"],
195 ["PTKANT","PTKANT ", "Answering Particle"],
196 ["PTKNEG","PTKNEG ", "Negation Particle"],
197 ["PTKVZ","PTKVZ ", "Separated Verbal Particle"],
198 ["PTKZU","PTKZU ", "'zu' Particle"],
199 ["PWAT","PWAT ", "Attributive Interrogative Pronoun"],
200 ["PWAV","PWAV ", "Adverbial Interrogative Pronoun"],
201 ["PWS","PWS ", "Substitutive Interrogative Pronoun"],
202 ["TRUNC","TRUNC ","Truncated"],
203 ["VAFIN","VAFIN ", "Auxiliary Finite Verb"],
204 ["VAIMP","VAIMP ", "Auxiliary Finite Imperative Verb"],
205 ["VAINF","VAINF ", "Auxiliary Infinite Verb"],
206 ["VAPP","VAPP ", "Auxiliary Perfect Participle"],
207 ["VMFIN","VMFIN ", "Modal Finite Verb"],
208 ["VMINF","VMINF ", "Modal Infinite Verb"],
209 ["VMPP","VMPP ", "Modal Perfect Participle"],
210 ["VVFIN","VVFIN ","Finite Verb"],
211 ["VVIMP","VVIMP ", "Finite Imperative Verb"],
212 ["VVINF","VVINF ", "Infinite Verb"],
213 ["VVIZU","VVIZU ", "Infinite Verb with 'zu'"],
214 ["VVPP","VVPP ", "Perfect Participle"],
215 ["XY", "XY ", "Non-Word"]
216 ]);
217 */
218 document.getElementById('menu').appendChild(menu.element());
219 //document.getElementById('largemenu').appendChild(largeMenu.element());
220
221 menu.limit(3).show(3);
222 menu.focus();
223
224 //largeMenu.limit(8).show(3);
225});