Format javascript code Webuilder 2022 vs 2025

Post your questions and problem reports here

Moderator: kfury77

Forum rules
Please try to follow these guidelines. This will help to receive faster and more accurate response.

  • Check the Support section of the corresponding product first. Chances are you will find your answer there;
  • Do not create new topics for already reported problems. Add your comments to the existing topics instead;
  • Create separate topic for each problem request. Do NOT post a number of non-related problem reports in a single topic;
  • Give your topic a meaningful title. Titles such as "A question," "Bug report" and "Help!" provide others no clue what your message is about;
  • Include the version number of the software you are using;
  • This is not an official customer support helpdesk. If you need a prompt and official response, please contact our support team directly instead. It may take a while until you receive a reply in the forum;

Format javascript code Webuilder 2022 vs 2025

Postby Guilimus » Sat Mar 09, 2024 9:27 pm

Hi - I prefer the functionality to format JS code in Webuilder 2022 - specifically the formatting options

Webuilder 2022 - after formatting (for myself nice and neat)
var weekday =["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",];

WeBuilder 2025 - after formatting (for myself - not necessary, to much white space, to many lines)
var weekday = [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
];
I cannot find an option to control this behaviour.
Guilimus
 
Posts: 4
Joined: Sun Aug 11, 2019 5:40 pm

Re: Format javascript code Webuilder 2022 vs 2025

Postby Aivars » Sun Mar 10, 2024 9:57 am

Hi - in JavaScript formatter dialog, go to Misc tab and set "Line width for wrapping" to something larger e.g. 150 - this controls when your long lines get split for readability. And in "JavaScript" tab you can set quote style to Double quotes.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2456
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: Format javascript code Webuilder 2022 vs 2025

Postby Guilimus » Sun Mar 10, 2024 5:46 pm

Hi - Thanks for the reply. I set "Line width for wrapping" to 155 then 255 + quote style to Double quotes.

The above changes did fix the problem with the example code but still changes:

/* I know - doc.write not so good - However it is exactly what I want as it deletes all HTML */
var mylinkstyle = "<style> a:link { color: black; text-decoration: none;} \
a:visited { color: black; text-decoration: none; } \
a:hover { color: grey; text-decoration: none !important;} \
</style>";

document.write(mylinkstyle,
"&nbsp;&nbsp;", dayname, "&nbsp;", day, "&nbsp;", monthname, "&nbsp;", year,
"&nbsp;", hours, ":", min, ampm, "&nbsp;",
"<a href='#'title='(Week #)'>(", weeknum, ")</a>&nbsp;",
"<a href='#'title='(Day #-Days to end / # in Year)'>(", daynum, "-",
daytoend, " / ", yeardays, ")</a>");

TO:
/* I know - doc.write not so good - However it is exactly what I want as it deletes all HTML */
var mylinkstyle =
"<style> a:link { color: black; text-decoration: none;} \
a:visited { color: black; text-decoration: none; } \
a:hover { color: grey; text-decoration: none !important;} \
</style>";

document.write(
mylinkstyle,
"&nbsp;&nbsp;",
dayname,
"&nbsp;",
day,
"&nbsp;",
monthname,
"&nbsp;",
year,
"&nbsp;",
hours,
":",
min,
ampm,
"&nbsp;",
"<a href='#'title='(Week #)'>(",
weeknum,
")</a>&nbsp;",
"<a href='#'title='(Day #-Days to end / # in Year)'>(",
daynum,
"-",
daytoend,
" / ",
yeardays,
")</a>"
);

I prefer to leave line width to 90. The above problem is only in 2025 not 2022.
Thanks Bill D.
Guilimus
 
Posts: 4
Joined: Sun Aug 11, 2019 5:40 pm

Re: Format javascript code Webuilder 2022 vs 2025

Postby Aivars » Mon Mar 11, 2024 10:01 am

Were you actively using the old formatter? We might bring it back as a legacy command, but it's really old and every time I've tried to use it, I could not find the configuration that formats well in the modern style. The philosophy behind the new formatter is to make every code look the same so that any programmer can effortlessly read code of another programmer and it's the most popular formatter now.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2456
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: Format javascript code Webuilder 2022 vs 2025

Postby Aivars » Mon Mar 11, 2024 10:04 am

One more thing - you can add this before the line that you don't want changed:
// prettier-ignore
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2456
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: Format javascript code Webuilder 2022 vs 2025

Postby Guilimus » Wed Mar 13, 2024 9:38 pm

Hi - Thanks for the reply
Yes indeed - I am still using the "old formatter"!

Your suggestion to use // prettier-ignore works, I only need 4 of these, so problem solved. Is "// prettier-ignore" etc documented anywhere?

Let me explain where I coming from. On my small laptop, the statements that are broken(on every comma) into many separate lines do not even show one complete line of code while only using about a 1.5 inch column down the left of my screen. The saving grace is - I have a very nice background.

Back in the day, and I'm going to give away my age here - I use to use Punch Cards! Your new formatter would have significantly increased the stack of cards. Also use to use a line editor on a hard copy terminal that, with some long forgotten command, would display the current line plus 3 lines above and below, quite a paper gobbler.

I hope that the above has at the least given a bit of a chuckle.

Thanks for producing an excellent editor which I enjoy using, just can't keep away from a keyboard. In my opinion editors such as yours have made a significant contribution to quality, readable and understandable code.

Anyone figure out my age, last column.

Cheers Bill D.
Guilimus
 
Posts: 4
Joined: Sun Aug 11, 2019 5:40 pm


Return to HTMLPad / Rapid CSS / Rapid PHP / WeBuilder Support

Who is online

Users browsing this forum: Google [Bot] and 46 guests