ASCIIMathML.js (ver 1.4.7) download page
ASCIIMathML.js is freely available under the GNU General Public
License. The current version is 1.4.7 (what's new).
If the instructions on this page seem complicated, don't worry.
You only have to do this the first time you want to use
ASCIIMathML.js on your own webpages. If you use it on a webpage,
please put a link to www.chapman.edu/~jipsen/asciimath.xml on that
webpage and send me an email at jipsen@chapman.edu with the URL
so that I can add a link on the users page. (Also send me an email if
you have problems or would like to provide some feedback.)
Here is the script: ASCIIMathML.js
(right-click on the link and choose "Save Link Target As..." if your
browser does not display the JavaScript code).
To make your XHTML file work in both Internet Explorer 6+MathPlayer
and Mozilla/Netscape 7+, you should also download David Carlisle's
pmathml.xsl stylesheet at http://www.w3.org/Math/XSL/pmathml.xsl (right-click on the link and choose "Save Link Target As...").
Or get both files bundled together: The script, a copy of this
page, and sample .html and .xml files are zipped (or tar'd) at
asciimathml-1.4.7
on
Just save both files in a local folder on your computer or your
webserver.
To write your own XHTML file that uses ASCIIMathML.js, give the file a
name that ends with .xml and use the following lines
at the top of your file:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="http://yourdomain/yourpathto/pmathml.xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://yourdomain/yourpathto/ASCIIMathML.js"></script>
<title>your title</title>
</head>
<body>
Of course you should fill in the "yourdomain/yourpathto" part with the
correct information (or delete http://yourdomain/yourpathto/ and
put ASCIIMathML.js and pmathml.xsl in the same folder as your XHTML file),
and end your file with
</body>
</html>
Since cross-browser MathML only works with XHTML files, remember to
write all tags in lowercase, use matching opening and closing tags
(like <p></p>), and write empty tags with a trailing slash (like
<hr/>).
Well, actually with ASCIIMathML one can now also get cross-browser
MathML rendered on HTML pages, see
asciimath.html.
That's it!
Here is a sample
file that you can save and modify to suit your local needs.
Finally, some information on how to extend
ASCIIMathML.js with additional symbols (this method may be preferable
to editing the file ASCIIMathML.js).
$countryCodeName = array(
'AF' => 'Afghanistan',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
'AO' => 'Angola',
'AI' => 'Anguilla',
'AQ' => 'Antarctica',
'AG' => 'Antigua and Barbuda',
'AR' => 'Argentina',
'AM' => 'Armenia',
'AW' => 'Aruba',
'AU' => 'Australia',
'AT' => 'Austria',
'AZ' => 'Azerbaijan',
'BS' => 'Bahamas',
'BH' => 'Bahrain',
'BD' => 'Bangladesh',
'BB' => 'Barbados',
'BY' => 'Belarus',
'BE' => 'Belgium',
'BZ' => 'Belize',
'BJ' => 'Benin',
'BM' => 'Bermuda',
'BT' => 'Bhutan',
'BO' => 'Bolivia',
'BA' => 'Bosnia and Herzegovina',
'BW' => 'Botswana',
'BV' => 'Bouvet Island',
'BR' => 'Brazil',
'IO' => 'Chagos Archipelago',
'VG' => 'British Virgin Islands',
'BN' => 'Brunei Darussalam',
'BG' => 'Bulgaria',
'BF' => 'Burkina Faso',
'BI' => 'Burundi',
'KH' => 'Cambodia',
'CM' => 'Cameroon',
'CA' => 'Canada',
'CV' => 'Cape Verde',
'KY' => 'Cayman Islands',
'CF' => 'Central African Republic',
'TD' => 'Chad',
'CL' => 'Chile',
'CN' => 'China',
'CX' => 'Christmas Island',
'CC' => 'Cocos Islands',
'CO' => 'Colombia',
'KM' => 'Comoros',
'CD' => 'Congo',
'CG' => 'Congo',
'CK' => 'Cook Islands',
'CR' => 'Costa Rica',
'CI' => 'Cote D\'Ivoire',
'CU' => 'Cuba',
'CY' => 'Cyprus',
'CZ' => 'Czech Republic',
'DK' => 'Denmark',
'DJ' => 'Djibouti',
'DM' => 'Dominica',
'DO' => 'Dominican Republic',
'TL' => 'Timor-Leste',
'EC' => 'Ecuador',
'EG' => 'Egypt',
'SV' => 'El Salvador',
'GQ' => 'Equatorial Guinea',
'ER' => 'Eritrea',
'EE' => 'Estonia',
'ET' => 'Ethiopia',
'FO' => 'Faeroe Islands',
'FK' => 'Falkland Islands',
'FJ' => 'Fiji',
'FI' => 'Finland',
'FR' => 'France',
'GF' => 'French Guiana',
'PF' => 'French Polynesia',
'TF' => 'French Southern Territories',
'GA' => 'Gabon',
'GM' => 'Gambia',
'GE' => 'Georgia',
'DE' => 'Germany',
'GH' => 'Ghana',
'GI' => 'Gibraltar',
'GR' => 'Greece',
'GL' => 'Greenland',
'GD' => 'Grenada',
'GP' => 'Guadaloupe',
'GU' => 'Guam',
'GT' => 'Guatemala',
'GN' => 'Guinea',
'GW' => 'Guinea-Bissau',
'GY' => 'Guyana',
'HT' => 'Haiti',
'HM' => 'Heard and McDonald Islands',
'VA' => 'Vatican City State',
'HN' => 'Honduras',
'HK' => 'Hong Kong',
'HR' => 'Croatia',
'HU' => 'Hungary',
'IS' => 'Iceland',
'IN' => 'India',
'ID' => 'Indonesia',
'IR' => 'Iran',
'IQ' => 'Iraq',
'IE' => 'Ireland',
'IL' => 'Israel',
'IT' => 'Italy',
'JM' => 'Jamaica',
'JP' => 'Japan',
'JO' => 'Jordan',
'KZ' => 'Kazakhstan',
'KE' => 'Kenya',
'KI' => 'Kiribati',
'KP' => 'Korea',
'KR' => 'Korea',
'KW' => 'Kuwait',
'KG' => 'Kyrgyz Republic',
'LA' => 'Lao People\'s Democratic Republic',
'LV' => 'Latvia',
'LB' => 'Lebanon',
'LS' => 'Lesotho',
'LR' => 'Liberia',
'LY' => 'Libyan Arab Jamahiriya',
'LI' => 'Liechtenstein',
'LT' => 'Lithuania',
'LU' => 'Luxembourg',
'MO' => 'Macao',
'MK' => 'Macedonia',
'MG' => 'Madagascar',
'MW' => 'Malawi',
'MY' => 'Malaysia',
'MV' => 'Maldives',
'ML' => 'Mali',
'MT' => 'Malta',
'MH' => 'Marshall Islands',
'MQ' => 'Martinique',
'MR' => 'Mauritania',
'MU' => 'Mauritius',
'YT' => 'Mayotte',
'MX' => 'Mexico',
'FM' => 'Micronesia',
'MD' => 'Moldova',
'MC' => 'Monaco',
'MN' => 'Mongolia',
'MS' => 'Montserrat',
'MA' => 'Morocco',
'MZ' => 'Mozambique',
'MM' => 'Myanmar',
'NA' => 'Namibia',
'NR' => 'Nauru',
'NP' => 'Nepal',
'AN' => 'Netherlands Antilles',
'NL' => 'Netherlands',
'NC' => 'New Caledonia',
'NZ' => 'New Zealand',
'NI' => 'Nicaragua',
'NE' => 'Niger',
'NG' => 'Nigeria',
'NU' => 'Niue',
'NF' => 'Norfolk Island',
'MP' => 'Northern Mariana Islands',
'NO' => 'Norway',
'OM' => 'Oman',
'PK' => 'Pakistan',
'PW' => 'Palau',
'PS' => 'Palestinian Territory',
'PA' => 'Panama',
'PG' => 'Papua New Guinea',
'PY' => 'Paraguay',
'PE' => 'Peru',
'PH' => 'Philippines',
'PN' => 'Pitcairn Island',
'PL' => 'Poland',
'PT' => 'Portugal',
'PR' => 'Puerto Rico',
'QA' => 'Qatar',
'RE' => 'Reunion',
'RO' => 'Romania',
'RU' => 'Russian Federation',
'RW' => 'Rwanda',
'SH' => 'St. Helena',
'KN' => 'St. Kitts and Nevis',
'LC' => 'St. Lucia',
'PM' => 'St. Pierre and Miquelon',
'VC' => 'St. Vincent and the Grenadines',
'WS' => 'Samoa',
'SM' => 'San Marino',
'ST' => 'Sao Tome and Principe',
'SA' => 'Saudi Arabia',
'SN' => 'Senegal',
'SC' => 'Seychelles',
'SL' => 'Sierra Leone',
'SG' => 'Singapore',
'SK' => 'Slovakia',
'SI' => 'Slovenia',
'SB' => 'Solomon Islands',
'SO' => 'Somalia',
'ZA' => 'South Africa',
'GS' => 'South Georgia and the South Sandwich Islands',
'ES' => 'Spain',
'LK' => 'Sri Lanka',
'SD' => 'Sudan',
'SR' => 'Suriname',
'SJ' => 'Svalbard & Jan Mayen Islands',
'SZ' => 'Swaziland',
'SE' => 'Sweden',
'CH' => 'Switzerland',
'SY' => 'Syrian Arab Republic',
'TW' => 'Taiwan',
'TJ' => 'Tajikistan',
'TZ' => 'Tanzania',
'TH' => 'Thailand',
'TG' => 'Togo',
'TK' => 'Tokelau',
'TO' => 'Tonga',
'TT' => 'Trinidad and Tobago',
'TN' => 'Tunisia',
'TR' => 'Turkey',
'TM' => 'Turkmenistan',
'TC' => 'Turks and Caicos Islands',
'TV' => 'Tuvalu',
'VI' => 'US Virgin Islands',
'UG' => 'Uganda',
'UA' => 'Ukraine',
'AE' => 'United Arab Emirates',
'GB' => 'UK',
'UK' => 'UK',
'UM' => 'United States Minor Outlying Islands',
'US' => 'USA',
'UY' => 'Uruguay',
'UZ' => 'Uzbekistan',
'VU' => 'Vanuatu',
'VE' => 'Venezuela',
'VN' => 'Viet Nam',
'WF' => 'Wallis and Futuna Islands',
'EH' => 'Western Sahara',
'YE' => 'Yemen',
'YU' => 'Yugoslavia',
'ZM' => 'Zambia',
'ZW' => 'Zimbabwe',
'**' => 'Unknown'
);
$iplines = file('../php/ip-to-country.txt');
$num_iplines = count($iplines);
function iptocountry($ip) {
global $countryCodeName, $iplines, $num_iplines;
$numbers = preg_split("/\./", $ip);
$code = $numbers[0]*16777216+$numbers[1]*65536+$numbers[2]*256+$numbers[3];
$n = -1;
$h = $num_iplines;
while ($n+1<$h) {
$m = ($n+$h) >> 1;
if (substr($iplines[$m],0,-2)<$code) {$n = $m;} else {$h = $m;}
}
$cn = $countryCodeName[substr($iplines[$h-1],-3,2)];
// if ($cn == '') {echo $code.' ';}
return $cn;
}
$lines = file('asciimathdownloadcounter.txt');
$num_lines = count($lines);
$countries = array();
$ipaddr = array();
$last =array();
$visits = 0;
for ($i = 0; $i < $num_lines; $i++) {
$ipn = explode(" ",$lines[$i]);
if (!isset($ipaddr[$ipn[0]])) {
$ipaddr[$ipn[0]]=1;
$visits++;
$c = iptocountry($ipn[0]);
if (isset($countries[$c])) {$countries[$c]++;} else {$countries[$c]=1;}
if ($i >= $num_lines-10) { $last[] = $c; }
} else {
if ($i >= $num_lines-10) { $last[] = iptocountry($ipn[0]); }
}
}
ksort($countries);
echo "$hits visits from ".(count($countries)-2)." countries (since Jan 10, 2004)
";
foreach ($countries as $key=>$val)
if ($key!=Unknown && $key!="Hong Kong") {echo $key.", ";}
echo "
Countries of most recent visitors: ".implode(" ",$last);
echo "";
?>