Luke 18 Posted June 26, 2010 Report Share Posted June 26, 2010 I've just read about a function that I'd like to include in a bot, that strips HTML links out of blocks of text... StripHTML() is the function, but I can't figure out how to use it in a bot. Go easy on my guys, I'm no Javascript programmer yet... Can someone tell me how to use it in a bot so that it takes the block of text (with some HTML in it, including the unwanted links) and spits out a variable that I can immediately put into a text field on the page? (The text block is coming from a list, this is all done per Loop iteration.) Failing that, does anyone know how to remove all html links from a block of text using uBot at all? Thanks in advance,Luke Quote Link to post Share on other sites
The_Brit 13 Posted June 27, 2010 Report Share Posted June 27, 2010 I've just read about a function that I'd like to include in a bot, that strips HTML links out of blocks of text... StripHTML() is the function, but I can't figure out how to use it in a bot. Go easy on my guys, I'm no Javascript programmer yet... Can someone tell me how to use it in a bot so that it takes the block of text (with some HTML in it, including the unwanted links) and spits out a variable that I can immediately put into a text field on the page? (The text block is coming from a list, this is all done per Loop iteration.) Failing that, does anyone know how to remove all html links from a block of text using uBot at all? Thanks in advance,Luke Paste the code of the function into a JS node and then after the code put the function call eg Function StripHTML { Code here} StripHTML(); If you want the resulting text you need to put the Javascript inside an eval node to capture it Quote Link to post Share on other sites
Luke 18 Posted June 27, 2010 Author Report Share Posted June 27, 2010 Paste the code of the function into a JS node and then after the code put the function call eg Function StripHTML { Code here} StripHTML(); If you want the resulting text you need to put the Javascript inside an eval node to capture it So first I need to find a "code of the function" -Not just the command StripHTML();, but a block of code someone has written specifically to remove the hyperlinks from a block of text? Assuming that's true, I wonder if part of this code does the deed: http://www.hscripts.com/scripts/JavaScript/remove-html-tag.php It's the closest I've been able to find. Thanks,Luke Quote Link to post Share on other sites
The_Brit 13 Posted June 27, 2010 Report Share Posted June 27, 2010 So first I need to find a "code of the function" -Not just the command StripHTML();, but a block of code someone has written specifically to remove the hyperlinks from a block of text? Assuming that's true, I wonder if part of this code does the deed: http://www.hscripts....ve-html-tag.php It's the closest I've been able to find. Thanks,Luke I haven't tested this I just threw it together as an example:- stripHTML.ubot dataItem1 and dataItem2 in the function call correspond to the names of the form elements you want any HTML tags to be removed from. You can do more than 2, just separate them with commas. Quote Link to post Share on other sites
Luke 18 Posted June 27, 2010 Author Report Share Posted June 27, 2010 dataItem1 and dataItem2 in the function call correspond to the names of the form elements you want any HTML tags to be removed from. You can do more than 2, just separate them with commas. Hmmm... I'm trying to test this now but I can't figure out which form elements you are talking about. There is no form in the html block itself, and no data comes from a form at all... Perhaps it would help to explain my exact usage here: I have a list where each line item on it is an entire Html page with lots of markup in it. I do not want to replace all html tags, it's good to have the formatting, but the actual <a> tags with other people's links in them just have to go! So a loop is running at this point, and it uses a $next list item to pull the entire posts' worth of content out. Now I can see that I'll be setting the variable #newText with your functionality there as the output that goes into the wordpress post box, but I don't see how any of this calls the input, nor what exactly the dataItems are. Thanks again,Luke Quote Link to post Share on other sites
The_Brit 13 Posted June 27, 2010 Report Share Posted June 27, 2010 Hmmm... I'm trying to test this now but I can't figure out which form elements you are talking about. There is no form in the html block itself, and no data comes from a form at all... Perhaps it would help to explain my exact usage here: I have a list where each line item on it is an entire Html page with lots of markup in it. I do not want to replace all html tags, it's good to have the formatting, but the actual <a> tags with other people's links in them just have to go! http://ubotstudio.com/forum/public/style_emoticons/default/wink.gif So a loop is running at this point, and it uses a $next list item to pull the entire posts' worth of content out. Now I can see that I'll be setting the variable #newText with your functionality there as the output that goes into the wordpress post box, but I don't see how any of this calls the input, nor what exactly the dataItems are. Thanks again,Luke The original use of this function was to pass in HTML form elements but it will still work as long as what you are passing in is enclosed in HTML tags. If you look at the var re line you may recognize the structure of an HTML tag, so technically, any string you send in that is enclosed in HTML tags should result in having them stripped out. Dave Quote Link to post Share on other sites
Luke 18 Posted June 27, 2010 Author Report Share Posted June 27, 2010 So I guess I just need one dataItem at the bottom, which is the #variable holding my original block of html code, right? Assuming so, how do I edit the $eval? I can't grab your code to edit in the first place... Very limited by uBot's interface on that one... Quote Link to post Share on other sites
The_Brit 13 Posted June 27, 2010 Report Share Posted June 27, 2010 So I guess I just need one dataItem at the bottom, which is the #variable holding my original block of html code, right? Assuming so, how do I edit the $eval? I can't grab your code to edit in the first place... Very limited by uBot's interface on that one... That's correct. What I do is create the JavaScript in a regular JS node and then copy and paste it into the eval node. To create the eval node, start with a Set node but just click OK. Then right-click on it and add the eval from the math option but then just click OK to get back to the script. Now you can paste the JS into the eval node. Dave Quote Link to post Share on other sites
Luke 18 Posted June 27, 2010 Author Report Share Posted June 27, 2010 What I do is create the JavaScript in a regular JS node and then copy and paste it into the eval node. ... Now you can paste the JS into the eval node. Hmm... But I can't get to the eval node's JS code to grab... It's untouchable. I'd write it over from scratch, but there are some friggy-weird characters in there! Can you post that in here somehow so I can copy it? Quote Link to post Share on other sites
The_Brit 13 Posted June 27, 2010 Report Share Posted June 27, 2010 Hmm... But I can't get to the eval node's JS code to grab... It's untouchable. I'd write it over from scratch, but there are some friggy-weird characters in there! http://ubotstudio.com/forum/public/style_emoticons/default/blink.gif Can you post that in here somehow so I can copy it? Here you go. FYI, the JS node was created by adding a blank node, clicking on the JS code in the eval node, CTRL-C, click on the JS node, CTRL-V stripHTML.ubot Quote Link to post Share on other sites
Luke 18 Posted June 27, 2010 Author Report Share Posted June 27, 2010 Here you go. FYI, the JS node was created by adding a blank node, clicking on the JS code in the eval node, CTRL-C, click on the JS node, CTRL-V Awesome. I'm in it now. I'll plug it in and let you know after dinner how it went. Thanks again, It is appreciated.-Luke Quote Link to post Share on other sites
Luke 18 Posted June 27, 2010 Author Report Share Posted June 27, 2010 Sadly it appears that it's not working. Here is a pic of exactly what I'm doing: It is not posting anything into the field at all, and i even saved the #LinklessHTML variable to a file and it came up empty. Did I overlook anything? Call the variable in the JS wrong perhaps? Thanks,Luke Quote Link to post Share on other sites
The_Brit 13 Posted June 28, 2010 Report Share Posted June 28, 2010 Sadly it appears that it's not working. Here is a pic of exactly what I'm doing: It is not posting anything into the field at all, and i even saved the #LinklessHTML variable to a file and it came up empty. Did I overlook anything? Call the variable in the JS wrong perhaps? Thanks,Luke Try this one instead which works when you only need to strip from one piece of HTML at a time. The content on the var str line is what you would replace with the variable containing your HTML. What I did to test it was to set str equal to the entire HTML source. Dave stripHTML.ubot Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.