»
EnglishFrenchVietnamese

Print - Air Distances script - JavaScriptBank.com

Full version: jsB@nk » Calculation » Air Distances script
URL: https://www.javascriptbank.com/air-distances-script.html

Air Distances script © JavaScriptBank.comShows air distances between selected world cities.

Full version: jsB@nk » Calculation » Air Distances script
URL: https://www.javascriptbank.com/air-distances-script.html



JavaScript
<SCRIPT language=JavaScript><!-- Hide from JavaScript-Impaired Browsersvar l=0;var r=0;var tc="";var al=" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";var ns="0123456789";function iA(){ this.length=iA.arguments.length; for (var i=0;i<this.length;i++){  this[i]=iA.arguments[i]; }}/* 3011 byte database of air distances uses position in the   string "al" to substitute for the numerics, saving a bit   over 4k download to visitors. */var a=new iA(35);a[0]="Berlin, Germany*   ciagchdcheihh dadeee gcaa hdef egeghfaci"+"ibf da  cifdcd ebehe eddegagecehadhfaa gcgh e debbfageedkbgdca";a[1]="Bombay, India*   ibga deacde dhabfgh bbiifhgddfhg caefa igb"+"cacggiei dacigddcfbifbffgcgeaihbfchdj dggdcacbdcdaigfhbhf";a[2]="Buenos Aires, Argentina*   jbddbgiaceifkdfgefgegggffibfabk "+"dgbcdfchchec hhegfacchfhhkiggcfefhga abbfic gffialb ihfkd fbffdb";a[3]="Calcutta, India*   f ccgdeebaecg dcfefccdiehaebaieeeie cdeg"+"ibebgddfjaadhib bceagdhedaichde jiigbbbaaagicaig dchf";a[4]="Capetown, South Africa*   fiee hgcgkecebbjccf aiiggecfdahea"+"fbigh jaafdig aehdh edeighfgaacggebee  jb h ff bi gg bbce";a[5]="Darwin, Australia*   ibgbfdecfgcigaahf ghdaihaifi hg eiiffb"+"dh bjcehehcgcgafigbhfciifhaihifgfbcadb hccgccafda";a[6]="Gibraltar*   fhch hahgebga ieidgdhjh efcbdacfced agidic iff"+" abahcchb edgha cfdaedfffegbcfiil fda ";a[7]="Hong Kong*   eeddihefceihgbd fidfahghdddh edeeecdj h"+"eifabcdihgfef ck  eggkfafdg ggafeah eheeda";a[8]="Honolulu, Hawaii, USA*   ha bhbgbcbefec eeacghg cdifc  fghe"+"begdce ghgde  f hhaih bfgibfhdicfgachedgajhg";a[9]="Istanbul, Turkey*   ee aeefhdeffi iga a ie aea aebfgead dch"+" fidfdbeffd  hehagf fdifecgeefjffcca";a[10]="Juneau, Alaska, USA*   ddbahdehgh dcbbdecbhea id eddfdfcde"+"bfbbbffcbggf ebegbg i dhggbdd agdhhh ";a[11]="London, England, UK*   eddffgje eedaeecdfdch gaebh bae eba"+"eca aagegg higbfdghegafgdeidkfhdf ";a[12]="Los Angeles, California, USA*   gbggicaedf gbdebhheccc  ef"+" fbegecbehdcafc fcceec iffdhhggedgfgaj b";a[13]="Manilla, Phillipines*   cidhhceachdidhbf bjbhffgagg"+"efbhabffekbefdfjicffdaaeadhahfeafegf";a[14]="Melbourne, Australia*   hdbhifjcfgefiici bjd efghffje jedh"+"aiiicg  haie acgfe iaf fh ";a[15]="Mexico City, Mexico*   ffib idcaegaae egaggcgfgbdedfbdggfc"+"ed ebcdh djcag dfi idh";a[16]="Moscow, Russia*   dffd da bfgaaedcf agadbdb fgb adghgieb d"+"bdebddfejbhdbg";a[17]="New York City, New York, USA*   cggcfgbbccfbfhbeei ddbehdh"+"bdbge ibdagcfifcfgdhiegg ";a[18]="Nome, Alaska, USA*   chdeeddegcdcegecdiccgheie hhcfaihcghf"+"aebihgchhba";a[19]="Oslo, Norway*   efi hcdcfbbacbfa hfdhabdgiadeie bfbeebbjig"+"dh ";a[20]="Panama City, Panama*   echhiagaebffdgacbiei bidcfeicbkfihd"+"bgdchbe";a[21]="Paris, France*   ea aihcbdacheg  fhgbediiegeffgf ckgidd ";a[22]="Peking, China*   dehfdbdi jgge ekgged  ffbggacafg eh ";a[23]="Port Said, Suez Canal, Egypt*   ebecbcfbdacbh ifgfeace ieh"+"djbebgc";a[24]="Quebec, Quebec, Canada*   baieaccidee bcefihia fdbibcgdd";a[25]="Reykjavik, Faxa Bay, Iceland*   fabb dgbccfaeefgafedgjgbegf";a[26]="Rio de Janeiro, Brazil*   efiahffhikcdiggkedgceeei";a[27]="Rome, Italy*   gdbeffefhfbcfabkebcga";a[28]="Santiago, Chile*   fbckfejbcjfdegigah";a[29]="Seattle, Washington, USA*   eg h fdghgbdicf";a[30]="Shanghai, China*   bcha if eeig";a[31]="Singapore, Singapore*   cc ebiddh";a[32]="Tokyo, Japan*   egfg d";a[33]="Wellington, New Zealand*   hab";a[34]="Zanzibar City, Tanzania*   ";var b=new iA(4);b[0]=1;b[1]=10;b[2]=100;b[3]=1000;b[4]=10000;function getMiles(form){ lf=(document.isn.isn1.options[document.isn.isn1.selectedIndex].value); rf=(document.isn.isn2.options[document.isn.isn2.selectedIndex].value); l=al.indexOf(lf); r=al.indexOf(rf); if (r<l){  l=r;  r=al.indexOf(lf);  } ls=a[l]; pos=ls.indexOf("*") ls1="From "+ls.substring(0,pos)+" to " +a[r].substring(0,a[r].indexOf("*"))+" is about "; ls=ls.substring(pos+1,ls.length); tc=ls.substring(((r*3)-(l*3)),ls.length); if (document.isn.rb[1].checked){  dispKm();  } else{  dispMi();  }}function dispMi(){ ch=tc.charAt(0); ls1+=al.indexOf(ch); ch=tc.charAt(1); ls1+=al.indexOf(ch); ch=tc.charAt(2); if (ch!=" "){  ls1+=(al.indexOf(ch)*10)+" miles";  } //1.613  else ls1+="00"+" miles"; document.isn.disp.value=ls1;}function dispKm(){ ch=tc.charAt(0); km=""; km+=al.indexOf(ch); ch=tc.charAt(1); km+=al.indexOf(ch); ch=tc.charAt(2); if (ch!=" "){  km+=(al.indexOf(ch)*10);  }  else{   km+="00";  }  num=0;  kml=km.length;  for (var i=kml-1;i>-1;i--){   cr=km.substring(i,i+1);   pos=ns.indexOf(cr);   num+=pos*b[kml-i-1];  }  km="";  km+=num*1.613;  pos=km.indexOf(".");  if (pos>-1){   km=km.substring(0,pos);  }  ls1+=km+" kilometres";  document.isn.disp.value=ls1;}// End Hiding --></SCRIPT><SCRIPT language=JavaScript><!--function retrace(){  history.back() }// --></SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<FORM name=isn><TABLE width=500 border=0>  <TBODY>  <TR>    <TD align=middle colSpan=3>      <HR noShade>      <FONT color=blue><B>Air Distances between Selected World Cities</B></FONT></TD></TR>  <TR>    <TD align=middle><FONT color=blue><B>Starting City</B></FONT><BR><SELECT       size=12 name=isn1>         <SCRIPT language=JavaScript><!-- Hide from JavaScript-Impaired Browsersls="";for (var i=0;i<35;i++){ ls+='<OPTION VALUE="'+al.substring(i,i+1)+'" onClick=""'; if (i==0){ls+=' SELECTED';} ls+='>'+a[i].substring(0,a[i].indexOf("*")); }document.write(ls);// End hiding --></SCRIPT>      </SELECT></TD>    <TD vAlign=top align=middle><FONT color=blue><B>Instructions:</B></FONT>       <BR>Select your starting city at left, destination at right. Or, if you are feeling particularly contrary today, vice versa. Choose whether you want miles or kilometres, then click below.      <P><INPUT onclick=getMiles(this.form) type=button value=" Get Distance " name=but>       <BR><INPUT onclick="" type=radio CHECKED value=a name=rb>Miles<BR><INPUT       onclick="" type=radio value=b name=rb>Kilometres </P>    <TD align=middle><FONT color=blue><B>Destination City</B></FONT>       <BR><SELECT size=12 name=isn2>         <SCRIPT language=JavaScript><!-- Hide from JavaScript-Impaired Browsersls="";for (var i=0;i<35;i++){ ls+='<OPTION VALUE="'+al.substring(i,i+1)+'" onClick=""'; if (i==1){ls+=' SELECTED';} ls+='>'+a[i].substring(0,a[i].indexOf("*")); }document.write(ls);// End hiding --></SCRIPT>      </SELECT></TD></TR>  <TR>    <TD align=middle colSpan=3>      <TABLE border=2>        <TBODY>        <TR>          <TD><INPUT size=80 name=disp> </TD></TR></TBODY></TABLE></TD></TR>  <TR>    <TD colSpan=3>      <HR noShade>    </TD></TR></TBODY></TABLE></FORM><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->