1 class SettingsWindow extends FeatureInterface{
2 background_div:any = document.createElement('DIV');
3 settings_div:any = document.createElement('DIV');
4 close_div:any = document.createElement('DIV');
5 contents_div = document.createElement('DIV');
6 ul_selection_start:any = document.createElement('UL');
8 close_link:any = document.createElement('A');
9 title_para:any = document.createElement('P');
10 title_text:any = document.createTextNode('4F-FSE Settings');
11 end_para:any = document.createElement('P');
12 end_text:any = document.createTextNode('Refresh to view changes');
14 settings_style:any = document.createElement('STYLE');
16 //to change order change, this AND...*
19 {Text : "View 『Image Hiding』 Settings", ListenerFunc : (a_id) => {
20 this.clearContainer();
21 (<Element>this.contents_div).innerHTML =
23 <div id="disposable_container">
24 <label>Non-MD5 Expiration Time(hours): </label>
25 <input id="Expiration_Time">
27 <label>MD5 Filters:</label>
29 <textarea style="width:98%;height:217px" placeholder="Enter MD5 like on 4chanX...
31 /def890/" id="MD5_List_FSE"></textarea>
35 (<HTMLInputElement>document.getElementById("Expiration_Time")).value = "" + (this.setting_items.image_hiding_settings.Expiration_Time / Constants.MILLISECONDS_TO_THE_HOUR);
36 (<HTMLInputElement>document.getElementById("MD5_List_FSE")).value = this.setting_items.image_hiding_settings.MD5_List_FSE;
37 var set_button = document.createElement('INPUT');
38 document.getElementById("disposable_container").appendChild(set_button);
39 set_button.setAttribute('VALUE', "Set Image Settings");
40 set_button.addEventListener("click", (evt) => {
42 this.clearContainer();
43 this.rebuildContainer();
45 set_button.setAttribute('TYPE', 'button');
49 {Text : "View 『Word Replacement』 Settings", ListenerFunc : (a_id) => {
50 this.clearContainer();
52 var disposable_container:any = document.createElement("DIV");
53 disposable_container.setAttribute("ID", "disposable_container");
54 this.contents_div.appendChild(disposable_container);
55 this.filterWindow(disposable_container);
56 this.filterSetTable();
59 {Text : "View 『Danbooru Image Adder』 Settings", ListenerFunc : (a_id) => {
60 this.clearContainer();
62 var disposable_container:Element = document.createElement("DIV");
63 disposable_container.setAttribute("id", "disposable_container");
64 this.contents_div.appendChild(disposable_container);
65 disposable_container.innerHTML = `
66 <table style="text-align:center;margin-left:5px">
69 <label>Very Large: </label>
72 <input id="v_large_DIA" name="preivew-size" style="display:inline" type="radio">
77 <label>Large: </label>
80 <input id="large_DIA" name="preivew-size" style="display:inline" type="radio">
85 <label>Medium: </label>
88 <input id="medium_DIA" name="preivew-size" style="display:inline" type="radio">
93 <label>Very Large: </label>
96 <input id="small_DIA" name="preivew-size" style="display:inline" type="radio">
101 <label>Width: </label>
104 <input id="width_DIA" name="preivew-size" style="width:20%" type="text">
109 <label>Height: </label>
112 <input id="height_DIA" name="preivew-size" style="width:20%" type="text">
119 <label>Quick Reply Min Width: </label>
120 <input id="qr_width_DIA" name="preivew-size" style="width:20%" type="text">
124 <input id="setQRProperties" value="Set Preview Size" type="button">
126 this.setImageAdderFields();
127 this.setImageAdderEventListeners();
130 {Text : "View 『Thread Rebuilder』 Settings", ListenerFunc : (a_id) => {
131 this.clearContainer();
133 var disposable_container = document.createElement("DIV");
134 disposable_container.setAttribute("id", "disposable_container");
135 this.contents_div.appendChild(disposable_container);
136 disposable_container.innerHTML =
138 <label>Use 4chan Archives: </label>
139 <input name="ArchiveSettings" id="OnsiteArchive" type="text">
141 <label>Use Offsite Archives: </label>
142 <input name="ArchiveSettings" id="OffsiteArchive" type="text">
144 <input id="setTime" value="Set Archive" type="button">
148 {Text : "View 『¥ Text』 Settings [Customizable]", ListenerFunc : (a_id) => {
149 this.clearContainer();
151 var disposable_container = document.createElement("DIV");
152 disposable_container.setAttribute("id", "disposable_container");
153 this.contents_div.appendChild(disposable_container);
154 disposable_container.innerHTML =
156 <label>¥Quote Character: </label>
157 <input name="quoteCharacter" id="quoteCharacter" type="text">
159 <label>RGB Hex Color: </label>
160 <input name="HexColorYen" id="hexColorYen" type="text">
161 <input name="HexColorYen" id="SelectColorYen" type="color">
163 <input id="setQuote" value="Set Quote Settings" type="button">
165 document.getElementById("SelectColorYen").addEventListener("input", (evt) => {
166 (<HTMLInputElement>document.getElementById("hexColorYen")).value =
167 ((<HTMLInputElement>document.getElementById("SelectColorYen")).value);
173 {Text : "View 『Kita』 Settings [Customizable]", ListenerFunc : (a_id) => {
174 this.clearContainer();
176 var disposable_container = document.createElement("DIV");
177 disposable_container.setAttribute("id", "disposable_container");
178 this.contents_div.appendChild(disposable_container);
179 disposable_container.innerHTML =
181 <script src="http://jscolor.js"></script>
182 <label>Kita Characters: </label>
183 <input name="selectiveCharacter" id="selectiveCharacters" type="text">
185 <label>RGB Hex Color: </label>
186 <input name="HexColorKita" id="HexColorKita" type="text">
187 <input name="HexColorKita" id="SelectColorKita" type="color">
189 <input id="setCharacter" value="Set Quote Settings" type="button">
191 document.getElementById("SelectColorKita").addEventListener("input", (evt) => {
192 (<HTMLInputElement>document.getElementById("HexColorKita")).value =
193 ((<HTMLInputElement>document.getElementById("SelectColorKita")).value);
197 {Text : "Set 『Visible Password』 : ", ListenerFunc : (input_id) => {
198 var input = document.getElementById(input_id);
199 var is_check:boolean = !(<HTMLInputElement>input).checked;
200 (<HTMLInputElement>document.getElementById(input_id)).checked = is_check;
205 setting_items:any = {};
209 this.retrieveStates();
214 setImageAdderFields(){
215 (<HTMLInputElement>document.getElementById("width_DIA")).value = this.setting_items.image_adder_settings.Width;
216 (<HTMLInputElement>document.getElementById("height_DIA")).value = this.setting_items.image_adder_settings.Height;
217 (<HTMLInputElement>document.getElementById("qr_width_DIA")).value = this.setting_items.image_adder_settings.QR_Width;
219 if ((<HTMLInputElement>document.getElementById("width_DIA")).value == "489") (<HTMLInputElement>document.getElementById("v_large_DIA")).checked = true;
220 else if((<HTMLInputElement>document.getElementById("width_DIA")).value == "400") (<HTMLInputElement>document.getElementById("large_DIA")).checked = true;
221 else if((<HTMLInputElement>document.getElementById("width_DIA")).value == "300") (<HTMLInputElement>document.getElementById("medium_DIA")).checked = true;
222 else if((<HTMLInputElement>document.getElementById("width_DIA")).value == "200") (<HTMLInputElement>document.getElementById("small_DIA")).checked = true;
225 setImageAdderEventListeners():void{
226 (<HTMLInputElement>document.getElementById("v_large_DIA")).addEventListener("click", function(){
227 (<HTMLInputElement>document.getElementById("width_DIA")).value = "489";
228 (<HTMLInputElement>document.getElementById("height_DIA")).value = "489";
231 (<HTMLInputElement>document.getElementById("large_DIA")).addEventListener("click", function(){
232 (<HTMLInputElement>document.getElementById("width_DIA")).value = "400";
233 (<HTMLInputElement>document.getElementById("height_DIA")).value = "400";
236 (<HTMLInputElement>document.getElementById("medium_DIA")).addEventListener("click", function(){
237 (<HTMLInputElement>document.getElementById("width_DIA")).value = "300";
238 (<HTMLInputElement>document.getElementById("height_DIA")).value = "300";
242 (<HTMLInputElement>document.getElementById("small_DIA")).addEventListener("click", function(){
243 (<HTMLInputElement>document.getElementById("width_DIA")).value = "200";
244 (<HTMLInputElement>document.getElementById("height_DIA")).value = "200";
248 (<HTMLInputElement>document.getElementById("setQRProperties")).addEventListener("click", (evt) => {
250 this.clearContainer();
251 this.rebuildContainer();
259 retrieveStates():void{
260 //values used to fill out data fields
261 this.setting_items.image_hiding_settings = {Expiration_Time: localStorage.getItem("Expiration_Time"), MD5_List_FSE: localStorage.getItem("MD5_List_FSE")};
262 this.retrieveWordReplaceStates();
263 this.retrieveImageAdderStates();
264 this.setting_items.thread_rebuild_settings = (localStorage.getItem("tab-settings4") == 'true');
265 this.setting_items.yen_settings = (localStorage.getItem("tab-settings5") == 'true');
266 this.setting_items.kita_settings = (localStorage.getItem("tab-settings6") == 'true');
267 this.setting_items.password_settings=(localStorage.getItem("pw_active"));
270 retrieveWordReplaceStates():void{
271 //acquire text filter representation
272 var storage_index:number = 0;
273 var JSON_storage:any = {};
274 var storage_key:string;
275 var text_filters:any[] = [];
276 while(storage_index < window.localStorage.length) {
278 storage_key = window.localStorage.key(storage_index);
279 JSON_storage[storage_key] = window.localStorage.getItem(storage_key);
281 var filters:string[] = Generics.getJSONPropertiesByKeyName(JSON_storage,"[0-9]+FLT");
283 filters.forEach((filter) => {
284 text_filters.push(TextReplacer.formatFilterSettings(JSON_storage[filter]));
287 var width = localStorage.getItem("width_DIA");
288 var height = localStorage.getItem("height_DIA");
289 var qr_width = localStorage.getItem("qr_width_DIA");
291 this.setting_items.word_replace_settings = {Number_of_filters: localStorage.getItem("filter_quantity"), Text_Filter_List: text_filters};
294 retrieveImageAdderStates():void{
295 this.setting_items.image_adder_settings = {Width: localStorage.getItem("width_DIA"),
296 Height: localStorage.getItem("height_DIA"),
297 QR_Width: localStorage.getItem("qr_width_DIA")};
299 if(this.setting_items.image_adder_settings.Height === null) this.setting_items.image_adder_settings.Height = 400;
300 if(this.setting_items.image_adder_settings.Width === null) this.setting_items.image_adder_settings.Width = 400;
301 if(this.setting_items.image_adder_settings.QR_Width === null) this.setting_items.image_adder_settings.QR_Width = 480;
303 (<HTMLInputElement>document.getElementById("fourchanx-css")).textContent += ".qr-preview { height:" + this.setting_items.image_adder_settings.Height + "px; width: " + this.setting_items.image_adder_settings.Width + "px; left:8%;background-size: cover;}";
304 (<HTMLInputElement>document.getElementById("fourchanx-css")).textContent += "#dump-list { min-height: " + (this.setting_items.image_adder_settings.Width - 20) + "px; width: " + (this.setting_items.image_adder_settings.QR_Width) + "px;}";
309 this.storeImageFilterStates();
310 //Text replace settings
311 this.storeTextFilterStates();
312 //Image Adder settings
313 this.storeImageAdderStates();
314 //Password replace settings
315 this.storePasswordStates()
317 this.retrieveStates();
320 storeImageFilterStates():void{
321 if(document.getElementById("Expiration_Time") !== null){
322 var time:any = document.getElementById("Expiration_Time");
323 var millisecond_time:number = parseInt((<HTMLInputElement>time).value) * Constants.MILLISECONDS_TO_THE_HOUR;
324 if (millisecond_time == 0 || millisecond_time === null || millisecond_time === undefined) millisecond_time = Constants.DEFAULT_HIDE_EXPIRATION_TIME;
325 localStorage.setItem("Expiration_Time", millisecond_time.toString());
326 var md5_filters = (<HTMLInputElement>document.getElementById("MD5_List_FSE")).value;
327 localStorage.setItem("MD5_List_FSE", md5_filters);
328 Generics.alert4ChanX("Image Settings Saved", "success", 3);
333 storeTextFilterStates():void{
334 if(document.getElementById("FilterRow0") !== null){
335 var f_row_moving:any = document.getElementById("FilterRow0");
336 var number_of_filters:number = 0;
337 var number_of_filters_actual:number = 0;
338 while(f_row_moving.nextSibling !== null){
339 if((<HTMLInputElement>document.getElementById("Pattern" + number_of_filters)).value !== "") number_of_filters_actual++;
341 f_row_moving = f_row_moving.nextSibling;
343 window.localStorage.setItem("filter_quantity", number_of_filters_actual.toString());
345 for (var pattern_input:number = 0 ; pattern_input < number_of_filters; pattern_input++){
346 var pattern_to_store:string = (<HTMLInputElement>document.getElementById("Pattern"+pattern_input)).value;
347 var replacement_to_store:string = (<HTMLInputElement>document.getElementById("Replacement"+pattern_input)).value;
348 var setting:string = 'g';
350 if(pattern_to_store === "") {
351 localStorage.removeItem(pattern_input + "FLT");
354 else if(new RegExp("^\/.*\/\\D+$").test(pattern_to_store)){}
355 else if (new RegExp("^\/.*\/$").test(pattern_to_store)){
356 pattern_to_store = pattern_to_store + setting;
358 else if(!new RegExp("^/.*\/\\D$").test(pattern_to_store)){
359 pattern_to_store = "/" + pattern_to_store + "/" + setting;
361 //test for breakages, try to cause error
362 var error_test:any = new RegExp(
363 pattern_to_store.substring(0, pattern_to_store.lastIndexOf("/") + 1),
364 pattern_to_store.substring(pattern_to_store.lastIndexOf("/") + 1)
368 Generics.alert4ChanX("Unrecoverable Regex error on pattern " + pattern_input + " for " + pattern_to_store, "error", undefined);
371 pattern_to_store = encodeURIComponent(pattern_to_store);
372 var save_string:string = (<HTMLInputElement>document.getElementById("Active"+pattern_input)).checked + '=' + pattern_to_store + '=' + replacement_to_store;
373 window.localStorage.setItem(pattern_input + "FLT", save_string);
375 Generics.alert4ChanX("Wordfilters Updated!", "success", 3);
379 storeImageAdderStates():void{
380 var width:string = (<HTMLInputElement>document.getElementById("width_DIA")).value;
381 localStorage.setItem("width_DIA", width);
383 var height:string = (<HTMLInputElement>document.getElementById("height_DIA")).value;
384 localStorage.setItem("height_DIA", height);
386 var qr_width:string = (<HTMLInputElement>document.getElementById("qr_width_DIA")).value;
387 localStorage.setItem("qr_width_DIA", qr_width);
392 storePasswordStates():void{
393 //password view settings
394 if(document.getElementById("check-settings6") !== null)
395 localStorage.setItem("pw_active", `${(<HTMLInputElement>document.getElementById("check-settings6")).checked}`);
398 clearContainer():void{
399 var disposable = document.getElementById("disposable_container");
400 if(disposable !== null) this.contents_div.removeChild(disposable);
401 else this.contents_div.removeChild(this.ul_selection_start);
405 this.contents_div.appendChild(this.ul_selection_start);
409 this.settings_style.innerHTML = `.inputs{
410 background-color:rgb(200,200,200);margin:5px 7px;width:100px;
413 position:fixed;width:100%;height:100%;background-color:rgba(200,200,200,0.3);top:0;left:0; z-index:9
416 font-size:18px;list-style:katakana-iroha outside;padding:2px;color:#2e2345;
419 transform: scale(1.2);
422 border:solid 1px black;position:fixed;background-color:rgb(200,200,200);left:40%;top:20%;margin-bottom:0; z-index:10
425 border:solid 1px black;position:absolute;width:25px;height:25px;background-color:rgba(255,100,90,0.9); right:3px;top:3px; z-index:10
428 font-size: 20px;padding: 12px 0px 9px 22px
434 background-color:white;margin:0 0;padding:5px 25px;
437 this.background_div.setAttribute('class', 'SettingsBackground');
438 this.background_div.setAttribute('id', 'SettingsBackground');
439 this.background_div.setAttribute('style','display:none');
441 this.settings_div.setAttribute('class', 'settingsMain');
442 this.settings_div.setAttribute('id', 'settingsWindow');
443 this.settings_div.setAttribute('style', 'display:none;width:500px');
445 this.close_link.setAttribute('href','javascript:void(0)');
447 this.close_div.setAttribute('class', 'closeIcon');
448 this.close_div.addEventListener('click', evt => this.hideWindow());
450 this.title_para.setAttribute('class', 'titleStyle');
452 this.contents_div.setAttribute('class','contentStyle');
454 this.end_para.setAttribute('class', 'footerStyle');
456 this.generateList(this.contents_div);
459 generateList(head_node:any):void{
460 this.list_items.forEach((list_item, index) => {
461 var li = document.createElement('LI');
462 li.setAttribute('class', 'settingsItem');
463 if(list_item.Text.indexOf('View') > -1){
464 var a:any = document.createElement('A');
465 a.setAttribute('href','javascript:void(0)');
466 a.textContent = list_item.Text;
467 var a_id = 'tab-settings' + index;
468 a.setAttribute('ID', 'tab-settings' + index);
469 var setup_func =(_a_id) => {
470 a.addEventListener('click', (evt) => list_item.ListenerFunc(_a_id));
472 this.ul_selection_start.appendChild(li);
477 var label:any = document.createElement('LABEL');
478 label.textContent = list_item.Text;
479 li.appendChild(label);
481 var input:any = document.createElement('INPUT');
482 var input_id:string = 'check-settings' + index;
483 input.setAttribute('TYPE','checkbox');
484 input.setAttribute('ID', 'check-settings' + index);
485 li.appendChild(input);
486 this.ul_selection_start.appendChild(li);
487 (<HTMLInputElement>input).checked = this.setting_items.password_settings == 'true';
488 var setup_func = (_input_id) => {
489 label.addEventListener('click',(evt) => list_item.ListenerFunc(_input_id));
491 setup_func(input_id);
497 document.body.appendChild(this.settings_style);
498 this.background_div.addEventListener('click', evt => this.hideWindow());
499 document.body.appendChild(this.background_div);
500 this.settings_div.appendChild(this.close_link);
501 this.close_link.appendChild(this.close_div);
502 this.title_para.appendChild(this.title_text);
503 this.settings_div.appendChild(this.title_para);
504 this.settings_div.appendChild(this.contents_div);
505 this.end_para.appendChild(this.end_text);
506 this.settings_div.appendChild(this.end_para);
507 document.body.appendChild(this.settings_div);
509 decideAction(node:any):void{}
511 getSettingsArr():Object{
512 return this.setting_items;
515 displayWindow():void{
516 this.background_div.style.display = 'block';
517 this.settings_div.style.display = 'block';
518 this.rebuildContainer();
522 this.background_div.style.display = 'none';
523 this.settings_div.style.display = 'none';
524 this.clearContainer();
527 filterWindow(disposable_container:any):void{
528 var filter_table:any = document.createElement("table");
529 filter_table.setAttribute("style", "text-align:center;");
530 filter_table.setAttribute("id", "filter_table");
531 disposable_container.appendChild(filter_table);
533 var table_row:any = document.createElement("tr");
534 filter_table.appendChild(table_row);
535 var table_head_active:any = document.createElement("th");
536 var head_text_active:any = document.createTextNode("Active");
537 table_head_active.appendChild(head_text_active);
538 filter_table.appendChild(table_head_active);
539 var table_head_pattern:any = document.createElement("th");
540 var headTextPattern:any = document.createTextNode("Pattern");
541 table_head_pattern.appendChild(headTextPattern);
542 filter_table.appendChild(table_head_pattern);
543 var table_head_replacement:any = document.createElement("th");
544 var head_text_replacement:any = document.createTextNode("Replacement");
545 table_head_replacement.appendChild(head_text_replacement);
546 filter_table.appendChild(table_head_replacement);
548 //Create the pattern table
549 //loop to create rows
550 var number_of_filters:number = parseInt(this.setting_items.word_replace_settings.number_of_filters);
551 if (number_of_filters === 0 || isNaN(number_of_filters)) number_of_filters = 6;
552 for (var i = 0; i < number_of_filters ; i++){
553 var table_row_contents:any = document.createElement("tr");
554 table_row_contents.setAttribute("id", "FilterRow" + i);
556 var table_data_active:any = document.createElement("td");
557 var table_checkbox_active:any = document.createElement("input");
558 table_checkbox_active.setAttribute("type", "checkbox");
559 table_checkbox_active.setAttribute("id", "Active" + i);
560 table_data_active.appendChild(table_checkbox_active);
561 table_row_contents.appendChild(table_data_active);
563 var table_data_pattern:any = document.createElement("td");
564 var table_input_pattern:any = document.createElement("input");
565 table_input_pattern.setAttribute("class", "inputs");
566 table_input_pattern.setAttribute("id", "Pattern" + i);
567 table_data_pattern.appendChild(table_input_pattern);
568 table_row_contents.appendChild(table_data_pattern);
570 var table_data_replacement:any = document.createElement("td");
571 var table_input_replacement:any = document.createElement("input");
572 table_input_replacement.setAttribute("class", "inputs");
573 table_input_replacement.setAttribute("id", "Replacement" + i);
574 table_data_replacement.appendChild(table_input_replacement);
575 table_row_contents.appendChild(table_data_replacement);
577 filter_table.appendChild(table_row_contents);
580 var table_last_contents:any = document.createElement("tr");
582 var table_add_collumn:any = document.createElement("td");
583 var table_add_row_button:any = document.createElement("input");
584 var table_subtract_row_button:any = document.createElement("input");
585 table_subtract_row_button.setAttribute("type", "button");
586 table_subtract_row_button.setAttribute("value", "-");
587 table_subtract_row_button.setAttribute("style", "padding: 7px 0; margin:5px 0;");
588 table_add_collumn.appendChild(table_subtract_row_button);
589 table_subtract_row_button.addEventListener("click", (evt) => this.filterRemoveRow());
590 table_add_row_button.setAttribute("type", "button");
591 table_add_row_button.setAttribute("value", "+");
592 table_add_row_button.setAttribute("style", "padding: 7px 0; margin:5px 0;");
593 table_add_collumn.appendChild(table_add_row_button);
594 table_add_row_button.addEventListener("click", (evt) => this.filterAddRow());
596 table_last_contents.appendChild(table_add_collumn);
598 var table_set_collumn:any = document.createElement("td");
599 var table_confirm_button:any = document.createElement("input");
600 table_confirm_button.setAttribute("type", "button");
601 table_confirm_button.setAttribute("id", "table_confirm_button");
602 table_confirm_button.setAttribute("value", "Set Replacements");
603 table_confirm_button.setAttribute("style", "padding: 7px 0; margin:5px 0;");
606 table_confirm_button.addEventListener("click", (evt) => {
608 this.clearContainer();
609 this.rebuildContainer();
612 table_set_collumn.appendChild(table_confirm_button);
613 table_last_contents.appendChild(table_set_collumn);
615 var table_close_collumn:any = document.createElement("td");
616 var table_close_button:any = document.createElement("input");
617 table_close_button.setAttribute("type", "button");
618 table_close_button.setAttribute("value", "Close Without Saving");
619 table_close_button.setAttribute("style", "padding: 7px 0; margin:5px 0;");
620 table_close_button.addEventListener("click", (evt) => {
621 this.clearContainer();
622 this.rebuildContainer();
624 table_close_collumn.appendChild(table_close_button);
625 table_last_contents.appendChild(table_close_collumn);
627 filter_table.appendChild(table_last_contents);
631 var number_of_filters:number = parseInt(this.setting_items.word_replace_settings.number_of_filters);
633 var filter_table:any = document.getElementById("filter_table");
634 filter_table.deleteRow(number_of_filters + 1);
637 var table_row_contents:any = document.createElement("tr");
638 table_row_contents.setAttribute("id", "FilterRow" + (number_of_filters - 1));
640 var table_data_active:any = document.createElement("td");
641 var table_checkbox_active:any = document.createElement("input");
642 table_checkbox_active.setAttribute("type", "checkbox");
643 table_checkbox_active.setAttribute("id", "Active" + (number_of_filters - 1));
644 table_data_active.appendChild(table_checkbox_active);
645 table_row_contents.appendChild(table_data_active);
647 var table_data_pattern:any = document.createElement("td");
648 var table_input_pattern:any = document.createElement("input");
649 table_input_pattern.setAttribute("class", "inputs");
650 table_input_pattern.setAttribute("id", "Pattern" + (number_of_filters - 1));
651 table_data_pattern.appendChild(table_input_pattern);
652 table_row_contents.appendChild(table_data_pattern);
654 var table_data_replacement:any = document.createElement("td");
655 var table_input_replacement:any = document.createElement("input");
656 table_input_replacement.setAttribute("class", "inputs");
657 table_input_replacement.setAttribute("id", "Replacement" + (number_of_filters - 1));
658 table_data_replacement.appendChild(table_input_replacement);
659 table_row_contents.appendChild(table_data_replacement);
661 filter_table.appendChild(table_row_contents);
663 var table_last_contents:any = document.createElement("tr");
665 var table_add_collumn:any = document.createElement("td");
666 var table_add_row_button:any = document.createElement("input");
667 var table_subtract_row_button:any = document.createElement("input");
668 table_subtract_row_button.setAttribute("type", "button");
669 table_subtract_row_button.setAttribute("value", "-");
670 table_subtract_row_button.setAttribute("style", "padding: 7px 0; margin:5px 0;");
671 table_add_collumn.appendChild(table_subtract_row_button);
672 table_subtract_row_button.addEventListener("click", (evt) => this.filterRemoveRow());
673 table_add_row_button.setAttribute("type", "button");
674 table_add_row_button.setAttribute("value", "+");
675 table_add_row_button.setAttribute("style", "padding: 7px 0; margin:5px 0;");
676 table_add_collumn.appendChild(table_add_row_button);
677 table_add_row_button.addEventListener("click", (evt) => this.filterAddRow());
679 table_last_contents.appendChild(table_add_collumn);
681 var table_set_collumn:any = document.createElement("td");
682 var table_confirm_button:any = document.createElement("input");
683 table_confirm_button.setAttribute("type", "button");
684 table_confirm_button.setAttribute("id", "table_confirm_button");
685 table_confirm_button.setAttribute("value", "Set Replacements");
686 table_confirm_button.setAttribute("style", "padding: 7px 0; margin:5px 0;");
688 table_confirm_button.addEventListener("click", (evt) => {
690 this.clearContainer();
691 this.rebuildContainer();
694 table_set_collumn.appendChild(table_confirm_button);
695 table_last_contents.appendChild(table_set_collumn);
697 var table_close_collumn:any = document.createElement("td");
698 var table_close_button:any = document.createElement("input");
699 table_close_button.setAttribute("type", "button");
700 table_close_button.setAttribute("value", "Close Menu");
701 table_close_button.setAttribute("style", "padding: 7px 0; margin:5px 0;");
702 table_close_button.addEventListener("click", (evt) => {
703 this.clearContainer();
704 this.rebuildContainer();
706 table_close_collumn.appendChild(table_close_button);
707 table_last_contents.appendChild(table_close_collumn);
709 filter_table.appendChild(table_last_contents);
712 filterRemoveRow():void{
713 var number_of_filters:number = parseInt(this.setting_items.word_replace_settings.number_of_filters);
715 var filter_table:any = document.getElementById("filter_table");
716 if(number_of_filters != 0){
717 filter_table.deleteRow(number_of_filters);
722 filterSetTable():void{
723 var filter_length = this.setting_items.word_replace_settings.Text_Filter_List.length;
724 for (var filter_count:number = 0 ; filter_count < filter_length ; filter_count++){
726 this.setting_items.word_replace_settings.Text_Filter_List[filter_count].Active === null ||
727 this.setting_items.word_replace_settings.Text_Filter_List[filter_count].Regex === null ||
728 this.setting_items.word_replace_settings.Text_Filter_List[filter_count].Replacement === null) return;
730 if(this.setting_items.word_replace_settings.Text_Filter_List[filter_count].Active === "true"){
731 (<HTMLInputElement>document.getElementById("Active"+filter_count)).checked = true;
734 (<HTMLInputElement>document.getElementById("Active"+filter_count)).checked = false;
736 (<HTMLInputElement>document.getElementById("Pattern"+filter_count)).value =
737 this.setting_items.word_replace_settings.Text_Filter_List[filter_count].Regex;
738 (<HTMLInputElement>document.getElementById("Replacement"+filter_count)).value =
739 this.setting_items.word_replace_settings.Text_Filter_List[filter_count].Replacement;