Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Topic:
Question on script
This thread has 7 replies. Displaying all posts.
Post 1 made on Wednesday June 9, 2021 at 01:26
mpg7321
Regular Member
Joined:
Posts:
June 2020
69
Can any one help, first line works, second line does not, any ideas on why?

var timeR = hoursR + ':' + minutesR + ':' + secondsR;


var timeR = hoursR.toString().padStart(2, '0') + ':' + minutesR.toString().padStart(2, '0') + ':' + secondsR.toString().padStart(2, '0');
Post 2 made on Wednesday June 9, 2021 at 12:47
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,729
LOL.

The Javascript engine you are running in the Pronto is circa 2008 (EcmaScript 5 - ES5) which is way before padStart was added to String.

You must resort to the old way or adding what is known as a mixin
or polyfills.

Old way:

var toPad = 1;
var padded = ("00" + toPad).substring(0,2);


A quick google (string padstart polyfill) finds this link which has exactly what you need. [Link: vanillajstoolkit.com]

If you look at this code, however, it's also looking for a 'repeat' function on String which also is not part of ES5.

Here's a link for that:

[Link: vanillajstoolkit.com]

Last edited by Lyndel McGee on June 9, 2021 12:56.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 3 made on Wednesday June 9, 2021 at 21:47
mpg7321
Regular Member
Joined:
Posts:
June 2020
69
Another question, I read up on Word-wrapping and do not follow the examples you have. I am still learning JavaScript and can't wrap my head on how to do this,
If I have a long string in a var Plot and want to write it to a single panel, lets call it KodiOverLay3, can this be done all in one panel? if so how?

Again thanks,
Post 4 made on Thursday June 10, 2021 at 00:19
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,729
Word wrapping is a complex topic. Typically, you wrap on word breaks (spaces) or max characters per line.

Here are some sample mixins that I use.
wordWrap, wordWrappIntoArray, trim, ltrim, rtrim.

The original wordWrap code came from the Philips RSS module back in 2008. I don't think I enhanced it at all. I did put in documentation as comments below.

All these use regular expressions where /\S*$/ matches on characters. I leave it to you to google and go to a regular expression site to determine what they do.


//********************************************************************************
// JavaScript String Extensions
//********************************************************************************
// String extensions for wordwrap + trimming
//String.wordWrap(maxLength: Integer, [breakWith: String = "\n"], [cutWords: Boolean = false]): String
//Returns an string with the extra characters/words "broken".
//maxLengthmaximum amount of characters per line
//breakWithstring that will be added whenever it's needed to break the line
//cutWordsif true, the words will be cut, so the line will have exactly "maxLength" characters, otherwise the words won't be cut
//
if (!String.prototype.wordWrap) {
String.prototype.wordWrap = function wordWrap(m, b, c) {
var i, j, s, r = this.split("\n");
if (m > 0) {
for (i in r) {
for (s = r[i], r[i] = ""; s.length > m; j = c ? m : (j = s.substr(0, m).match(/\S*$/)).input.length - j[0].length || m, r[i] += s.substr(0, j) + ((s = s.substr(j)).length ? b : "")) {};
r[i] += s;
}
}
return r.join("\n");
};
}

if (!String.prototype.wordWrapIntoArray) {
String.prototype.wordWrapIntoArray = function wordWrapIntoArray(m, b, c) {
var i, j, s, r = this.split("\n");
if (m > 0) {
for (i in r) {
for (s = r[i], r[i] = ""; s.length > m; j = c ? m : (j = s.substr(0, m).match(/\S*$/)).input.length - j[0].length || m, r[i] += s.substr(0, j) + ((s = s.substr(j)).length ? b : "")) {};
r[i] += s;
}
}
return r;
};
}

if (!String.prototype.trim) String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, "");
};

if (!String.prototype.ltrim) String.prototype.ltrim = function() {
return this.replace(/^\s+/, "");
};

if (!String.prototype.rtrim) String.prototype.rtrim = function() {
return this.replace(/\s+$/, "");
};
//********************************************************************************
// JavaScript String Extensions
//********************************************************************************


If you are looking for something that is rather readable but likely does not behave in the same way, check this out.

[Link: stackoverflow.com]
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 5 made on Thursday June 10, 2021 at 01:42
mpg7321
Regular Member
Joined:
Posts:
June 2020
69
ya, I thank you I am using the link you provided, think I got it working.

Last edited by mpg7321 on June 10, 2021 01:54.
OP | Post 6 made on Thursday June 10, 2021 at 22:07
mpg7321
Regular Member
Joined:
Posts:
June 2020
69
Any experience with creating an expanding list/table?
Post 7 made on Friday June 11, 2021 at 12:38
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,729
How about opening a new thread with specific subject lines for questions about different topics which will make things better searchable in the future?

To create a list of items, you need to have multiple widgets on the screen. If the list needs to scroll up/down, you use a backing array (Model), then some code (Controller) to slide up/down, etc, and the a set of widgets (View) that the controller uses to render the data.

This is the MVC (Model-View-Controller) design pattern. I'd be happy to write some code for you on a contract basis if you want to contact me offline to discuss your needs.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 8 made on Friday June 18, 2021 at 20:15
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,729
A long time ago, I worked with Barry on a small project, a slider bar. There were lots of widgets involved.

If you go to the link below, the last item in the
Philips Pronto PRO section is this project.

[Link: the-gordons.net]

I realize that a slider is not your original ask but to scroll up/down in a list, the slider might come in handy.
Lyndel McGee
Philips Pronto Addict/Beta Tester


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse