Created
June 2, 2011 08:11
-
-
Save trico/1004097 to your computer and use it in GitHub Desktop.
Editor intereses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('<input type="button">').attr('id', 'op').attr('value', 'Obt').appendTo('body'); | |
$('#op').live('click' , function(){ | |
var re = /%interes%&i=([a-z0-9A-Z]*)&u=(\S*)/g, | |
text = $('#news').val(), | |
matched = null; | |
while( (matched=re.exec(text)) != null ){ | |
console.log(matched[1]); | |
$('<p>').attr('id', matched[1] + '_p').appendTo('body'); | |
$('<p>').attr('id', matched[1] + '_p2').appendTo('body'); | |
$('<p>'); | |
$('<input>').attr('id', matched[1] + '_interes').attr('size', '74').val(matched[1].replace('"', '')).data('old', matched[1]).appendTo('#' + matched[1] + '_p'); | |
$('<textarea>').attr('id', matched[1]).attr('cols', '70').attr('rows', '6').val(matched[2].replace('"', '')).data('old', matched[2].replace('"', '')).appendTo('#' + matched[1] + '_p2'); | |
} | |
}); | |
$('#rem').live('click' , function(){ | |
var re = /%interes%&i=([a-z0-9A-Z]*)&u=(\S*)/g, | |
text = $('#news').val(), | |
matched = null, | |
final= text; | |
while( (matched=re.exec(text)) != null ){ | |
final = final.replace($('#' + matched[1] +'_interes').data('old'), $('#' + matched[1] +'_interes').val()); | |
final = final.replace($('#' + matched[1]).data('old'), $('#' + matched[1]).val()); | |
} | |
console.log(final); | |
$('#news').val(final); | |
}); | |
$('<input type="button">').attr('id', 'rem').attr('value', 'Rem').appendTo('body'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment