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

page last uploaded: 2017-04-06, 13:33