Posts tagged BNR
How to add a nice jQuery slider
Nov 15th
This weekend fun was adding to my website the cool sliding control from Jérémie Tisseau website. That pretty it was, I immediately started thinking it as a container to my BNR exchange rate page. The coded worked perfectly, with few modifications.
Firstly, WordPress uses the $ operator for Prototype library, so if you want to add your jQuery library the invocation to WordPress Firebug will report the error “$ is not a function”. So here’s the fix: you’ll have to change any occurrence of the $ sign to jQuery. Just like in the following example:
$(document).ready(function() {
// Expand Panel
$("#open").click(function(){
$("div#panel").slideDown("slow");
});
// Collapse Panel
$("#close").click(function(){
$("div#panel").slideUp("slow");
});
// Switch buttons from "Log In | Register" to "Close Panel" on click
$("#toggle a").click(function () {
$("#toggle a").toggle();
});
});
TO:
jQuery(document).ready(function() {
// Expand Panel
jQuery("#open").click(function(){
jQuery("div#panel").slideDown("slow");
});
// Collapse Panel
jQuery("#close").click(function(){
jQuery("div#panel").slideUp("slow");
});
// Switch buttons from "Log In | Register" to "Close Panel" on click
jQuery("#toggle a").click(function () {
jQuery("#toggle a").toggle();
});
});
BNR exchange rate
Aug 12th
In this global crisis, nothing is more useful than a good chart to watch your money as investment. That’s why I created a special page which collects freely available exchange rates from BNR (National Romanian Bank) and presents them in a graphical form. This way, the viewers of my website will always be on the edge with exchange rates, as soon as BNR posts them (usually around 13:00 GMT+2).
The main challenges were:
- Building a php script to parse XML, inserting the exchange rates into database. The lack of experience and debugging tools made a huge difference in development time. But all is working now.
- Creating a php script that will daily update the exchange rates, so the users will have the fresh rates at their disposal as soon as possible.
- Design the page that hosts the chart and provide create the appropriate data structure which will feed the chart with data.
- learn to use a very interesting framework of representing data as charts – Google Visualisations
Next steps:
- Offer the posibility to choose among all 30 currencies for which the BNR provides exchange rates.
- implement AJAX for smooth behavior of refreshing the page while user chooses a different currency.
Enjoy!
cPanel: using Cron Jobs
Aug 10th
First – what is a cron job? It is a piece of software which can be run at specific times by the cron service. By example, one could set a cron job to update his application exchange rates from a server every day at a specific hour so its application will be up to date.
I used it because the Romanian National Bank doesn’t have a proper page to check for exchange rates – they present just the numbers, but no trends, no charts – nothing visual. Too bad for them! For me it is actually a good way to refresh my PHP / MySQL and apache management skills. Because this Cron stuff is actually new for me, I composed a small tutorial in order to be easy for me to remember and for you, my dear readers, to get quickly the information required for a quick start. So let’s get going with our ..