forked from cory/tildefriends
		
	Slight emoji picker improvements, and fix a problem with showing doubled votes. Though this revealed that loading needs serious work.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3967 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
		| @@ -28,34 +28,59 @@ export function picker(callback, anchor) { | ||||
| 		div.style.maxHeight = '16em'; | ||||
| 		div.style.overflow = 'scroll'; | ||||
| 		div.style.fontWeight = 'bold'; | ||||
| 		div.style.cursor = 'pointer'; | ||||
| 		Object.entries(json).forEach(function(row) { | ||||
| 			let header = document.createElement('div'); | ||||
| 			header.appendChild(document.createTextNode(row[0])); | ||||
| 			div.appendChild(header); | ||||
| 			for (let entry of row[1]) { | ||||
| 				let emoji = document.createElement('span'); | ||||
| 				const k_size = '1.25em'; | ||||
| 				emoji.style.width = k_size; | ||||
| 				emoji.style.maxWidth = k_size; | ||||
| 				emoji.style.minWidth = k_size; | ||||
| 				emoji.style.height = k_size; | ||||
| 				emoji.style.maxHeight = k_size; | ||||
| 				emoji.style.minHeight = k_size; | ||||
| 				emoji.style.display = 'inline-block'; | ||||
| 				emoji.style.overflow = 'hidden'; | ||||
| 				emoji.onclick = function() { | ||||
| 					callback(entry); | ||||
| 					div.parentElement.removeChild(div); | ||||
| 				} | ||||
| 				emoji.appendChild(document.createTextNode(entry.emoji)); | ||||
| 				div.appendChild(emoji); | ||||
| 		let input = document.createElement('input'); | ||||
| 		input.type = 'text'; | ||||
| 		div.appendChild(input); | ||||
| 		let list = document.createElement('div'); | ||||
| 		div.appendChild(list); | ||||
| 		function refresh() { | ||||
| 			while (list.firstChild) { | ||||
| 				list.removeChild(list.firstChild); | ||||
| 			} | ||||
| 		}); | ||||
| 			let search = input.value; | ||||
| 			console.log('refrsh', search); | ||||
| 			Object.entries(json).forEach(function(row) { | ||||
| 				let header = document.createElement('div'); | ||||
| 				header.appendChild(document.createTextNode(row[0])); | ||||
| 				list.appendChild(header); | ||||
| 				let any = false; | ||||
| 				for (let entry of row[1]) { | ||||
| 					if (search && | ||||
| 						search.length && | ||||
| 						entry.name.indexOf(search) == -1) { | ||||
| 						continue; | ||||
| 					} | ||||
| 					let emoji = document.createElement('span'); | ||||
| 					const k_size = '1.25em'; | ||||
| 					emoji.style.width = k_size; | ||||
| 					emoji.style.maxWidth = k_size; | ||||
| 					emoji.style.minWidth = k_size; | ||||
| 					emoji.style.height = k_size; | ||||
| 					emoji.style.maxHeight = k_size; | ||||
| 					emoji.style.minHeight = k_size; | ||||
| 					emoji.style.display = 'inline-block'; | ||||
| 					emoji.style.overflow = 'hidden'; | ||||
| 					emoji.style.cursor = 'pointer'; | ||||
| 					emoji.onclick = function() { | ||||
| 						callback(entry); | ||||
| 						div.parentElement.removeChild(div); | ||||
| 					} | ||||
| 					emoji.title = entry.name; | ||||
| 					emoji.appendChild(document.createTextNode(entry.emoji)); | ||||
| 					list.appendChild(emoji); | ||||
| 					any = true; | ||||
| 				} | ||||
| 				if (!any) { | ||||
| 					list.removeChild(header); | ||||
| 				} | ||||
| 			}); | ||||
| 		} | ||||
| 		refresh(); | ||||
| 		input.oninput = refresh; | ||||
| 		document.body.appendChild(div); | ||||
| 		if (anchor) { | ||||
| 			let rect = anchor.getBoundingClientRect(); | ||||
| 			if (rect.top < window.clientHeight / 2) { | ||||
| 			if (rect.top < window.innerHeight / 2) { | ||||
| 				div.style.top = rect.bottom + 'px'; | ||||
| 			} else { | ||||
| 				div.style.top = (rect.top - div.clientHeight) + 'px'; | ||||
|   | ||||
| @@ -117,6 +117,7 @@ tfrpc.register(function push_posts(posts) { | ||||
| }); | ||||
|  | ||||
| tfrpc.register(function push_votes(votes) { | ||||
| 	Vue.set(g_data, 'votes', {}); | ||||
| 	votes.forEach(function(vote) { | ||||
| 		var content = JSON.parse(vote.content); | ||||
| 		var link = content.vote.link; | ||||
| @@ -179,7 +180,7 @@ window.addEventListener('load', function() { | ||||
| 		data: g_data, | ||||
| 		watch: { | ||||
| 			whoami: function(newValue, oldValue) { | ||||
| 				tfrpc.rpc.refresh(newValue, this.selected, true); | ||||
| 				tfrpc.rpc.refresh(newValue, this.selected, oldValue !== undefined); | ||||
| 			}, | ||||
| 			selected: function(newValue, oldValue) { | ||||
| 				let self = this; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user