I need help with this code:
I have a plain text in a URL and I need to convert it to a list (ul) to show in a page. The format of the list is:
* IMAGEURL
** text
* IMAGEURL2
** text2
...
and I need to convert it to:
<ul id="listaEmoticones">
<li><img src="IMAGEURL" /> <span>text</span></li>
<li><img src="IMAGEURL2" /> <span>text2</span></li>
...
</ul>
I have this code but I don't know how to continue:
$(function() {
var $chat = $('#Chat_15028');
$lista = $('').attr('id', 'listaEmoticones')
$chat.prepend($lista);
$.ajax({
'dataType': 'text',
'data': {
'title': 'MediaWiki:Emoticons',
'action': 'raw',
'ctype': 'text/css'
},
'url': wgScript,
'success': function(data) {
var lines = data.split("\n");
for (var i in lines) {
var val = (lines[i].indexOf('** ') == 0) ? lines[i].substring(3) : '';
var $opt = $('').text(lines[i]);
$lista.append($opt);
}
}
});
})
Thanks
EDIT: Thanks for the correction, I speak Spanish