homepage Welcome to WebmasterWorld Guest from 23.22.173.58
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
URL Decoding
Revata

5+ Year Member



 
Msg#: 4023478 posted 12:35 am on Nov 12, 2009 (gmt 0)

My Javascript isn't very strong, but I've got an event listener that will show a filename when a media file is selected. The script looks like this:


function itemMonitor(obj)
{
gid('nowplaying').innerHTML = '<span class="style1">Now Playing: ' + player.getPlaylist()[obj.index].file.split('/')[1].split('.')[0] + '</span>';
};

...because some of the files have urlencoded filenames I want them to appear without the %27's and such, so I tried this:


function itemMonitor(obj)
{
gid('nowplaying').innerHTML = '<span class="style1">Now Playing: ' + player.getPlaylist()[obj.index]._utf8_decode(unescape(file)).split('/')[1].split('.')[0] + '</span>';
};

But since it's expecting a string in the unescape argument it doesnt work. Is there any way I can change the command so that it'll urldecode the filename rather than the word "file" in this case?

 

Fotiman

WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4023478 posted 2:06 pm on Nov 13, 2009 (gmt 0)

player.getPlaylist()[obj.index]._utf8_decode(unescape(file.split('/')[1].split('.')[0])) + '</span>';

Does that work?

Revata

5+ Year Member



 
Msg#: 4023478 posted 6:14 pm on Nov 19, 2009 (gmt 0)

Hm, that didn't work. In fact, entering "_utf8_decode(unescape())" in the command breaks the entire innerHTML. It doesnt even display "Now Playing: ".

I wonder is there any other way to decode other than with: _utf8_decode ?

Fotiman

WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4023478 posted 7:09 pm on Nov 19, 2009 (gmt 0)

How about this?


function itemMonitor(obj) {
var str = '<span class="style1">Now Playing: ',
filename = player.getPlaylist()[obj.index].file.split('/')[1].split('.')[0];
filename = unescape(filename);
str += filename + '</span>';
gid('nowplaying').innerHTML = str;
}

Revata

5+ Year Member



 
Msg#: 4023478 posted 8:09 pm on Nov 19, 2009 (gmt 0)

Success! That works, thanks for the help Fotiman. =)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved