View bitcoinpriceinwords.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Bitcoin Price in Words - Sylvain Saurel</title> | |
<link rel="preconnect" href="https://fonts.gstatic.com"> | |
<link href="https://fonts.googleapis.com/css2?family=Sriracha&display=swap" rel="stylesheet"> | |
<script type="text/javascript"> | |
var textToSpeech = ""; |
View sayBitcoinPrice.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sayBitcoinPrice() { | |
if (textToSpeech) { | |
const utterance = new SpeechSynthesisUtterance(textToSpeech); | |
utterance.lang = 'en-US'; | |
speechSynthesis.speak(utterance); | |
} | |
} |
View numberToWords.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = ['','one ','two ','three ','four ', 'five ','six ','seven ','eight ','nine ','ten ','eleven ','twelve ','thirteen ','fourteen ','fifteen ','sixteen ','seventeen ','eighteen ','nineteen ']; | |
var b = ['', '', 'twenty','thirty','forty','fifty', 'sixty','seventy','eighty','ninety']; | |
function numberToWords (num) { | |
if ((num = num.toString()).length > 9) | |
return 'MOON'; | |
n = ('000000000' + num).substr(-9).match(/^(\d{2})(\d{2})(\d{2})(\d{1})(\d{2})$/); | |
if (!n) |
View parseJson.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseJson(json) { | |
var time = "on " + json["time"]["updated"]; | |
var usdValue = json["bpi"]["USD"]["rate"]; | |
var gbpValue = json["bpi"]["GBP"]["rate"]; // ToDo later | |
var euroValue = json["bpi"]["EUR"]["rate"]; // ToDo later | |
var usdValueInWords = (numberToWords(usdValue.split(".")[0].replace(",","")) + " dollars").toUpperCase(); | |
document.getElementById("content").innerHTML = usdValueInWords; | |
View bpi_call.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bitcoinPrice() { | |
var xmlhttp = new XMLHttpRequest(); | |
var url = "https://api.coindesk.com/v1/bpi/currentprice.json"; | |
xmlhttp.onreadystatechange = function() { | |
if (this.readyState == 4 && this.status == 200) { | |
var json = JSON.parse(this.responseText); | |
parseJson(json); | |
} | |
}; |
View index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Bitcoin Price in Words - Sylvain Saurel</title> | |
<link rel="preconnect" href="https://fonts.gstatic.com"> | |
<link href="https://fonts.googleapis.com/css2?family=Sriracha&display=swap" rel="stylesheet"> | |
<style> | |
#top { |
View hexadecimalcolorclock.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed&display=swap" rel="stylesheet"> | |
<style> | |
#hexatime { | |
width: 300px; | |
text-align: center; | |
margin: 0 auto; | |
margin-top: 500px; |
View hexislight.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hexislight(color) { | |
var hex = color.replace('#', ''); | |
var red = parseInt(hex.substr(0, 2), 16); | |
var green = parseInt(hex.substr(2, 2), 16); | |
var blue = parseInt(hex.substr(4, 2), 16); | |
// it is a known formula, nothing magical here | |
var brightness = ((red * 299) + (green * 587) + (blue * 114)) / 1000; | |
return brightness > 155; | |
} |
View hexaTime.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hexaTime() { | |
var date = new Date(); | |
// we convert in the 0 .. 255 range | |
var seconds = parseInt(date.getSeconds() * 255 / 59); | |
var minutes = parseInt(date.getMinutes() * 255 / 59); | |
var hours = parseInt(date.getHours() * 255 / 23); | |
return "#" + toHex(hours) + toHex(minutes) + toHex(seconds); | |
} |
View ToHex.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function toHex(d) { | |
var hex = ("0" + (Number(d).toString(16))).slice(-2).toUpperCase(); | |
return hex; | |
} |
NewerOlder