<commit_before><!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<meta name="description" content="application/xhtml+xml"/>
<title> KS-Color Picker </title>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="http://bhwarren.github.io/ks-clock-face/color-dict.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/ac-colors@1/dist/ac-colors.min.js"></script>


<script>

let colorPickerColors = color_picker_colors;
let hexColors = Object.keys(colorPickerColors);
hexColors.forEach(color => colorPickerColors[color].hsl = getHSL(color))
hexColors.sort(colorSort).sort(colorSort).sort(colorSort)

function getDiff(hsl1, hsl2, index){
	let granularity = 8
	let divisor = index == 0 ? 360 : 100
	if(hsl1[0] == 0 && hsl1[1] == 0)
		hsl1[0] = -1
	if(hsl2[0] == 0 && hsl2[1] == 0)
		hsl2[0] = -1
	return Math.ceil(hsl1[index]/divisor*granularity) - Math.ceil(hsl2[index]/divisor*granularity)
}

// sort colors using hsl values
function colorSort(color1, color2) {
	let hsl1 = colorPickerColors[color1].hsl
	let hsl2 = colorPickerColors[color2].hsl
	
	let hueDiff = getDiff(hsl1, hsl2, 0) 
	let saturationDiff = getDiff(hsl1, hsl2, 1) 
	let lightnessDiff = getDiff(hsl1, hsl2, 2) 

	if(hueDiff != 0){
		// if the hues are different, sort by that first
		return hueDiff 
	}
	else if(saturationDiff != 0){
		// if the saturation is different, then use that
		return saturationDiff 
	}
	else{ 
		// finally, if the hue and saturation are the same, order by lightness
		return lightnessDiff 
	}
}

//given a pebble color name, return an html color for the preview background 
function getHTMLColor(name){
	//color_picker_colors defined in color-dict.js
	for (var key in color_picker_colors){
		if(color_picker_colors[key]["identifier"] == name){
			return key;
		}
	}
}

// gets the number used by pebble to represent the color
function getColorID(name){
	let nameToNumberMap = {'Black': 1,
		'OxfordBlue': 1, 'DukeBlue': 2, 'Blue': 3, 'DarkGreen': 4,
		'MidnightGreen': 5, 'CobaltBlue': 6, 'BlueMoon': 7, 'IslamicGreen': 8,
		'JaegerGreen': 9, 'TiffanyBlue': 10, 'VividCerulean': 11, 'Green': 12,
		'Malachite': 13, 'MediumSpringGreen': 14, 'Cyan': 15, 'BulgarianRose': 16,
		'ImperialPurple': 17, 'Indigo': 18, 'ElectricUltramarine': 19, 'ArmyGreen': 20,
		'DarkGray': 21, 'Liberty': 22, 'VeryLightBlue': 23, 'KellyGreen': 24,
		'MayGreen': 25, 'CadetBlue': 26, 'PictonBlue': 27, 'BrightGreen': 28,
		'ScreaminGreen': 29, 'MediumAquamarine': 30, 'ElectricBlue': 31, 'DarkCandyAppleRed': 32, 
		'JazzberryJam': 33, 'Purple': 34, 'VividViolet': 35, 'WindsorTan': 36,
		'RoseVale': 37, 'Purpureus': 38, 'LavenderIndigo': 39, 'Limerick': 40,
		'Brass': 41, 'LightGray': 42, 'BabyBlueEyes': 43, 'SpringBud': 44,
		'Inchworm': 45, 'MintGreen': 46, 'Celeste': 47, 'Red': 48,
		'Folly': 49, 'FashionMagenta': 50, 'Magenta': 51, 'Orange': 52,
		'SunsetOrange': 53, 'BrilliantRose': 54, 'ShockingPink': 55, 'ChromeYellow': 56,
		'Rajah': 57, 'Melon': 58, 'RichBrilliantLavender': 59, 'Yellow': 60,
		'Icterine': 61, 'PastelYellow': 62, 'White': 63
	}
	return nameToNumberMap[name.replace(/\s+/, '')]
}

// converts hex string to hsl, useful for sorting
function getHSL(hexString){
	let hslValue = (new Color({"color":hexString, "type":"hex"})).hsl
	return hslValue
}

