Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- function convert(htmlText)
- {
- // maybe they put spaces around the = . Remove them
- htmlText = htmlText.replace(/ = /gi, "=");
- // maybe they put quotes surrounding the value
- // so look for =" and ">
- htmlText = htmlText.replace(/=\"/gi, "=");
- //bbcodetext = bbcodetext.replace(/\">/gi, ">");
- // maybe they put single quote surrounding the value
- // so look for =' and '>
- htmlText = htmlText.replace(/=\'/gi, "=");
- htmlText = htmlText.replace(/<A\s*HREF/i, "<A HREF");
- htmlText = htmlText.replace(/<CODE>/gi, "[code]");
- htmlText = htmlText.replace(/<\/CODE>/gi, "[/code]");
- htmlText = do_quote(htmlText);
- htmlText = htmlText.replace(/<A HREF/i, "[url");
- htmlText = htmlText.replace(/<\/A>/i, "[/url]");
- // This replaces all remaining HTML code between < and >
- htmlText = htmlText.replace(/<[^>]*>/g, "");
- // This will convert all > into ] because we left
- // some open
- htmlText = htmlText.replace(/>/g, "]");
- htmlText = htmlText.replace(/\'>/g, "]");
- htmlText = htmlText.replace(/\">/g, "]");
- htmlText = htmlText.replace(/\']/g, "]");
- htmlText = htmlText.replace(/\"]/g, "]");
- return htmlText;
- }
- function do_quote(text)
- {
- text = text.replace(/<BLOCKQUOTE>/gi, "[quote");
- text = text.replace(/<BLOCKQUOTE /gi, "[quote");
- text = text.replace(/<\/BLOCKQUOTE>/gi, "[/quote]");
- var i = 0;
- var pos;
- var citeFound = false;
- //Firstly remove cite= and its value
- for (pos = 0; pos != -1; pos)
- {
- pos = text.indexOf("cite=", pos);
- if (pos != -1) // if cite= is found
- {
- text = text.replace("cite", "")
- pos++;
- i++;
- citeFound = true;
- } // end if <cite> is found
- else
- {
- //Add hardbracket after 'quote'
- text = text.replace("[quote","[quote]");
- }
- }
- for (pos = 0; pos != -1; pos)
- {
- pos = text.indexOf("<cite>", pos);
- if (pos != -1) // if <cite> is found
- {
- text = text.replace("[quote]","[quote");
- pos = text.indexOf("<cite>", 0);
- text = text.replace("<cite>", "")
- var quote = text.substring(pos,text.indexOf("</cite>", pos));
- text = text.replace(quote, "");
- if(!citeFound)
- {
- //Removing the anchor tags if any
- quote = quote.replace(/<A HREF=/i, "");
- quote = quote.replace(/<\/A>/i, "");
- //Removing newz.dk anoying "Kilde"
- quote = quote.replace("Kilde", "");
- quote = quote.replace("\">", "");
- text = text.replace("[quote", "[quote="+quote+"]");
- }
- pos++;
- i++;
- } // end if <cite> is found
- } // end for
- return text;
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement