From 0f68a47403884f575a1112ca0c790f37bfc0fc18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 24 Apr 2022 01:14:01 +0200 Subject: Dead code removal. --- static/input_list.js | 110 --------------------------------------------------- static/script.ts | 37 ----------------- 2 files changed, 147 deletions(-) delete mode 100644 static/input_list.js (limited to 'static') diff --git a/static/input_list.js b/static/input_list.js deleted file mode 100644 index a7a446f3..00000000 --- a/static/input_list.js +++ /dev/null @@ -1,110 +0,0 @@ -/* - ∀ children('.input-list') => 'unit' ∈ classList(child) - -
-
-
-
- -*/ - - -/* private */ -function transferListeners(old_unit, new_unit) { - for (let [o, n] of zip([old_unit, ...old_unit.querySelectorAll("*")], - [new_unit, ...new_unit.querySelectorAll("*")])) { - for (const key in o.listeners) { - if (! o.listeners.hasOwnProperty(key)) continue; - for (let proc of o.listeners[key]) { - n.addEventListener(key, proc); - } - } - } -} - - -/* private */ -function advance_final(input_list) { - let old_unit = input_list.unit; - let new_unit = old_unit.cloneNode(true); - new_unit.classList.add('final'); - transferListeners(old_unit, new_unit); - input_list.appendChild(new_unit); -} - - -/* private */ -function update_inline_list () { - - /* can target self */ - let unit = this.closest('.unit'); - - let lst = this.closest('.input-list'); - - if (unit.classList.contains("final")) { - if (this.value !== '') { - unit.classList.remove('final'); - advance_final(lst); - } - } else { - /* TODO all significant fields empty, instead of just current */ - if (this.value === '') { - let sibling = unit.previousElementSibling || unit.nextElementSibling; - unit.remove(); - if (sibling.tagName !== 'input') - sibling = sibling.querySelector('input'); - sibling.focus(); - } - } -} - -/* run this from window.onload (or similar) */ -function init_input_list() { - - for (let lst of document.getElementsByClassName('input-list')) { - - for (let el of lst.getElementsByTagName('input')) { - el.addEventListener('input', update_inline_list); - } - - let oldUnit = lst.querySelector('.final.unit') - let unit = oldUnit.cloneNode(true); - - transferListeners(oldUnit, unit); - - lst.unit = unit; - - if (lst.dataset.bindby) { - lst.get_value = lst.dataset.bindby; - } else if (lst.dataset.joinby) { - lst.get_value = get_get_value(lst.dataset.joinby); - } else { - lst.get_value = get_get_value(); - } - - /* Propagate add event listener downwards */ - lst._addEventListener = lst.addEventListener; - lst.addEventListener = function(type, proc) { - switch (type) { - case 'input': - for (let el of lst.getElementsByTagName('input')) { - el.addEventListener('input', proc); - } - default: - lst._addEventListener(type, proc); - } - }; - } -} - -/* -------------------------------------------------- */ - -/* different function forms since we want to capture one self */ -const get_get_value = (join=',') => function () { - return [...this.querySelectorAll('input')] - .map(x => x.value) - .filter(x => x != ''); - // .join(join); -} - -/* -------------------------------------------------- */ diff --git a/static/script.ts b/static/script.ts index 865c005e..650a5aa0 100644 --- a/static/script.ts +++ b/static/script.ts @@ -1,6 +1,5 @@ import { VEvent, xml_to_vcal } from './vevent' import { SmallcalCellHighlight, Timebar } from './clock' -import { makeElement } from './lib' import { vcal_objects, event_calendar_mapping } from './globals' import { EventCreator } from './event-creator' import { PopupElement, setup_popup_element } from './components/popup-element' @@ -111,20 +110,6 @@ window.addEventListener('load', function() { the whole page scroll there. */ el.parentElement!.removeAttribute("href"); - - let popup = document.getElementById("popup" + el.id); - // popup.getElementsByClassName("edit-form")[0].onsubmit = function () { - // create_event(el); - // return false; /* stop default */ - // } - - /* Bind all vcomponent properties into javascript. */ - // if (el.closest(".longevents")) { - // new VComponent(el, true); - // } else { - // new VComponent(el, false); - // } - } document.onkeydown = function(evt) { @@ -139,28 +124,6 @@ window.addEventListener('load', function() { /* ---------------------------------------- */ - /* needs to be called AFTER bind_properties, but BEFORE init_input_list - After bind_properties since that initializes categories to a possible field - Before init_input_list since we need this listener to be propagated to clones. - [CATEGORIES_BIND] - */ - // TODO fix this - // for (let lst of document.querySelectorAll(".input-list[data-property='categories']")) { - // let f = function() { - // console.log(lst, lst.closest('.popup-container')); - // let event = event_from_popup(lst.closest('.popup-container')) - // event.properties.categories = lst.get_value(); - // }; - - // for (let inp of lst.querySelectorAll('input')) { - // inp.addEventListener('input', f); - // } - // } - - // init_arbitary_kv(); - - // init_input_list(); - document.addEventListener('keydown', function(event) { /* Physical key position, names are what that key would be in QWERTY */ -- cgit v1.2.3