INNER CODE UNIT · JavaScript

createPalette

Booodaness/Scientific-Notes · Booodaness/_Assets/Presentations/phase-space-analysis-harmonic-oscillators.md/plugin/chalkboard/plugin (copy).js:240

	function createPalette( colors, length ) {
		if ( length === true || length > colors.length ) {
			length = colors.length;
		}
		var palette = document.createElement( 'div' );
		palette.classList.add('palette');
		var list = document.createElement( 'ul' );
		// color pickers
		for (var i = 0; i < length; i++ ) {
			var colorButton = document.createElement( 'li' );
			colorButton.setAttribute("data-color",i);
			colorButton.innerHTML = '<i class="fa fa-square"></i>';
			colorButton.style.color = colors[i].color;
			colorButton.addEventListener("click", function(e) {
				colorIndex(e.target.parentElement.getAttribute("data-color"));
			});
			list.appendChild( colorButton );
		}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…