Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for atticnumerals.hta

(view source code of atticnumerals.hta as plain text)

  1. <!DOCTYPE HTML>
  2. <html lang="en">
  3. <head>
  4.  
  5. <title>Attic Numerals Converter</title>
  6.  
  7. <meta http-equiv="x-ua-compatible" content="ie=9" />
  8.  
  9. <script type="text/javascript">
  10. window.resizeTo( 480, 540 ); // resize HTA
  11. window.moveTo( ( window.screen.width - 480 ) / 2, ( window.screen.height - 540 ) / 2 ); // center HTA on screen
  1. </script>
  2.  
  3. <HTA:APPLICATION
  4.   applicationname="Attic Numerals Converter"
  5.   id="AtticNumerals"
  6.   version="1.01"
  7.   scroll="no"
  8.   singleinstance="yes" />
  9.  
  10. <style type="text/css">
  1. html {
  2. 	height: 100%;
  3. 	width: 100%;
  4. }
  5.  
  6. body
  7. {
  8. 	background-color: #108010;
  9. 	color: black;
  10. 	filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#40F0C0',EndColorStr='#108010');
  11. 	font-family: arial, sans-serif;
  12. 	font-size: 12pt;
  13. 	height: 100%;
  14. 	margin: 0;
  15. 	padding: 0;
  16. 	width: 100%;
  17. }
  18.  
  19. a {
  20. 	color: darkgray;
  21. }
  22.  
  23. input[type=text] {
  24. 	background-color: white;
  25. 	border: 1px solid silver;
  26. 	color: black;
  27. 	height: 20px;
  28. 	text-align: right;
  29. 	width: 210px;
  30. }
  31.  
  32. th {
  33. 	text-align: left;
  34. }
  35.  
  36. .Button {
  37. 	border-radius: 8px;
  38. 	font-weight: bold;
  39. 	height: 22px;
  40. 	width: 147px;
  41. }
  42.  
  43. .Center {
  44. 	margin-left: auto;
  45. 	margin-right: auto;
  46. 	text-align: center;
  47. }
  48.  
  49. .Input {
  50. 	background-color: white;
  51. 	border: 1px solid silver;
  52. 	color: black;
  53. 	height: 22px;
  54. 	text-align: right;
  55. 	width: 212px;
  56. }
  57.  
  58. .Right {
  59. 	text-align: right;
  60. }
  1. </style>
  2. </head>
  3.  
  4. <script language="VBScript">
  1. Dim gvaAttic, gviDecimal, gviAttic, gvsAttic
  2. Dim imgAttic0050, imgAttic0500, imgAttic5000
  3.  
  4.  
  5. Sub window_onload
  6. 	document.getElementById( "AppName" ).innerHTML    = AtticNumerals.applicationname
  7. 	document.getElementById( "AppVersion" ).innerHTML = AtticNumerals.version
  8. 	document.title = AtticNumerals.applicationname & " " & AtticNumerals.version
  9. 	gviDecimal     = 0
  10. 	gviAttic       = 0
  11. 	' Use embedded images for Attic Numerals 50, 500 and 5000
  12. 	CreateImageSources
  13. 	document.getElementById( "Attic0050Src" ).src = imgAttic0050
  14. 	document.getElementById( "Attic0500Src" ).src = imgAttic0500
  15. 	document.getElementById( "Attic5000Src" ).src = imgAttic5000
  16. 	' The order in which the items are added determines the order of the calculations, so start with the highest number
  17. 	Set gvaAttic = CreateObject( "Scripting.Dictionary" )
  18. 	gvaAttic.Item( 10000 ) = "<span title=""10000"">&Mu;</span>"
  19. 	gvaAttic.Item(  5000 ) = "<img src=""" & imgAttic5000 & """ width=""18"" height=""18"" alt=""5000"" />"
  20. 	gvaAttic.Item(  1000 ) = "<span title=""1000"">&Chi;</span>"
  21. 	gvaAttic.Item(   500 ) = "<img src=""" & imgAttic0500 & """ width=""18"" height=""18"" alt=""500"" />"
  22. 	gvaAttic.Item(   100 ) = "<span title=""100"">&Eta;</span>"
  23. 	gvaAttic.Item(    50 ) = "<img src=""" & imgAttic0050 & """ width=""18"" height=""18"" alt=""50"" />"
  24. 	gvaAttic.Item(    10 ) = "<span title=""10"">&Delta;</span>"
  25. 	gvaAttic.Item(     5 ) = "<span title=""5"">&Pi;</span>"
  26. 	gvaAttic.Item(     1 ) = "<span title=""1"">&Iota;</span>"
  27. End Sub
  28.  
  29.  
  30. Sub Add1( )
  31. 	gviDecimal = gviDecimal + 1
  32. 	document.getElementById( "Decimal" ).value = gviDecimal
  33. 	ShowAttic
  34. End Sub
  35.  
  36.  
  37. Sub Add10( )
  38. 	gviDecimal = gviDecimal + 10
  39. 	document.getElementById( "Decimal" ).value = gviDecimal
  40. 	ShowAttic
  41. End Sub
  42.  
  43.  
  44. Sub Add100( )
  45. 	gviDecimal = gviDecimal + 100
  46. 	document.getElementById( "Decimal" ).value = gviDecimal
  47. 	ShowAttic
  48. End Sub
  49.  
  50.  
  51. Sub Add1000( )
  52. 	gviDecimal = gviDecimal + 1000
  53. 	document.getElementById( "Decimal" ).value = gviDecimal
  54. 	ShowAttic
  55. End Sub
  56.  
  57.  
  58. Sub Add10000( )
  59. 	gviDecimal = gviDecimal + 10000
  60. 	document.getElementById( "Decimal" ).value = gviDecimal
  61. 	ShowAttic
  62. End Sub
  63.  
  64.  
  65. Sub Add5( )
  66. 	gviDecimal = gviDecimal + 5
  67. 	document.getElementById( "Decimal" ).value = gviDecimal
  68. 	ShowAttic
  69. End Sub
  70.  
  71.  
  72. Sub Add50( )
  73. 	gviDecimal = gviDecimal + 50
  74. 	document.getElementById( "Decimal" ).value = gviDecimal
  75. 	ShowAttic
  76. End Sub
  77.  
  78.  
  79. Sub Add500( )
  80. 	gviDecimal = gviDecimal + 500
  81. 	document.getElementById( "Decimal" ).value = gviDecimal
  82. 	ShowAttic
  83. End Sub
  84.  
  85.  
  86. Sub Add5000( )
  87. 	gviDecimal = gviDecimal + 5000
  88. 	document.getElementById( "Decimal" ).value = gviDecimal
  89. 	ShowAttic
  90. End Sub
  91.  
  92.  
  93. Function AddAtticDigit( intSize )
  94. 	Dim intThisDigit, strThisDigit
  95. 	strThisDigit = ""
  96. 	If gviAttic < intSize Then
  97. 		strThisDigit = ""
  98. 	Else
  99. 		intThisDigit = Int( gviAttic / intSize )
  100. 		gviAttic     = gviAttic Mod ( intThisDigit * intSize )
  101. 		For i = 1 To intThisDigit
  102. 			strThisDigit = strThisDigit & gvaAttic.Item( intSize )
  103. 		Next
  104. 	End If
  105. 	AddAtticDigit = strThisDigit
  106. End Function
  107.  
  108.  
  109. Sub CenterWindow( )
  110. 	window.moveTo CInt( ( window.screen.width - document.body.offsetWidth ) / 2 ), CInt( ( window.screen.height - document.body.offsetHeight ) / 2 )
  111. End Sub
  112.  
  113.  
  114. Sub Clear( )
  115. 	document.getElementById( "Decimal" ).value   = ""
  116. 	document.getElementById( "Attic" ).innerHTML = ""
  117. End Sub
  118.  
  119.  
  120. Sub CreateImageSources( )
  121. 	' Embedded images for Attic Numerals 50, 500 and 5000
  122. 	imgAttic0050 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH2gkIEDkgnhnRdQAAAJZJREFUOI3t0KEKAkEUheFPEYsKi8lqMgu+gVhsVh/IKvgKaheTYPER9jVsm8wGDQs7OoMsaPBvc5j738Pl12gEsgM6CbOzmKjAtPRuY4IV5rjhgl5sUxHINthj8eZPVNTFCRmOr0TNBPES2+fwFaOUNqFtZ487wRjrUKNWRDpEH7tSNvi0UYisLlGFlGP/RVXyuuTf5Q6xnRXu4tnD1AAAAABJRU5ErkJggg=="
  123. 	imgAttic0500 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH2gkIEDkgnhnRdQAAAI5JREFUOI3t0LEJAkEURdGjmImIBjYgWIEt2IE1bDtWY2ZgA0aGNmAiiLGLJht8PrjsLgsaeGEY3mP+ZWb4NQYpL3CpVh1LzOpEc9ywDt0KD1xDd8QkDo6SqKz2U+g2OKeulMiiT4ylp3QVFdiGnL+ksWiHfcj3fGDYUNSaKV5dBnu70V/UXvTEoS/5d3kDD6QQnuVMCtgAAAAASUVORK5CYII="
  124. 	imgAttic5000 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH2gkIEDkgnhnRdQAAAJlJREFUOI3t0D0OAWEUheEHEZUIEhvQWAALEIl12ILFKO2ARq2htQRqncQCJBTzFTIZ30z8hMJJbnFP8Z5zL7+mUmrvYB8mpi6aMVALJ/TvvCHaWGCCHWaox5IauKa8CjYYYBW8c07jTBCMcUDvEaicRw6qhoCskMKNathKTlu+0miKueTJR4yebVRIRX/0B30AdMH6XfDv6gbFThh4peNQfAAAAABJRU5ErkJggg=="
  125. End Sub
  126.  
  127.  
  128. Sub ShowAttic( )
  129. 	Dim intKey, strVal
  130. 	gviDecimal = 0
  131. 	On Error Resume Next
  132. 	gviDecimal = CLng( document.getElementById( "Decimal" ).value )
  133. 	On Error Goto 0
  134. 	gviAttic   = gviDecimal
  135. 	gvsAttic   = ""
  136. 	For Each intKey In gvaAttic.Keys
  137. 		strVal   = AddAtticDigit( intKey )
  138. 		gvsAttic = gvsAttic & strVal
  139. 	Next
  140. 	document.getElementById( "Attic" ).innerHTML = gvsAttic
  141. End Sub
  1. </script>
  2.  
  3. <body onresize="vbscript:window.setTimeout('CenterWindow()',250,'VBScript')">
  4.  
  5. <div style="height: 25px;"></div>
  6.  
  7. <div style="height: 480px; margin: auto; width: 400px;">
  8.  
  9. <table style="height: 320px; width: 400px;">
  10. <tr title="Enter a decimal number">
  11. 	<th>Decimal</th>
  12. 	<th>&nbsp;&nbsp;&nbsp;</th>
  13. 	<th colspan="5"><input type="text" id="Decimal" onchange="vbscript:ShowAttic( )" onkeyup="vbscript:ShowAttic( )" /></th>
  14. </tr>
  15. <tr title="Use the buttons to enter an Attic numeral">
  16. 	<th>Attic Numerals</th>
  17. 	<th>&nbsp;</th>
  18. 	<th colspan="5"><div class="Input" id="Attic"></div></th>
  19. </tr>
  20. <tr>
  21. 	<th colspan="7">&nbsp;</th>
  22. </tr>
  23. <tr>
  24. 	<th colspan="7">Attic Input:</th>
  25. </tr>
  26. <tr>
  27. 	<th><input type="button" class="Button" value="Add         1" onclick="vbscript:Add1( )" /></th>
  28. 	<th>&nbsp;</th>
  29. 	<th>&Iota;</th>
  30. 	<th>&nbsp;&nbsp;&nbsp;</th>
  31. 	<th><input type="button" class="Button" value="Add         5" onclick="vbscript:Add5( )" /></th>
  32. 	<th>&nbsp;</th>
  33. 	<th>&Pi;</th>
  34. </tr>
  35. <tr>
  36. 	<th><input type="button" class="Button" value="Add       10" onclick="vbscript:Add10( )" /></th>
  37. 	<th>&nbsp;</th>
  38. 	<th>&Delta;</th>
  39. 	<th>&nbsp;</th>
  40. 	<th><input type="button" class="Button" value="Add       50" onclick="vbscript:Add50( )" /></th>
  41. 	<th>&nbsp;</th>
  42. 	<th><img id="Attic0050Src" width="18" height="18" alt="50" /></th>
  43. </tr>
  44. <tr>
  45. 	<th><input type="button" class="Button" value="Add     100" onclick="vbscript:Add100( )" /></th>
  46. 	<th>&nbsp;</th>
  47. 	<th>&Eta;</th>
  48. 	<th>&nbsp;</th>
  49. 	<th><input type="button" class="Button" value="Add     500" onclick="vbscript:Add500( )" /></th>
  50. 	<th>&nbsp;</th>
  51. 	<th><img id="Attic0500Src" width="18" height="18" alt="500" /></th>
  52. </tr>
  53. <tr>
  54. 	<th><input type="button" class="Button" value="Add   1000" onclick="vbscript:Add1000( )" /></th>
  55. 	<th>&nbsp;</th>
  56. 	<th>&Chi;</th>
  57. 	<th>&nbsp;</th>
  58. 	<th><input type="button" class="Button" value="Add   5000" onclick="vbscript:Add5000( )" /></th>
  59. 	<th>&nbsp;</th>
  60. 	<th><img id="Attic5000Src" width="18" height="18" alt="5000" /></th>
  61. </tr>
  62. <tr>
  63. 	<th><input type="button" class="Button" value="Add 10000" onclick="vbscript:Add10000( )" /></th>
  64. 	<th>&nbsp;</th>
  65. 	<th>&Mu;</th>
  66. 	<th>&nbsp;</th>
  67. 	<th><input type="button" class="Button" value="Clear" onclick="vbscript:Clear( )" /></th>
  68. 	<th>&nbsp;</th>
  69. 	<th>&nbsp;</th>
  70. </tr>
  71. </table>
  72.  
  73. <div style="height: 25px;"></div>
  74.  
  75. <p class="Center"><span id="AppName">Application</span>,&nbsp; Version <span id="AppVersion">0.00</span><br />
  76. &copy; 2018, Rob van der Woude<br />
  77. <a href="http://www.robvanderwoude.com/attics.php">www.robvanderwoude.com</a></p>
  78.  
  79. <p class="Center">More info on <a href="http://en.wikipedia.org/wiki/Attic_numerals">Attic numerals</a> at <a href="http://en.wikipedia.org/wiki/Attic_numerals">WikiPedia</font></a></p>
  80.  
  81. </div>
  82.  
  83. </body>
  84. </html>

page last modified: 2024-04-16; loaded in 0.0135 seconds