Download code/validation/JavaScript/0046712_0x444.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 2.5 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/code/validation/JavaScript/0046712_0x444.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/code/validation/JavaScript/0046712_0x444.js
-
curl -L -o 0046712_0x444.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/code/validation/JavaScript/0046712_0x444.js
2.5 kB
| function getParameterByName(name, url) { | |
| if (!url) { | |
| url = window.location.href; | |
| } | |
| name = name.replace(/[\[\]]/g, "\\$&"); | |
| var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), | |
| results = regex.exec(url); | |
| if (!results) return null; | |
| if (!results[2]) return ''; | |
| return decodeURIComponent(results[2].replace(/\+/g, " ")); | |
| } | |
| /*! | |
| * Dynamically changing favicons with JavaScript | |
| * Works in all A-grade browsers except Safari and Internet Explorer | |
| * Demo: http://mathiasbynens.be/demo/dynamic-favicons | |
| */ | |
| // HTML5™, baby! http://mathiasbynens.be/notes/document-head | |
| document.head || (document.head = document.getElementsByTagName('head')[0]); | |
| function changeFavicon(src) { | |
| var link = document.createElement('link'), | |
| oldLink = document.getElementById('dynamic-favicon'); | |
| link.id = 'dynamic-favicon'; | |
| link.rel = 'shortcut icon'; | |
| link.href = src; | |
| if (oldLink) { | |
| document.head.removeChild(oldLink); | |
| } | |
| document.head.appendChild(link); | |
| } | |
| // Return base64 image dataURL | |
| function createFavIcon(color) { | |
| // Create a canvas element | |
| var canvas = document.createElement('canvas'); | |
| canvas.width = 133; | |
| canvas.height = 133; | |
| // Get the drawing context | |
| var ctx = canvas.getContext('2d'); | |
| // Then you can do stuff, e.g.: | |
| ctx.fillStyle = color; | |
| ctx.fillRect(0,0,133,133); | |
| return canvas.toDataURL() | |
| } | |
| // Comapre HEX Colors | |
| function hexColorDelta(hex1, hex2) { | |
| // get red/green/blue int values of hex1 | |
| var r1 = parseInt(hex1.substring(0, 2), 16); | |
| var g1 = parseInt(hex1.substring(2, 4), 16); | |
| var b1 = parseInt(hex1.substring(4, 6), 16); | |
| // get red/green/blue int values of hex2 | |
| var r2 = parseInt(hex2.substring(0, 2), 16); | |
| var g2 = parseInt(hex2.substring(2, 4), 16); | |
| var b2 = parseInt(hex2.substring(4, 6), 16); | |
| // calculate differences between reds, greens and blues | |
| var r = 255 - Math.abs(r1 - r2); | |
| var g = 255 - Math.abs(g1 - g2); | |
| var b = 255 - Math.abs(b1 - b2); | |
| // limit differences between 0 and 1 | |
| r /= 255; | |
| g /= 255; | |
| b /= 255; | |
| // 0 means opposit colors, 1 means same colors | |
| return (r + g + b) / 3; | |
| } | |
| // Get similar name color | |
| function getSimilarColorName(color) { | |
| var difference = 0; | |
| var finalColor | |
| for (i in Object.keys(tinycolor.hexNames)) { | |
| var currentDiff = hexColorDelta(color, Object.keys(tinycolor.hexNames)[i]); | |
| if (currentDiff > difference) { | |
| difference = currentDiff; | |
| finalColor = Object.keys(tinycolor.hexNames)[i] | |
| } | |
| } | |
| return tinycolor.hexNames[finalColor]; | |
| } | |