hta_apps/rgbToHex.hta
2023-06-03 23:26:52 +03:00

83 lines
2.1 KiB
HTML
Executable File

<!--
-- rgbToHex
-- Author: Alexander Popov
-- License: Public Domain
-- Version: 1.0
-- History: see EOF.
-->
<html>
<head>
<HTA:APPLICATION
applicationName="rgbToHex"
version="1.0"
maximizeButton="no"
border="dialog"
innerBorder="no"
scroll="no"
singleInstance="yes"
contextMenu="no"
/>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta charset="utf-8">
<title>rgbToHex</title>
<script type="text/javascript">
window.onload = function() {
var w = 340; // Ширина окна
var h = 310; // Высота окна
// Изменение размера окна и размещение по центру
window.resizeTo(w, h);
window.moveTo((window.screen.width - w) / 2, (window.screen.height - h) / 2);
}
/**
* Функция для перевода rbg цвета в hex
*/
function rgbToHex(r, g, b) {
return '#' + (1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1);
}
function rgbCalc() {
var rgb = document.getElementById('rgb-text');
var rgbValue = rgb.value.split(',');
r = parseInt(rgbValue[0]);
g = parseInt(rgbValue[1]);
b = parseInt(rgbValue[2]);
rgb.value = rgbToHex(r, g, b);
}
</script>
<style>
* { margin: 0; padding: 0; }
body { font-family: 'Segoe UI'; font-size: 14px; }
p.hero {
background-color: #000; color: #fff;
font-weight: bold; text-align: center;
padding: 8px; margin-bottom: 8px;
}
div.footer {
margin-top: 8px; padding: 8px;
background-color: #000; color: #fff;
font-weight: bold;
}
</style>
</head>
<body>
<p class="hero">rgbToHex</p>
<div>
<input id="rgb-text" value="R, G, B">
<button onclick="rgbCalc();">RGB > HEX</button>
</div>
<div class="footer">
<p>Version: 1.0 || by iiiypuk</p>
</div>
</body>
</html>
<!--
VERSION 1.0
- Init version
-->