Customization

30 views
Skip to first unread message

Al

unread,
Oct 9, 2018, 7:33:40 PM10/9/18
to SwitchList
I cannot seem to get my customized waybill style to show in the SwitchList dropdown for styles. I've read your instructions, and I do know some HTML, but can't get it to work.
Please help.

Thanks,
Al

P.S. I love this app. Thank you so much developing it. I would be willing to pay $10-$15 for a more (easier?) customizable version.

Robert Bowdidge

unread,
Oct 10, 2018, 1:05:31 AM10/10/18
to switc...@googlegroups.com
Hi, Al,

If you send me a copy of your waybill style at rwbow...@gmail.com, I'll check it out and see what's up. (Alternatively, want to put it somewhere you can share? You could ask the folks on the mailing list for comments and feedback on the style.)

Robert
> --
> You received this message because you are subscribed to the Google Groups "SwitchList" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to switchlist+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Robert Bowdidge

unread,
Oct 18, 2018, 2:20:27 AM10/18/18
to Al Merkrebs, switc...@googlegroups.com
Hi, Al,

Sorry for the slow response - the day job is way too busy.

Short answer: there's a bug - well, an unneeded character - in the Waybill template, and that's breaking the web page that is the Waybill template. It's an inappropriate back quote (`) on line 243 of switchlist.html, in the ChooseRoute file:

if (newRoute == undefined) {
` newRoute = "" // <<——— the backquote at the beginning of this line shouldn't be there!
}

Deleting that backquote will fix the problem. I'll fix in the next version of SwitchList, but you can delete the character in your copy of the switchlist, or change the official copy hidden in SwitchList.app.

Here's a longer answer about how the Waybill template works, and how I diagnosed the problem - diagnosing this problem is the same way you'd diagnose any problems in your customizations to the Waybill style.

For most switchlist styles, filling out the web page describing the switchlist is easy. If I'm printing a table of cars and destinations, I just ask for the car's initials and numbers for the first cell in a row, the car's destination city for the second cell, the destination industry for the third, etc. SwitchList knows about all those attributes for a car, so filling it in is nice and straightforward:

"Please move the freight car {{car.initials}} {{car.number}} to {{car.nextStop.name}}."

The waybill template knows the car that's being drawn on this line, knows that the car has initials, numbers, and a next stop, and fills in the text easily.

For the waybill style, the route is something that the rest of SwitchList knows nothing about; we're guessing the route completely in the web page which is the SwitchList template. A little bit of a JavaScript program figures out a route and puts it in the waybill, just like your favorite news site puts an ad at the top of the article. We use JavaScript code in the Waybill template to look at a few details of the car, make a guess about a plausible route string, and paste that string into place. Specifically, the JavaScript looks for any HTML <span> with class "routeLoaded" or "routeEmpty", gets some information on the car, and then fills in that span with a nice string representing how a full car or empty car would have been routed.

So here's the "clever" part. The web page which is drawing the waybill gets the hint from the *exact same place* it's going to write the human-readable route; as long as it can read the hint and replace it with the human readable page before the page is displayed, you'll only see the realistic route and won't know about our clever trick about where the hint was stored. The SwitchList template places five "hints" about the car in the space where the route should be; the JavaScript reads that hint, figures out a good route, then replaces that hint with the human-readable string. The five hints are comma-separated: is the car loaded, does it have a cargo, is the source online, is the destination online, the owning railroad, the source, and the destination. That's the "1,1,0,1,SP,West Coast, Auto Parts Whse" that you wanted to change - it's the hints saying "the car is loaded, has a cargo, came from an offline source, and is an SP car". The code in the ChooseRoute() function takes that set of hints, splits the set of hints up at the commas, and makes a guess about the route based on the hints. I don't think this was a great way for me to add the hints - it would have been nice to set things up so that if the web page broke, the hints didn't appear as routes. However, it's how the Waybill works right now.

The fact that you're seeing the 1,1,1… implies that the Waybill template is broken - the hints aren't getting read and replaced with the human-readable route. The easiest way to debug this is to set up SwitchList in the "web server mode" to show switchlists in a web browser, then click on the link in the "SwitchList Web Server" window to view the switchlists in the web browser on your current computer. Most web browsers (Safari, Chrome, Firefox) have features built in to debug web pages; if you're using Safari, turn on "Show Develop menu in menu bar" from the Advanced preferences so you get access to all the web debugging stuff.

In my case, I open the JavaScript console via Safari's "Show JavaScript Console" in the Develop menu, and reload the page, and I see a couple JavaScript errors: "unexpected EOF" and "Can't find variable: On Load". That means the web page is broken, which means the SwitchList template is broken; the "Can't find variable" means it can't find the function that's run when the web page loads, which explains why the routes aren't getting inserted. A bit of poking around in the official Waybill template inside SwitchList.app shows there's an unintended back quote (`) a few lines from the bottom of the Choose Route function. If I remove that backquote, then the routes look more sane. The Vasona Branch layout gives good routes for most cars (because the Waybill template by default has things set up to suggest routes for my layout.) The routes are less good for other layouts; the Chicago example gives one example (routing an SP car from "SAC-SJ", which is a very odd route to Chicago!) and leaves the others blank. Blank is much nicer than leaving those hints stuck in the waybill!

I'm guessing this is the same problem you're hitting. I'd do the following:
1) get rid of the backquote in Waybill's switchlist.html so that the route stuff actually gets filled in.
2) Start filling in routes for your layout. Go through the three dictionaries ("initialsToRailroadArray", "routingHome", and "routingHere", and add routes appropriate for your railroad.
* For routingHere, get each set of railroad initials on cars, and guess at a likely route that a car from that railroad might have come directly to your railroad.
* for routingHome, name a route to get a car from that railroad back to its home from your railroad.
* For routingFromOffline, provide a potential route that a car would take from each offline industry.
* For routingToOffline, provide a potential route a car would take to an offline industry.

You might find that you'll add a syntax error as you fill in all those tables; load the web page in Safari so you can see an error message and diagnose the cause, or comment out the table entries you added until the web page works again.

I'll fix the waybill problem in the next version of SwitchList. If you run into any problems trying to customize the Waybill template, let me know.

Robert


> On Oct 10, 2018, at 8:23 AM, Al Merkrebs <a...@sonic.net> wrote:
>
> Hi Robert,
>
> Thank you for your quick reply.
>
> I am just starting to experiment with customizing the waybill style. I didn’t like series of “1,”s appearing in the ROUTE section of the default waybills style, so I simply tried changing the “,” to “-“. See the two lines in the file: var hints = route.innerHTML.split('-'); That does not change anything in the ROUTE section. I still get the “,”s instead of the “-s”.
>
> Now for the embarrassing part. I may not be understanding the concept. I am sending you the “switchlist.html” file that I have modified by replacing the “,” to “-“. I have put my modified file in both ~/Library/Containers/com.blogspot.vasonabranch.SwitchListApp/Data/Library/Application Support/SwitchList and in ~/Library/Application Support/SwitchList. I still get the “,”s instead of the “-s”.
>
> What am I doing wrong?
>
> Thank you,
> Al
> -----------------------
Reply all
Reply to author
Forward
0 new messages