wikipedia api - How to add 'http:' to img src to get correct image url in javascript -


i have javascript widget fetches articles wikipedia through mediawiki api (http://en.wikipedia.org/w/index.php?title=main_page&action=render). it's app samsung smart tvs. text part works fine, won't display images because img src structured this:

"//en.wikipedia.org/wiki/file:example.jpg"

and i've come realize using pc emulator samsung firmware converts type of full url:

"file://localhost/en.wikipedia.org/wiki/file:example.jpg"

is possible add "http:" src app points correct links hence displaying both thumbnails , full-size images?

here's relevant part of js code:

uicontents.showimage = function(srcurlfromwikipage, showhigherresolution) { //    alert("uicontents.filldescription()");       var cuturl = srcurlfromwikipage;      //document.getelementbyid('uicontentsimgframeiframe').href = srcurl;     //window.frames.uicontentsimgframeiframe.location.href = srcurl + "#file";      //prepare link full-size picture:     //cuturl = cuturl.replace('thumb/','');     //cuturl = cuturl.substring(0, cuturl.lastindexof('/'));      //show preview thumb version     //if (cuturl.match(/\.svg$/)) cuturl = srcurlfromwikipage;     alert('img src: ' + cuturl);     //show preview thumb version     var elemimg = document.getelementbyid('uicontentsimgframeimage');      document.getelementbyid('uicontentsimgframe').style.display = 'block';     //set image source     if (showhigherresolution == true) elemimg.onload = 'uicontents.resizeimage()';     elemimg.alt = 'loading...';     elemimg.src = cuturl;      elemimg.style.visibility = 'hidden';     elemimg.style.visibility = 'visible';      imageviewisopened = true;      document.getelementbyid('uisearchfield').style.visibility = 'hidden';     document.getelementbyid('uisearchtextinput').style.visibility = 'hidden'; 

any suggestions? in advance.

var cuturl = srcurlfromwikipage.replace("file://localhost/","http://"); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -