blob: e3b0f993ceaff8cf5614bb0705b35a8bb6d97bce [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());
Leo Reppc66268e2021-10-28 11:44:35 +020095 ExampleItemList.push(OwnContainerItemClass.create());
Leo Reppd162b2e2021-06-30 13:51:07 +020096 ExampleItemList[0].value = "Example Item 1";
97 ExampleItemList[0]._i = 3;
98 ExampleItemList[1]._i = 4;
Leo Reppc66268e2021-10-28 11:44:35 +020099 ExampleItemList[2].value = "Remove the Prefix Test";
100 ExampleItemList[2]._i=5;
101 ExampleItemList[2].onclick = function (e) {
102 this._menu.container().removeItemByIndex(3);
103 };
Leo Reppd162b2e2021-06-30 13:51:07 +0200104
105 //Own container class.
106 var OwnContainerClass = {
107 create : function (listOfContainerItems, params) {
108 console.log(containerClass);
109 return containerClass.create(listOfContainerItems, params)
110 .upgradeTo(this);
111 }
112 //Dont know what you would want to add though
113 // You could add the containerItemClass parameter here *if* you really wanted to.
114 };
115
116 /**
117 * Create own menu class.
118 */
119
120 var OwnMenu = {
121 create : function (list) {
122 const params = {
123 itemClass : OwnMenuItemClass,
124 prefixClass : prefixClass,
125 lengthFieldClass : lengthFieldClass,
126 containerClass : OwnContainerClass,
127 containerItemClass : OwnContainerItemClass
128 };
129 console.log("Am now in OwnMenu create",containerMenuClass);
130 console.log(ExampleItemList); // we learn, that it definetly has all the functions defined in alwaysmenu.js
131 var obj = containerMenuClass.create(list,params,ExampleItemList)
132 .upgradeTo(this);
133 //._init(list, params);
134 obj._firstActive = true;
135 console.log("OwnMenu Element",obj._el);
136 return obj;
137 }
138 };
139
140 var list = [
141 ["Constituency"],
142 ["Lemma"],
143 ["Morphology"],
144 ["Part-of-Speech"],
145 ["Syntax"]
146 ];
147
148 /**
149 var list = [
150 ['Titel', 'title', 'string'],
151 ['Untertitel', 'subTitle', 'string'],
152 ['Beschreibung', 'desc', 'string'],
153 ['Veröffentlichungsdatum', 'pubDate', 'date'],
154 ['Länge', 'length', 'integer'],
155 ['Autor', 'author', 'string'],
156 ['Genre', 'genre', 'string'],
157 ['corpusID', 'corpusID', 'string'],
158 ['docID', 'docID', 'string'],
159 ['textID', 'textID', 'string']
160 ];
161 */
162
163 var menu = OwnMenu.create(list);
164
165 /**
166 var largeMenu = OwnMenu.create([
167 // http://www.ids-mannheim.de/cosmas2/projekt/referenz/stts/morph.html
168 // http://nachhalt.sfb632.uni-potsdam.de/owl-docu/stts.html
169 // "$.", "$(", "$,"
170 ["ADJA","ADJA ", "Attributive Adjective"],
171 ["ADJD","ADJD ", "Predicative Adjective"],
172 ["ADV","ADV ", "Adverb"],
173 ["APPO","APPO ", "Postposition"],
174 ["APPR","APPR ", "Preposition"],
175 ["APPRART","APPRART ", "Preposition with Determiner"],
176 ["APZR","APZR ","Right Circumposition"],
177 ["ART","ART ", "Determiner"],
178 ["CARD","CARD ", "Cardinal Number"],
179 ["FM","FM ", "Foreign Material"],
180 ["ITJ","ITJ ", "Interjection"],
181 ["KOKOM","KOKOM ", "Comparison Particle"],
182 ["KON","KON ", "Coordinating Conjuncion"],
183 ["KOUI","KOUI ", "Subordinating Conjunction with 'zu'"],
184 ["KOUS","KOUS ", "Subordinating Conjunction with Sentence"],
185 ["NE","NE ", "Named Entity"],
186 ["NN","NN ", "Normal Nomina"],
187 ["PAV", "PAV ", "Pronominal Adverb"],
188 ["PDAT","PDAT ","Attributive Demonstrative Pronoun"],
189 ["PDS","PDS ", "Substitutive Demonstrative Pronoun"],
190 ["PIAT","PIAT ", "Attributive Indefinite Pronoun without Determiner"],
191 ["PIDAT","PIDAT ", "Attributive Indefinite Pronoun with Determiner"],
192 ["PIS","PIS ", "Substitutive Indefinite Pronoun"],
193 ["PPER","PPER ", "Personal Pronoun"],
194 ["PPOSAT","PPOSAT ", "Attributive Possessive Pronoun"],
195 ["PPOSS","PPOSS ", "Substitutive Possessive Pronoun"],
196 ["PRELAT","PRELAT ", "Attributive Relative Pronoun"],
197 ["PRELS","PRELS ", "Substitutive Relative Pronoun"],
198 ["PRF","PRF ", "Reflexive Pronoun"],
199 ["PROAV","PROAV ", "Pronominal Adverb"],
200 ["PTKA","PTKA ","Particle with Adjective"],
201 ["PTKANT","PTKANT ", "Answering Particle"],
202 ["PTKNEG","PTKNEG ", "Negation Particle"],
203 ["PTKVZ","PTKVZ ", "Separated Verbal Particle"],
204 ["PTKZU","PTKZU ", "'zu' Particle"],
205 ["PWAT","PWAT ", "Attributive Interrogative Pronoun"],
206 ["PWAV","PWAV ", "Adverbial Interrogative Pronoun"],
207 ["PWS","PWS ", "Substitutive Interrogative Pronoun"],
208 ["TRUNC","TRUNC ","Truncated"],
209 ["VAFIN","VAFIN ", "Auxiliary Finite Verb"],
210 ["VAIMP","VAIMP ", "Auxiliary Finite Imperative Verb"],
211 ["VAINF","VAINF ", "Auxiliary Infinite Verb"],
212 ["VAPP","VAPP ", "Auxiliary Perfect Participle"],
213 ["VMFIN","VMFIN ", "Modal Finite Verb"],
214 ["VMINF","VMINF ", "Modal Infinite Verb"],
215 ["VMPP","VMPP ", "Modal Perfect Participle"],
216 ["VVFIN","VVFIN ","Finite Verb"],
217 ["VVIMP","VVIMP ", "Finite Imperative Verb"],
218 ["VVINF","VVINF ", "Infinite Verb"],
219 ["VVIZU","VVIZU ", "Infinite Verb with 'zu'"],
220 ["VVPP","VVPP ", "Perfect Participle"],
221 ["XY", "XY ", "Non-Word"]
222 ]);
223 */
224 document.getElementById('menu').appendChild(menu.element());
225 //document.getElementById('largemenu').appendChild(largeMenu.element());
226
227 menu.limit(3).show(3);
228 menu.focus();
229
230 //largeMenu.limit(8).show(3);
231});