What's new

Coming change - removal of legacy Tomato JS code

RMerlin

Asuswrt-Merlin dev
Staff member
Hi developers,

With 3006.102.6 (and probably 3004.388.11), I will be removing the legacy Javascript files that Asus were reusing from Tomato. That means tmmenu.js, tmcal.js and so on will no longer be present in the firmware.

If you are reusing any function from these, you will need to update your scripts. E() for instance can be replaced with a document.getElementById() call. The comma() function can be replaced with the toLocaleString() method. Here's an example from a function that I wrote for the new Traffic Monitor pages, to format traffic numbers:

Code:
        /* Output formatting logic:  0 returns 0, above that but below 10 returns X.XX, the rest returns X.  Adds more granularity to small numbers */
        if (value < 10 && value !== 0) {
                formattedValue = value.toLocaleString(ui_locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
        } else {
                formattedValue = value.toLocaleString(ui_locale, { maximumFractionDigits: 0 });
        }

Replace "ui_locale" with "en-US" to reproduce the same formatting comma() was doing (comma separator for thousands, and period for fraction digits).

You can probably also use something from the Intl.NumberFormat object type to the same effect.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top