I'd like to modify WP plugin's code.
This plugin dynamically creates table, assigns color to cells of this table.
I'd like to put a JavaScript code in this plugin, so the color of cells with a certain text inside is changed.
I have the code, it should work as it has been tested before.
I just don't know where to put this code to make it work. I tried to put it in the PHP file which creates the table but code in this file is not ended with "?>" which I suppose means that somewhere else is the rest of the code which is being added in the proces of creating the table.
It's possible that the table is being loaded via AJAX.
I have access to all the files so I can provide if necessary.
Would anyone be so kind and helped me locate suitable place for my code?
To add more javascript functionality to the third party plugin you should add your additional javascript code with wordpress' own function wp_enqueue_script. Somewhere in the third party plugin code the plugin is initialized. There you can add your file with the additional javascript code.
Related
How do I call other JavaScript in Spotfire.
For example, JS written on Page 1 has to be called in Page 10.
Earlier I used to write the same function on both pages, I know how to call/reuse python script which written already, and in a similar manner, I would like to re-use JS Function.
Is your JS on page 1 in a text area? If so, you can create a reusable script, just like IPython in Spotfire. To do this, edit the HTML where you want JS (you need to have a text area somewhere), then select insert JavaScript. You can create a new script here that can be called across the entire document.
I need to dynamically append css elements to a css file using values selected from a db.
Is there a way to do this using javascript or some other library.
I've looked on atmospherejs.com but didn't see anything that looked like it could do it.
I'm currently doing this using php/mysql but if I can use meteor and js that would be better.
Any ideas?
Take a look at this article: http://davidwalsh.name/add-rules-stylesheets
the file will need to get built on every page load, however. The problem with adding styles via script is that they get parsed REALLY late in the page build process, it will be a way better user experience for you to build a custom.php (or something) file and give that to every page - which it sounds like you're doing already.
That will ensure it processes the styles before the scripts, avoiding a momentary style 'flash' where your script finishes executing and adds the new rules.
I need to be able to extract, manipulate and update the text in wordpress's tinymce #content textbox.The code is coded in a wordpress plugin.
The below post helps but i am unable to comment or contact the original creator to ask him further questions. Having 1 points I cant practically do anything except ask questions. Let me know if i am doing this wrong.
Basically the code from this link is what i need to manipulate or edit the content in wordpress tinymce editor.
Manipulating TinyMCE content with jQuery
But the code seems to be overly simplified.
so my question is:
Do i need to include jquery
Do i need to include the tinymce js or class? is it in wordpress itself?
The code seems to be half javascript half php? Is the code suppose to be coded in a .js file?
do i need to put php tags here?
// make it into a jQuery object
var $content = $(content);
// manipulate the jquery object using jquery
$content = $content.remove('a');
Thanks.
hi I have figured it out after a bit more researching.
At first I was working with php to manipulate data after it is saved. But then i went on to wanting to manipulate the text before it was saved like underlining certain text based on a list in the database. So I needed to move on to javascript because i was editing the text before it was submitted or a page reload which i didn't wrap my head around yet.
So next i just coded the changes into javascript and built a button to call the process.
and seems i didn't need to include the tinymce class because probably the header of the editor page has already included it.
I would like to add the Google Remarketing JavaScript code to my site. According to Google's documentation, I need to add the code right before the tag in my HTML document. I can easily do this in the template which would add the code to all of my pages. But what if I only want to add the JavaScript code to a single page? What is the best method to go about doing this?
I tried assigning a new module position right before the tag and inserting the code using a custom HTML module. Only problem is, it wrapped the code in a meaning the remarketing code wasn't truly inserted right above the tag.
You could use a module which allows to run custom code in it. There are several solutions to this in the JED: http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/custom-code-in-modules
You could go about this by using JFactory::addScriptDeclaration();. More info can be found about this via the following link:
http://docs.joomla.org/JDocument/addScriptDeclaration
Or, you could try using Google Tag Manager which is a Plugin for Joomla 2.5 and 3.x
What I Want: Very simply I have a C program that generates a variable periodically, I want to be able to display this value on a website.
Restrictions: The webpage is HTML, php does not work, javascript does [I have tried a few javascript solutions but they have all been long, tedious and in the end ineffective] I want it to be able to format the text so that it matches the rest of the webpage. Above all I'd really like to find something simple that works.
Freedoms: I can output the variable from my C program to just about any file type and content that I want, the file is hosted so is available locally to the server or online for the client.
Preferred Solutions: I am currently playing around with the object and iframe tags native to html. They give a nice simple input:
<object height=20 width=75 type='text/plain' border=0 data="URL/filename.txt"></object>
inserts the contents of my file, but it can't be formatted so I am stuck with 12pt Courier font which is not acceptable. Using
<iframe seamless height=20 width=75 scrolling='no' src="URL/filename.htm"></iframe>
and adding my desired font/colour/size etc to the htm file gets me the right text style, but htm has a large amount of white padding around it which I can't seem to get rid of so I have to make my iframe quite large for the text to be displayed, but then it doesn't fit smoothly with other text.
So anyone that can answer one of four questions:
How to remove excess padding from htm
How to format the style of a html object
Is there anything in Java as simple as the php [so apparently it doesn't show php code even when you quote it as code. But basically using echo and get_file_contents to insert the contents of a txt file into a html page]
Propose an alternate solution
Padding and style can be handled by css.
By java I assume you mean javascript - google-ing will help you. Without details of what your server is running and what is dispatching your pages we can't give you an exact answer. You might want something with ajax to keep it updating in the background.
Try googling your question, you'd be surprised how often this helps.
I'm not sure what you're trying to do once you get the variable into your web page, but I think something like the following could be useful.
Create a hidden div on your page
Have your C application write the variable to some file
Use jquery to execute an ajax call to pull that value into the div ( or whatever other container you want to use
using some type of timer, execute the ajax call every X period of time, which will then get your up to date variable
on your main page, have another timer that will then come in to that container, grab your value and then you are free to do what you want with it.
This is all off the top of my head without knowing much about what you're trying to accomplish. If you provide some further details we may be able to help you a little more.
You need AJAX... that's just a fancy buzz-word. It means you can tell JavaScript can get a file from the server without reloading the page and you can insert data from that file into your HTML.
AJAX is made much simpler by using a JavaScript library like jQuery, but it can be done without jQuery. There's a pretty decent Getting Started tutorial at Mozilla Developer Network if you want to do it the hard way, but I really recommend jQuery.
As far as formatting... any formatting... you need to use CSS. Just about everything about the appearance of anything on a web page is controlled by CSS. MDN has a Learn CSS section, too.
load jquery on you main html file
put a div with some id (example id="newvalue")
make you c program to write the output in a file (for example value.html)
on main html page header, after jquery include code add some javascript like
$( document ).ready(function() {
$("#newvalue").load('yoursiteurl/value.html');
});