rss wordwrap somewhere else

Forum about hardware/software for the Philips Pronto TSU9600 and other remotes.

Moderator: hvxl

Post Reply
User avatar
Snelvuur
Forum Moderator
Forum Moderator
Posts: 3156
Joined: Fri Apr 06, 2007 11:01 pm
Location: Netherlands
Contact:

rss wordwrap somewhere else

Post by Snelvuur »

I tried to use the wordwrap function in my own pages, but whats wrong. I still get the normal "long" line instead of one wordwrapped.

Anyone has a hint? :-)

Code: Select all

var start = 0;
var result = "";
var socket = new TCPSocket(false);
var t1,t2,t3,t4,t5
var event1,event2;
var descrip1, descrip2;
var tijd1;
var d;

String.prototype.wordWrap = function(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");
};

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

socket.onConnect = function()
{
  socket.write("GET /cgi-bin/channelinfo HTTP/1.1\r\n");
  socket.write("Accept: */*\r\n");
  socket.write("Host: 192.168.1.99\r\n");
  socket.write("\r\n");
};

socket.onData = function()
{
  result += socket.read(5000,1000);

t1 = result.indexOf("class=\"event\">", 0)+14;
t2 = result.indexOf("/span>",t1)-1;
event1 = result.substring(t1,t2);
t4 = result.indexOf("class=\"description\">", t2)+20;
t5 = result.indexOf("/span>",t4)-1;
descrip1 = result.substring(t4,t5);
// CF.widget("storyline").label=descrip1;

var newtext = descrip1.wordWrap(30, "\n", false).trim().split("\n");

CF.widget("storyline").label=newtext;

};


socket.onClose = function()
{
};


socket.onIOError = function(e)
{
};


if(socket.connected == false)
{
  socket.connect('192.168.1.99', 80, 3000);
};
// Erik (binkey.nl)
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

rss wordwrap somewhere else

Post by Digit »

Could it be spaces are still "&nbsp"?
Since you don't seem to use the StripHtml().
Your descrip1 could look like 1 big word to the wordwrap function and will not be split.
User avatar
Snelvuur
Forum Moderator
Forum Moderator
Posts: 3156
Joined: Fri Apr 06, 2007 11:01 pm
Location: Netherlands
Contact:

rss wordwrap somewhere else

Post by Snelvuur »

Well i do know (i think you) or someone else pointed out a wordwrap too. But i cant remember where it is, remotecentral, mail, im, forum.. too much stuff these days.. trying to put it all in my head :)

// Erik (binkey.nl)
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

rss wordwrap somewhere else

Post by Digit »

This is the only other topic where wordwrap is involved:
http://www.domoticaforum.eu/topic.asp?TOPIC_ID=673.

But that's the RSS feed topic, and you're using parts of code right now, so it must have been someone else. Now you mention it, i read something about wordwrap on remotecentral, about a month ago i think.
User avatar
Snelvuur
Forum Moderator
Forum Moderator
Posts: 3156
Joined: Fri Apr 06, 2007 11:01 pm
Location: Netherlands
Contact:

rss wordwrap somewhere else

Post by Snelvuur »

Yes, but that was wordwrap for only the end of the line, not words i think.

// Erik (binkey.nl)
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

rss wordwrap somewhere else

Post by Digit »

Could be.
How about my questions? Did you have a look at that?
Did you have a very-very good look at the descrip1 variable before the call of Wordwrap?
A CR+LF at the wrong place in the string can let the Indexof-calls perform different from what you'd expect; i had that problem once; took me 2 hours to find out.
User avatar
Snelvuur
Forum Moderator
Forum Moderator
Posts: 3156
Joined: Fri Apr 06, 2007 11:01 pm
Location: Netherlands
Contact:

rss wordwrap somewhere else

Post by Snelvuur »

I used a simple wrap, that only cut the lines at a certain amount of characters. That did work with my descrip1. Dont know how else to check that.

// Erik (binkey.nl)
Post Reply

Return to “Philips Pronto (TSU9600), IRtrans and other remotes”