//when a preview is clicked, make selection show up on pebble
function changeColor(hexColor) {
	let colorID = getColorID(colorPickerColors[hexColor].name) 
	let colorUsages = JSON.parse(getCookie("colorUsages") || "{}")

	colorUsages[hexColor] = (colorUsages[hexColor] || 0) + 1

	let expires = new Date();
  	expires.setTime(expires.getTime() + (100*24*60*60*1000)); // 100 years from now<commit_msg>fixed not all colors matching<commit_after><!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<meta name="description" content="application/xhtml+xml"/>
<title> KS-Color Picker </title>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="http://bhwarren.github.io/ks-clock-face/color-dict.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/ac-colors@1/dist/ac-colors.min.js"></script>


<script>

let colorPickerColors = color_picker_colors;
let hexColors = Object.keys(colorPickerColors);
hexColors.forEach(color => colorPickerColors[color].hsl = getHSL(color))
hexColors.sort(colorSort).sort(colorSort).sort(colorSort)

function getDiff(hsl1, hsl2, index){
	let granularity = 8
	let divisor = index == 0 ? 360 : 100
	if(hsl1[0] == 0 && hsl1[1] == 0)
		hsl1[0] = -1
	if(hsl2[0] == 0 && hsl2[1] == 0)
		hsl2[0] = -1
	return Math.ceil(hsl1[index]/divisor*granularity) - Math.ceil(hsl2[index]/divisor*granularity)
}

// sort colors using hsl values
function colorSort(color1, color2) {
	let hsl1 = colorPickerColors[color1].hsl
	let hsl2 = colorPickerColors[color2].hsl
	
	let hueDiff = getDiff(hsl1, hsl2, 0) 
	let saturationDiff = getDiff(hsl1, hsl2, 1) 
	let lightnessDiff = getDiff(hsl1, hsl2, 2) 

	if(hueDiff != 0){
		// if the hues are different, sort by that first
		return hueDiff 
	}
	else if(saturationDiff != 0){
		// if the saturation is different, then use that
		return saturationDiff 
	}
	else{ 
		// finally, if the hue and saturation are the same, order by lightness
		return lightnessDiff 
	}
}

//given a pebble color name, return an html color for the preview background 
function getHTMLColor(name){
	//color_picker_colors defined in color-dict.js
	for (var key in color_picker_colors){
		if(color_picker_colors[key].name == name){
			return key;
		}
	}
}

// gets the number used by pebble to represent the color
function getColorID(name){
	let nameToNumberMap = {'Black': 1,
		'OxfordBlue': 1, 'DukeBlue': 2, 'Blue': 3, 'DarkGreen': 4,
		'MidnightGreen': 5, 'CobaltBlue': 6, 'BlueMoon': 7, 'IslamicGreen': 8,
		'JaegerGreen': 9, 'TiffanyBlue': 10, 'VividCerulean': 11, 'Green': 12,
		'Malachite': 13, 'MediumSpringGreen': 14, 'Cyan': 15, 'BulgarianRose': 16,
		'ImperialPurple': 17, 'Indigo': 18, 'ElectricUltramarine': 19, 'ArmyGreen': 20,
		'DarkGray': 21, 'Liberty': 22, 'VeryLightBlue': 23, 'KellyGreen': 24,
		'MayGreen': 25, 'CadetBlue': 26, 'PictonBlue': 27, 'BrightGreen': 28,
		'ScreaminGreen': 29, 'MediumAquamarine': 30, 'ElectricBlue': 31, 'DarkCandyAppleRed': 32, 
		'JazzberryJam': 33, 'Purple': 34, 'VividViolet': 35, 'WindsorTan': 36,
		'RoseVale': 37, 'Purpureus': 38, 'LavenderIndigo': 39, 'Limerick': 40,
		'Brass': 41, 'LightGray': 42, 'BabyBlueEyes': 43, 'SpringBud': 44,
		'Inchworm': 45, 'MintGreen': 46, 'Celeste': 47, 'Red': 48,
		'Folly': 49, 'FashionMagenta': 50, 'Magenta': 51, 'Orange': 52,
		'SunsetOrange': 53, 'BrilliantRose': 54, 'ShockingPink': 55, 'ChromeYellow': 56,
		'Rajah': 57, 'Melon': 58, 'RichBrilliantLavender': 59, 'Yellow': 60,
		'Icterine': 61, 'PastelYellow': 62, 'White': 63
	}
	nameToNumberMap = JSON.parse(JSON.stringify(nameToNumberMap).toLowerCase())
	name = name.replace(/\s+/g, '').replace(/\(.*\)/g, '').toLowerCase()
	return nameToNumberMap[name]
}

// converts hex string to hsl, useful for sorting
function getHSL(hexString){
	let hslValue = (new Color({"color":hexString, "type":"hex"})).hsl
	return hslValue
}

//when a preview is clicked, make selection show up on pebble
function changeColor(hexColor) {
	let colorID = getColorID(colorPickerColors[hexColor].name) 
	let colorUsages = JSON.parse(getCookie("colorUsages") || "{}")

	colorUsages[hexColor] = (colorUsages[hexColor] || 0) + 1

	let expires = new Date();
  	expires.setTime(expires.getTime() + (100*24*60*60*1000)); // 100 years from now
{'fraction_non_alphanumeric': 0.1682157350438539, 'fraction_numerical': 0.04922110223851289, 'mean_word_length': 5.116893514811849, 'pattern_counts': {'":': 4, '<': 31, '<?xml version=': 0, '>': 33, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2714578', 'n_tokens_mistral': 3350, 'n_tokens_neox': 2870, 'n_words': 713}