微件:External demands:修订间差异

来自Hyacinth
跳转到导航 跳转到搜索
删除的内容 添加的内容
草awa留言 | 贡献
无编辑摘要
草awa留言 | 贡献
无编辑摘要
第29行: 第29行:
appendTo.appendChild(p);
appendTo.appendChild(p);
const duplicates = new Map();
const duplicates = new Map();
const liShell = new Map();
const ul = document.createElement('ul');
const ul = document.createElement('ul');
value.forEach((s) => {
value.forEach((s) => {
第38行: 第39行:
const duplicateLi = document.createElement('li');
const duplicateLi = document.createElement('li');
duplicateLi.appendChild(duplicatedAlias);
duplicateLi.appendChild(duplicatedAlias);
duplicates.get(externalTarget).appendChild(ul);
liShell.get(externalTarget).appendChild(ul);
}
}
} else {
} else {
const li = document.createElement('li');
const li = document.createElement('li');
duplicates.set(externalTarget, li);
duplicates.set(externalTarget, s);
liShell.set(externalTarget, li);
li.appendChild(s);
li.appendChild(s);
ul.appendChild(li);
ul.appendChild(li);

2024年4月11日 (四) 09:34的版本

<script>
const elements = document.getElementsByClassName('external_demand_span');

if (elements.length == 0) {
    const externalDemandShell = document.getElementById('external_demand_shell');
    externalDemandShell.style.display = 'none';
} else {
	const appendTo = document.getElementById('external_demand');

	const cats = new Map();

	for (let i = 0; i < elements.length; i++) {
	    const element = elements[i];
	    const clone = element.cloneNode(true);
	    console.log(clone.title);
	    if (!cats.has(clone.title)) {
	    	cats.set(clone.title,new Array());
    	}
    	cats.get(clone.title).push(clone);
    	clone.style.display = 'inline';
	    clone.classList.remove('external_demand_span')
	}

	function handler(value, key, map) {
    	console.log(key);
    	console.log(value);
    	const p = document.createElement('p');
    	p.innerText = '来自' + key + '的条目:';
    	appendTo.appendChild(p);
    	const duplicates = new Map();
    	const liShell = new Map();
    	const ul = document.createElement('ul');
    	value.forEach((s) => {
        	const externalTarget = s.lastChild.title;
        	if (duplicates.has(externalTarget)) {
        	    const duplicatedAlias = duplicates.get(externalTarget).lastChild.cloneNode(true);
        	    if (!duplicates.get(externalTarget).lastChild.className == 'external_demand_duplicate') {
        	        const duplicatedUl = document.createElement('ul');
        	        const duplicateLi = document.createElement('li');
        	        duplicateLi.appendChild(duplicatedAlias);
        	        liShell.get(externalTarget).appendChild(ul);
        	    }
        	} else {
        	    const li = document.createElement('li');
        		duplicates.set(externalTarget, s);
        		liShell.set(externalTarget, li);
        		li.appendChild(s);
        		ul.appendChild(li);
        	}
    	})
	    appendTo.appendChild(ul);
	}

	cats.forEach(handler);
}
</script>