'use strict'; /* JWBjs.php is a required part of the Javascript Weight & Balance program. Copyright (C) 2011-2019 Terry Liittschwager This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ $('#jsDate').html('2019-04-27'); var bFoundTailNum, day, eqZFW=0, eqTAXI=1, eqTAKEOFF=2, eqLANDING=3, eqINCAFTCUM=4, eqZFWGT545=5, eqLGWAFTCG=6, eTime, fBrowser, filename, hour, i, iButton, iDoc, iKey, iLen, iLoad, iPosFile, iSemicolon, iTail, iUserAgent, lsIndex, minute, month, nKeys, nLoadsLocal, nLoadsServer, now=new Date(), nowSecs=(now.getTime()/1000)+(now.getTimezoneOffset()*60), nTailsLocal, nTailsServer, sAirFile, sArg, sBrowser='', sCodeLoc=[], second, sFuelDenByWt, sFuelFile, sMTOWxZFW, sPosFile, sServerLoadArray=[], sServerName, sSplit, ssSplit, sTailFileName, sTailNum=[], sTestText=[], sTime, sZFWGT545, tailnum, then, sTemp, sUserAgent, year, oSource={ codeloc:'', filename:'', from:'', posfile:'', tailnum:'', tmSeconds:0, type:'' } ; /* $(document).ajaxError(function(){ $.prompt('No Ajax'); }); */ $.prompt.setDefaults({opacity:.7,overlayspeed:'fast'}); window.$wb={ anAirlineName:$('#anAirlineName'), laLocalAircraft:$('#laLocalAircraft'), laLocalMsg:$('#laLocalMsg'), llLocalLoads:$('#llLocalLoads'), llLocalMsg:$('#llLocalMsg'), saServerAircraft:$('#saServerAircraft'), slServerLoads:$('#slServerLoads'), stServerLoads:$('#stServerLoads') }; var urlstr; var jqxhr=$.getJSON('planes.jdat', function(planes) { $wb.anAirlineName.append(''); $wb.anAirlineName.append('
' + planes.airlineName + '
'); $wb.anAirlineName.append('
'); sServerName=document.location.href.slice(0,document.location.href.indexOf('index')); $('#snServerName').html(sServerName); // sBrowser=window.navigator.userAgent; // $('#biBrowserInfo').html(sBrowser); // AIRCRAFT ON SERVER $wb.saServerAircraft.empty(); nTailsServer=planes.airPlane.length; sTailNum=Array(nTailsServer); sCodeLoc=Array(nTailsServer); for (iTail=0; iTail' + sTailNum[iTail] + '
'); } var sParam=window.location.search.substring(1).split('&'); if (sParam!='') { if (sParam=='nolocal') window.location='nolocal.html'; else { bFoundTailNum=false; for (iTail=0; iTail0) { sServerLoadArray.sort(); for (iLoad=nLoadsServer-1; iLoad>=0; iLoad--) { filename=sServerLoadArray[iLoad]; if (filename.substr(0,4)=='TEST') continue; tailnum=filename.substring(0,filename.length-6); year=filename.substr(0,4); if ($.isNumeric(year)&&year!=2222) { month=filename.substr(5,2)-1; day=filename.substr(8,2); hour=filename.substr(11,2); minute=filename.substr(13,2); second=filename.substr(15,2); then=new Date(year,month,day,hour,minute,second); eTime=nowSecs-(then.getTime()/1000); if (eTime<60) sTime=sprintf(' %d seconds',eTime); else { eTime/=60; if (eTime<60) sTime=sprintf(' %d minutes',eTime); else { eTime/=60; if (eTime<24) sTime=sprintf(' %d hours',eTime); else { eTime/=24; sTime=sprintf(' %5.1f days',eTime); } } } } else { sTime='  test file'; } sSplit=filename.split('_'); ssSplit=sSplit[3].split('.'); sArg="'" + filename + "','server','" + sSplit[2] + ".jpos','" + ssSplit[0] + "','load'"; $wb.slServerLoads.append('' + sTime + '
'); } } // AIRCRAFT IN LOCAL STORAGE airlocal(); // LOADS IN LOCAL STORAGE setLoadsLocalMsg(); $wb.llLocalMsg.show(); $wb.llLocalLoads.empty(); nLoadsLocal=0; for (iKey=nKeys-1; iKey>=0; iKey--) { filename=lsIndex[iKey]; sSplit=filename.split('_'); if (sSplit[3]!=undefined) { ssSplit=sSplit[3].split('.'); tailnum=filename.substring(0,filename.length-6); year=filename.substr(0,4); if ($.isNumeric(year)) { month=filename.substr(5,2)-1; day=filename.substr(8,2); hour=filename.substr(11,2); minute=filename.substr(13,2); second=filename.substr(16,2); second=filename.substr(13,2); then=new Date(year,month,day,hour,minute,second); eTime=nowSecs-(then.getTime()/1000); if (eTime<60) sTime=sprintf(' %d seconds',eTime); else { eTime/=60; if (eTime<60) sTime=sprintf(' %d minutes',eTime); else { eTime/=60; if (eTime<24) sTime=sprintf(' %d hours',eTime); else { eTime/=24; sTime=sprintf(' %5.1f days',eTime); } } } } else { sTime=' test file'; } sArg="'" + filename + "','local','" + sSplit[2] + ".jpos','" + ssSplit[0] + "','load'"; $wb.llLocalLoads.append('' + sTime + '
'); nLoadsLocal++; } } if (nLoadsLocal>0) $wb.llLocalMsg.hide(); // AIRCRAFT OVERVIEW var fMaxLandingWt, fMaxTakeoffWt, fMaxTaxiWt, fMaxZfWt, iJair=0, iPt; $('#dpOverview').empty(); for (iTail=0; iTail' + sTailNum[iTail] + '   '); (function(iAir) { $.getJSON(sCodeLoc[iTail] + '/data/' + sTailNum[iAir] + '.jair',function(plane) { fMaxZfWt=plane.ev[eqZFW].pt[0].wt; for (iPt=1; iPt                                                                                                  ' + plane.docs[iDoc]); } } */ }); })(iJair); iJair++; } // TEST LOADS ON SERVER $('#stServerLoads').empty(); var nTestText=0; for (iLoad=0; iLoad'); (function(iText) { $.getJSON('reports/' + filename,function(new_ld) { $('#stServerLoads li').eq(iText).append('  ' + new_ld.testtext); }); })(nTestText); nTestText++; } } }); var value=$.jStorage.get('noflash'); if (!value) { var sFirstText="
\ \

JWAB (Javascript Weight And Balance) is a browser-based SPA (Single-Page Application) weight and balance app for freighter aircraft. I wrote it as an exercise to keep my aging brain active. I'm in my 80s now, but I still add to it from time to time. There was some thought that it might replace a DOS program I wrote that was used during the years 1988 through 2016 at three freight carriers, but that didn't happen. The DOS program handled Boeing 727, 747 and 767 aircraft, Douglas DC-8 and DC-9 aircraft, and Lockheed L‑1011 aircraft. The current aircraft in JWAB are just 747s and 767s.

\

The app is freeware (GPLv3). Play with it if you like. Questions to Terry at terry.liittschwager@gmail.com.

\ \
USAGE NOTES update of 2020-07-02
\ \
    \
  • The POSITION REFERENCE DATA radio button menu on 747 aircraft pages now has three more options:\
      \
    • “target offset” shows where each position is relative to the target zero fuel c.g. used by AUTO LOAD.
    • \
    • “zfw cg offset” shows where each position is relative to the current zero fuel c.g.
    • \
    • “sequence” is the position sequence number starting with one.
    • \
    \ The added options are to help in the development of the AUTO LOAD feature. The AUTO LOAD section is just above the ULD POSITIONS on 747 aircraft, but it's not yet functional. When I have it working on the 747, I'll add it to the 767.\
  • \
  • Test loads being used for development have a year of 2222 to keep them at the top of the SERVER Loads list, and the word TEST appears in place of the created time of day.
  • \
  • The weight unit default for N919YY and N952YY is kilograms. The default for all other aircraft is pounds. You can use the WEIGHT UNIT IN USE radio buttons to change which unit will be used in the display. Kilogram weights are in this color. Pound weights are in this color.
  • \
  • You can speed up the program by using the Toggle Plotting button to turn off the plotting. If a linear or cumulative limit is exceeded, the plotting is automatically turned back on so you can see what happened.
  • \
\
" ; $.prompt(sFirstText,{overlayspeed:'fast',prefix:'wideJqi',top:15}); } $.jStorage.deleteKey('noflash'); function airlocal() { 'use strict'; lsIndex=$.jStorage.index(); lsIndex.sort(); nKeys=lsIndex.length; $wb.laLocalAircraft.empty(); $wb.laLocalMsg.show(); nTailsLocal=0; for (iKey=0; iKey' + filename + '
'); nTailsLocal++; } } setTailsLocalMsg(); if (nTailsLocal>0) $wb.laLocalMsg.hide(); } function alltolocal() { 'use strict'; for (iTail=0; iTail-1) { iosc=words[i].indexOf(';'); if (iosc>-1) { iadjust=iosc-ioamp; iwl-=iadjust; } } ibrbr=words[i].indexOf('

'); if (ibrbr>-1) { inline=words[i].length-ibrbr-8; sout+=' '; } else { if (inline+iwl>=limit) { sout+='
'; inline=words[i].length; } else { if (i>0) { sout+=' '; inline++; } inline+=iwl; } } sout+=words[i]; } return sout; } function flushlocal() { 'use strict'; $.jStorage.flush(); flushlocalaircraft(); flushlocalloads(); } function flushlocalaircraft() { 'use strict'; // $.jStorage.flush(); nTailsLocal=0; $wb.laLocalAircraft.empty(); $wb.laLocalMsg.show(); } function flushlocalloads() { 'use strict'; // $.jStorage.flush(); nLoadsLocal=0; $wb.llLocalLoads.empty(); $wb.llLocalMsg.show(); } const setLoadsLocalMsg=()=>$wb.llLocalMsg.html('' + fitLength('NO LOCAL LOADS - There are currently no loads in this browser's LOCAL storage.

From an aircraft page, you can use “F9 Save Load to LOCAL” to put a load in LOCAL storage and it will show here when you next bring up this page. This happens independently of whether there is Internet access or not.

If you use the "F10 Send Load to SERVER", a backup copy of the load sent will also appear here the next time you bring up this page.',57) + '
'); const setTailsLocalMsg=()=>$wb.laLocalMsg.html('' + fitLength('NO LOCAL AIRCRAFT - There are currently no aircraft in this browser's LOCAL storage. When you select an aircraft from the SERVER, it will automatically be put in LOCAL storage for use when there is no Internet access.',55) + '
'); function setsource(sFile,sFrom,sPos,sTail,sType) { 'use strict'; var sLoc; oSource.filename=sFile; oSource.from=sFrom; oSource.posfile=sPos; oSource.tailnum=sTail; oSource.tmSeconds=0, oSource.type=sType; for (iTail=0; iTail