How to run an ajax.js
Hello,
I'm working on a plugin that will use "web client puzzles" to thwart numerous automated attacks on a web server. The application is called "kaPow" and it can work in conjunction with other Turing tests. I have already modified the BotStop plugin to get a skeleton for the kaPow plugins. But, here is my problem, I don't know much about ajax and the example application provided by the kaPow folks uses this to trigger the client's computational work.
The application puts this at the top of the php file
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> <script src=``"ajax.js" type="text/javascript" ></script>
in order to use jquery,
and then later has this tag in the body
<form id="commentform" method="POST" name="commentform" action="index2.php" enctype="multipart/form-data" onsubmit="Validate(); return false;">
So, when the submit button is pressed the Validate() function is called that resides in a file called ajax.js in the local directory. Unfortunately, I can't figure out how to get similar behavior using vanilla's forms. I've determined that the Validate() function should run when the "Submit" button is pressed on the registration form. This seems to be mostly controlled by the plugin file 'views/registerbasic.php". I've put echo statements throughout this file and my new config.Kapow.plugin.php file in order to observe the program flow, and I believe I've narrowed what I need to do.
Can someone tell me if there is a way to add an event that is triggered when the registration form has its submit button pressed? I can't seem to figure out how I can use jquery within the Vanilla framework to call this code. I'm confused on how I would hook on to the event of the specific "Submit" button being pressed on the registration form? It seems like I want to do something like the below:
<!DOCTYPE html> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $.getScript("demo_ajax_script.js"); }); }); </script> </head> <body> <button>Use Ajax to get and then run a JavaScript</button> </body> </html>
But, I can't figure out how this code needs to be modified for use with the registration form.
Any help is appreciated!
Comments
@gomer , the button to target I believe is the
jQuery(document).ready(function($){$('.ApplyButton').click(function(){
$.getScript("demo_ajax_script.js");
});
you would put this in the master.default.php of your theme in the head or after foot section
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
I am using the BotStop plugin files as a template. I don't see any files related to theme. Can I assume that the config.blah.plugin.php file is the theme file? There is also a registerbasic.php file in a views folder in that file set. I have been modifying both of these files in order to get my plugin to work.
I'll try targeting that button in both places and check back.
Thanks!
no you can't because it is not called default.master.php which is in the views folder of your theme.
I don't know what theme you use but it should be either php or tpl file in the views folder.
that is where you put the query document ready function . Or make a plugin that does that.
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
My Vanilla is a fresh install. So, I have not added any themes. I only added the BotStop plugin and modified it. I looked in the folder vanilla\themes\ and found folders; default, EmbedFriendly, and mobile. I looked in the default folder and found only an about.php file. Should, I install a basic theme to make my life easier? If this is the best way to get the default.master.php file in order to modify it, I can do that. Recommend any simple themes?
Thanks!
Just download something you like , several ones you can pick from. The easiest to modify are the ones that use a php instead of tpl .
Because it resembles a normal html index page. It is easy to learn with.
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
You mean as in not very decorated simple or simple code?
If you mean simple code, it is all the same it is only hard until you get used to working with it. Basic css.
If you mean simple in design as far as looks , minimalistic , you won't like my themes, they are not for everyone just those who like more design features. But all themes work relatively the same . it s a matter of taste. The most important is the layout coz the colors you can easily change. I do recommend getting a recent theme because it is likely still being supported by the author. Some are years old and some have problems better off making your own...
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
alternative to modifying default.master.tpl or default.master.php
http://vanillaforums.org/discussion/comment/176376/#Comment_176376
or read the wiki on how to create simple plugin that adds a js file.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.