Recent Topics

1 Aug 08, 2007 21:27    

I had an idea for getting JavaScript into codes that seems pretty simple, but I don't know if it would work:

1. Write your JS code in TextPad (or whatever editor you use)
2. Search and replace out all the linebreaks (to prevent them from being auto BRed)
3. Search and replace < to {{{ and > to }}}
4. Create a renderer that replaces {{{ with < and }}} with >
5. Post the JS code inside {{{script}}} tags! b2evo thinks it's just plain text and doesn't complain.
6. When it's displayed it renders back to its original form.

Would this work at all? I have no idea how to do renderers but I'm looking at the tutorial and I could probably figure it out!

2 Aug 08, 2007 21:41

I hate to say this, but it is already done.
Look [url=http://forums.b2evolution.net/viewtopic.php?t=12228&start=0&postdays=0&postorder=asc&highlight=]here[/url] (¥åßßås official announcemnt of the plugin)
or [url=http://innervisions.org.uk/]here[/url] ( ¥åßßås website)
or [url=http://forums.b2evolution.net/viewtopic.php?t=12167&start=0&postdays=0&postorder=asc&highlight=javascript]here[/url] (the original post that refreshed ¥åßßås memory)

You can get a look at the code. That will explain some of the nice features of text replacement.

3 Aug 08, 2007 21:51

Does this plugin also allow me to use the other HTML tags that b2evo doesn't seem to like (IE form, noscript, etc...)?

4 Aug 08, 2007 22:06

You need to sneek around ../blogs/conf/_formatting.php as I tried to explain in the third link.
<noscript> works to my knowledge. For some other tags I don't know, but if you want to include a youtube or flash, you soon run into trouble. That's why there are so many plugins.

Good luck

5 Aug 08, 2007 22:13

Still just wondering, would the process in the first post work to hide HTML tags that I don't want to bother editing into formatting.php?

6 Aug 08, 2007 22:19

I think not, the question is who comes in first. If it's the _formatting.php, you loose. Your idea is excelent, but most hackers try something like [tag] ... [/tag] like the phpBB we're using in the forum. Then you can replace [tag] by <tag> in the plugin.
Or <!--tag--> or {{{tag}}}

Good luck

7 Aug 08, 2007 22:30

I don't get why the formatting.php coming in before the renderer would be a problem. Wouldn't it just see the {{{ and }}}s as plain text? Then the renderer changes it to HTML before it gets displayed.

So if I typed in:
{{{SCRIPT TYPE="Text/Javascript"}}}

JAVASCRIPT CODE HERE
{{{/SCRIPT}}}

I don't think b2evo would respond because it would see this as plain text.

Maybe I am misunderstanding the way either or both of these things work.

8 Aug 08, 2007 22:42

I read:

3. Search and replace < to {{{ and > to }}}

as a plugin action. Then you are too late and loose.
You could do this clientside by javaScript then you win.

Think about it. Your idea is correct.

Good luck

9 Aug 08, 2007 22:44

Wouldn't it be too early that's a problem? If I replaced BEFORE b2evo checks to see if there are unrecognized tags, then I'd have a problem, but if I AFTER it checked, but just before it got sent to the client then it would display properly.

EDIT - Oh I see what you mean

Step 3 is in textpad
4 is in plugin

I guess I wasn't clear

When you paste in the post it looks like {{{ }}}
but when it gets sent to the user it's HTML because the plugin converts that crap to < and >

10 Aug 08, 2007 22:52

It only checks the moment you hit the send button on your post. So in your post there are no illegal tags allowed.

For testing purposes you can disable _formatting.php. Then you can post whatever you want. It's in the beginning of the file.

Good luck

11 Aug 08, 2007 22:54

If you missed my edit look

12 Aug 09, 2007 08:56

If you're using 1.10.x then you can use (Un)FilterItemContent() to change things before the html checker gets into the game.

Take a look at the code plugin as it uses these hooks to do a similar task to what you're after so it should be a good starting point

¥

13 Aug 17, 2007 22:10

I like this AstonishMe plugin, and as an added plus it allows email subscription :)
My question is, does it let you specify <script src=...
if you use the <!--js tags?

14 Aug 17, 2007 22:24

Usually you want you js files in the header. You can use <!--script src [...] for that.
You use <!--js for specific javaScript in the body of the post. Of course that can be a js file, called by <!--js src [...].

The difference lies in the javaScript command

getElementById("%post%")


where you can make a <div> within the post:

<p id="%post%">


and the script will act upon the paragraph. In my [url=http://forums.b2evolution.net/viewtopic.php?t=12167&start=0&postdays=0&postorder=asc&highlight=javascript]previous post [/url] I have a working example that explains a lot:

<!--js
function changeColor(newColor)
{
 elem = document.getElementById("%post%");
 elem.style.color = newColor;
}
-->
<p id="%post%">Hello World</p>
<button onclick="changeColor('blue');">blue</button>
<button onclick="changeColor('red');">red</button>
<noscript><br /><br />Enable javaScript to enjoy</noscript>


Copy/paste this code in a new post in your blog. View the source of the post and see what and how it replaced certain parts.

The %post% variable will be replaced by a unique post specific tag that is equal in the code and in the script, so it's communicating.

Good luck

15 Aug 17, 2007 22:29

Thanks. I just want to embed a tool from another site.
I've converted this


<script type="text/javascript">
var refID=1073361 ;
</script><script type="text/javascript" src="http://www.xaraonline.com/zy1562cc1e/460E2B977EB54309.js"></script>


to this


<!--js
var refID=1073361 ;
-->
<!--js src="http://www.xaraonline.com/zy1562cc1e/460E2B977EB54309.js" 
-->

Should it work?

16 Aug 17, 2007 23:05

It doesn't work, the source ended up outside the tag like I thought it might when I asked:


<script type="text/javascript"> src="http://www.xaraonline.com/zy1562cc1e/460E2B977EB54309.js”


(from the generated page)

17 Aug 18, 2007 04:13

Hi Troy,

played with the code for several hours but unfortunately I didn't find a solution.
If you're the only blogger on your blog, you might consider disabling the htmlchecker in ../blogs/conf/_formatting.php. You also could consider using <iframes> but these are also blocked by the htmlchecker (you can add them as 'safe' in the file, but the structure of the _formatting.php file is puzzling to say the least).

The code from Xara is a tad too complicated to add between <!--js. For example, it starts with:

document.write('<SCRIPT"[...]


and if you understand what the plugin is trying, you can imagine a faint smile on my face.

In a few hours time ¥åßßå will hoover the forum. Perhaps he can provide a new angle on the case.

Good luck

18 Aug 18, 2007 13:49

<!--js
var refID=1073361 ;
document.write( '<' + 'script type="text/javascript" src="http://www.xaraonline.com/zy1562cc1e/460E2B977EB54309.js"><' + '/script>' );
-->

;)

¥

19 Aug 18, 2007 14:11

Tried it yesterday, got errors like /n /n. Then the Xara js file sneaks out of it's document.write and outputs bare code.
The best thing I could do is outputting <script type="text/javascript" src="http://www.xaraonline.com/zy1562cc1e/460E2B977EB54309.js"> to the screen -in the post- but unfortunately that was not (again) picked up by JavaScript.

But don't let this unfortunate attempt withhold you from trying.

20 Aug 18, 2007 14:17

You got errors using that code? Can you paste the source of what gets kicked out ( or a link to a demo post ? )

¥

21 Aug 18, 2007 14:31

¥åßßå wrote:

You got errors using that code? Can you paste the source of what gets kicked out ( or a link to a demo post ? )

¥

Parser error: not well-formed (invalid token) near document.write( '<' + 'script type="te


That's after pushing the post button.
It did only output when replacing < by &lt;

I got nasty output when copying content of js file and paste within <!--js -->

22 Aug 18, 2007 15:00

Lets have another go then ;)

<div id="%post%cheat"></div>
<!--js
var refID=1073361 ;
var foo = document.getElementById( '%post%cheat' );
var bar = document.createElement( 'script' );
bar.src = 'http://www.xaraonline.com/zy1562cc1e/460E2B977EB54309.js';
bar.type = 'text/javascript';
foo.appendChild( bar );
-->

¥

23 Aug 18, 2007 21:00

Something weird is happened. When I tried ¥åßßås code in a new post, all of a sudden my last example came to life. That is the previous post in my blog. :roll:
So, combining the two posts somehow should do the trick.
I think it's something like one post generating the <script link and the other post executing it.
This is a [url=http://www.blog.hemminga.net/wiki_stub.php]link[/url]. The layout sucks and the JavaScript ruined the header of the blog, but it's there.

This is the previous posting:

<!--js 
var refID=1073361 ;
function dhtmlLoadScript(url)
{
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsById(%post%)[0].appendChild(e);
}

onload = function()
{
   dhtmlLoadScript("http://www.xaraonline.com/zy1562cc1e/460E2B977EB54309.js");
}

-->

<p id="%post%">xx</p>


As you can see, it was an attempt after a few hours playing yesterday and I finally got to the point where I stopped. Funny enough if you see the similarities between this post and ¥åßßås, we both went took the same steps trying to solve the riddle.

Forgot to mention: the Xara thing renders correct in the backoffice, but screws up in the blog.

24 Aug 19, 2007 20:37

trying now...

-EDIT I hope I enabled JavaScript correctly in AM... What I did was enable the checkbox in the code and then check it in the backoffice. Should this work?

EDIT - Doesn't like DIV ID or P ID either :(

25 Aug 19, 2007 21:02

Troy wrote:

EDIT - Doesn't like DIV ID or P ID either :(

You should 'enable style in post' or something similar (this is from memory :-/ ) in ../blogs/config/_formatting.php to allow the id thing.

26 Aug 19, 2007 22:37

Okay, i'll do that :)

edit: It was this line:

# Set this to true to allow id && style as core attributes for posts
$posts_allow_css_tweaks = true;

27 Aug 19, 2007 22:44

None of these three are working for me. The first one gives me an error:

Cannot update, please correct these errors:
Parser error: XML_ERR_NAME_REQUIRED near s var refID=1073361

The second one does nothing, and the third one just shows the xx.

28 Aug 19, 2007 23:38

Yes and the funny thing was: I had the third code in a post showing only xx, then I made a new post with ¥åßßås code and now all of a sudden my post started to display the Xara thing, as you can see when you click the link I provided.

The conclusion is that both codes combined will show the Xara thing. I think my code provides the framework and ¥åßßås code executes mine, resulting in the Xara to display.

At this moment I do not plan to work on it. I think ¥åßßå can easily add a few lines to his code to make it possible to fumble the url in the <script> tag, but that's up to ¥åßßå himself.

Good luck

29 Sep 02, 2007 04:15

Can this work with a Haloscan code? some like:

<a href="javascript:HaloScan('01');" target="_self"><script type="text/javascript" class="am_custom_post_01_">postCount('01'); </script></a>

30 Sep 02, 2007 04:36

Try:

<a href="javascript:HaloScan('01');" target="_self"><!--js <div id=%post%>postCount('01');</div> --></a>


It spits out:

<a href="javascript:HalosScan('01');" target="_self"><script type="text/javascript"><div id="am_custom_post_01">postCount('01');</div></script></a>

31 Sep 02, 2007 06:20

Afwas wrote:

Try:

<a href="javascript:HaloScan('01');" target="_self"><!--js <div id=%post%>postCount('01');</div> --></a>


It spits out:

<a href="javascript:HalosScan('01');" target="_self"><script type="text/javascript"><div id="am_custom_post_01">postCount('01');</div></script></a>

So much thanks for your reply, but I got an error:

Found invalid URL: Invalid URL 
Parser error: > required near vascript:HaloScan('01');" target=

:( I'll hope someone can help me! :(

32 Sep 02, 2007 08:48

Try this, add this to your <head>

<script type="text/javascript">
function haloMe( thePostId )
{
	theHolder = document.getElementById( thePostId + 'halo' );
	thePostId = thePostId.substr( 15, thePostId.length - 16 );
	var theLink = document.createElement( 'a' );
	theLink.href = 'javascript:HaloScan( \'' + thePostId + '\' );';
	var theScript = document.createElement( 'script' );
	theScript.appendChild( document.createTextNode( 'postCount( \'' + thePostId + '\' ); ' ) );
	theLink.appendChild( theScript );
	theHolder.appendChild( theLink );
}
</script>

Then in your post use :

<div id="%post%halo"></div>
<!--js haloMe( '%post%' ); -->

¥

33 Sep 03, 2007 02:45

¥åßßå wrote:

Try this, add this to your <head>

<script type="text/javascript">
function haloMe( thePostId )
{
	theHolder = document.getElementById( thePostId + 'halo' );
	thePostId = thePostId.substr( 15, thePostId.length - 16 );
	var theLink = document.createElement( 'a' );
	theLink.href = 'javascript:HaloScan( \'' + thePostId + '\' );';
	var theScript = document.createElement( 'script' );
	theScript.appendChild( document.createTextNode( 'postCount( \'' + thePostId + '\' ); ' ) );
	theLink.appendChild( theScript );
	theHolder.appendChild( theLink );
}
</script>

Then in your post use :

<div id="%post%halo"></div>
<!--js haloMe( '%post%' ); -->

¥

First of all, thanks for your help. I added the first code to head and the second one to my post, but still in a error:

Tag <div> may not have attribute id 

I don't know really the reason why Haloscan don't work with b2evolution!

34 Sep 03, 2007 02:49

In B2evo 1.10 open ../blogs/conf/_formatting.php and find on line 55:

$post_allow_css_tweaks = false;


and set it to true.

This 'trick' doesn't exist in 1.9 or earlier, there you have to manually add the 'id' as allowed tag somewhere in the file. Perhaps you can borrow the file from a 1.10 download.

Good luck

35 Sep 03, 2007 07:00

Afwas wrote:

In B2evo 1.10 open ../blogs/conf/_formatting.php and find on line 55:

$post_allow_css_tweaks = false;


and set it to true.

This 'trick' doesn't exist in 1.9 or earlier, there you have to manually add the 'id' as allowed tag somewhere in the file. Perhaps you can borrow the file from a 1.10 download.

Good luck

I set it to true and apparently works. But when I post something in the blog the link to the haloscan comments don't appear :'( . So much thanks for the time you dedicated to my questions... the last one would be if exists other comment system that can work with b2evolution (not the predeterminate one)? ;)

36 Sep 03, 2007 07:39

You can leave a link to a post where it didn't show up, so ¥åßßå can have a (last) look at it. He's the wizard that often finds a simple solution to a difficult question.


Form is loading...