zRSSFeed ajustando la salida JS

I'm using zRSSFeed to display a feed with images and it works great, only I'm having some trouble amending the order of the HTML that is output. I want the image to come first. The HTML output is:

<h4>
    <a title="View this feed at" href="http://someurl.com/image.jpg" target="_self">This is an image</a>
</h4>
<div class="date">04/16/2013 01:49:15</div>
<p class="image">
    <img src="http://someurl.com/image.jpg">
</p>

I located the JavaScript which is outputting this and have tried playing around with the order, but things break quite easily.

e.linkredirect && (k = encodeURIComponent(k));
j[d].html = '<' + e.titletag + '><a href="' + e.linkredirect + k + '" title="View this feed at ' + b.title + '">' + g.title + '</a></' + e.titletag + '>';
e.date && a && (j[d].html += '<div class="date">' + a + '</div>');
e.content && (g = e.snippet && '' != g.contentSnippet ? g.contentSnippet : g.content, e.linkcontent && (g = '<a href="' + e.linkredirect + k + '" title="View this feed at ' + b.title + '">' + g + '</a>'), j[d].html += '<p class="image">' + g + '</p>');

I could effectively put the image at the beginning of the j[d].html in it's first instance and use the e.linkredirect to get the src, however if I reuse this as a feed without images, this will not work properly. The image is added in the paragraph with the class "image". Any suggestions on how I work this?

preguntado el 25 de abril de 13 a las 06:04

For starts can you split the output JS up? So run if statements round the vars to see if they exist before += them to j[d].html? -

I can, but the problem is some of the naming conventions make it really difficult to know what is what, especially line 4 of the above script. -

At every point where mark up is added, split it there. -

Fixed it. Was incredibly simple in the end! Line 4 I changed the end of the statement from j[d].html += '<p class="image">' + g + '</p>' to j[d].html = '<p class="image">' + g + '</p>' + j[d].html. -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.