Add live time with name of countries in JQVMAPS - php

I want to add the current time to the country name in JQVMAP. Like this: Eqypt-05:30 AM
By default, when we hover the mouse over a country, it only shows the country name in world map. I also want to add the current time. Please help me.

Pleasing to consult the documentation regarding:
onRegionOver: function(event, code, region)
{
// log out the region and or code to see the ID
if (window.console) console.log( region );
},
http://jqvmap.com/
youll need to do a time conversion hash/object based on element ID or similar
var foo = { "jqvmap1_thisID";"+5","jqvmap1_anotherID":"-2" };
then do the conversion
(not writing all the pseudo code)
OR you could have script that sets the labels onload, and then updates (settimeout 5000), though this is not ideal at all.
good luck!
Bo

Related

Specification of mark-up format included in facebook open graph text

When I am performing Open Graph requests, some of the responses that I am expecting to be text are having some kind of markup included. For example, when I am requesting the Name and Description of an album, in the description I get something like \u0040[12412421421:124:The Link]. (The \u0040 is actually the # sign.)
In this case it seems that what it is saying is that the 'The Link' should be a hyperlink to a facebook page with ID 12412421421. I presume there is similar kind of markup for hashtags and external URLs.
I am trying to find some official documentation or description for this, but I can't seem to find any documentation of this (I might be looking with the wrong keywords).
Is there any online documentation that describes this? And better still is there an PHP library or function already available somewhere that converts this text into its HTML equivalent?
I am using this Facebook PHP SDK, but it doesn't seem to offer any such function. (Not sure if there is anything in the new version 4.0 one but I can't use it anyway for now because it requres PHP 5.4+ and my host currently is still on 5.3.).
It's true that the PHP SDK doesn't provide anything to deal with these links and the documentation doesn't document that either. However the API gives all the information you need in the description field itself, so here is what you could do:
$description = "Live concert with #[66961492640:274:Moonbootica] "
. "in #[106078429431815:274:London, United Kingdom]! #music #house";
function get_html_description($description) {
return
// 1. Handle tags (pages, people, etc.)
preg_replace_callback("/#\[([0-9]*):([0-9]*):(.*?)\]/", function($match) {
return ''.$match[3].'';
},
// 2. Handle hashtags
preg_replace_callback("/#(\w+)/", function($match) {
return ''.$match[0].'';
},
// 3. Handle breaklines
str_replace("\n", "<br />", $description)));
}
// Display HTML
echo get_html_description($description);
While 2. and 3. handle hashtags and breaklines, the part 1. of the code basically splits up the tag #[ID:TYPE:NAME] into 3 groups of information (id, type, name) before generating HTML links from the page IDs and names:
Live concert with Moonbootica in London, United Kingdom! #music #house
Live concert with Moonbootica in London, United Kingdom!
#music #house
FYI and even if it's not much useful, here are the meanings of the types:
an app (128),
a page (274),
a user (2048).
the # describes a tag to someone,facebook id doesnt make difference between a fanpage or a single person so you gotta deal with php only.and the # should be the only char that describes a person/page tagged
The markup is used to reference a fanpage.
Example:
"description": "Event organised by #[303925999750490:274:World Next Top Model MALTA]\nPhotography by #[445645795469650:274:Pixbymax Photography]"
The 303925999750490 is the fanpage ID. The World Next Top Model MALTA is the name of fanpage. (Don't know what the 274 means)
When you render this on your page, you can render like this:
Event organised by World Next Top Model MALTA
Photography by Pixbymax Photography

nestable tree with left and right value

Nestable tree structure handle with left and right value
I already done the functionality of add parent node, child node and delete node.
But How to save tree value after moving nodes drag and drop with the nestable.js
Lest see my output what I want to do....
i want to manage with data-left, data-right values
And my database structure is
Please help in this how to manage drag and drop functionality.
I tried to comment this, but the website tells me I need 50 Reputation in order to do so, so this may or may not answer your question, I'd have to wait until I got home when I could fiddle with something similar in database / Javascript structure.
I'm fairly familiar with left/right_id tables and such. The first place I saw them was in phpBB3.0 and I spent a whole lot of time reading up on them.
One thing you could do to help you expedite your queries is to add a parent_id column, this way you can immediately get ALL the child notes without having to use "left_id > 1 AND right_id < 8" in your SQL statements.
Now, for your javascript question, how I will try to go about this when I get home is to declare an array of id keys => child values. So, in the screenshot example you've given above you could hopefully get to something like this
array(
2 => array(
5 => array(
3
),
6
),
3 => array(
8
),
4
)
In order to get this you'd have to loop through the DOM for each member of the list, using their id's and the array.push function to add values as necessary.
I'll try and help more once I can get to my house where I have a PHP server setup, but this should give you an Idea of how to get it started.
Are you using any Javascript framework (such as MooTools, jQuery)?
Edit:
So, I've worked on it for quite some time and I've got a general thing working. Below is the code directly responsible for looping through the DOM tree and assigning left/right_id values. It should be fairly easy to edit it for your liking.
I have a preference for MooTools, so I wrote this using the mootools library (it offers some Element features that are quite nice and in fact gave me a multi-level drag and sort tool to test this with). If you prefer to use another library, it should be fairly easy to switch the code to work for it, but I do not use jQuery so I am unfortunately not helpful in that regard
Link to download all files involved: Here
function calculate_ids(el,left_id, parent_id){
var el = $(el);
//makes the element a MooTools Element
var left_id = left_id || 1;
//If left_id is given, we are using this function recursively
var parent = parent_id || 0;
//Gives us a quick method in order to figure out what level we are currently on
var id_array = {};
/*ID array object will look like
{
1:{
'left_id':1,
'right_id':2,
'parent':0
},
2:{
'left_id':3,
'right_id':6,
parent_id:0
},
3:{
'left_id':4,
'right_id':5
},
etc.
}
*/
var els = el.getChildren('li');
//Get the immediate children
els.each(function(child){
var id = child.get('id');
//The ID
var descendants = child.getElements('li');
//Gets ALL most descendent children that match the format, these are ordered the way they are in the DOM
var right_id = left_id + descendants.length * 2 + 1
id_array[id] = {
'left_id':left_id,
'right_id':right_id,
'parent':parent
};
if(descendants.length > 0){
//There are child elements to this thing, recursion!
id_array = Object.merge(id_array, calculate_ids( child.children[0], left_id + 1, id) );
}
left_id = right_id + 1;
//Increment the left_id counter
});
return id_array;
}
Known Issues
The example code I posted doesn't correctly calculate the left/right ids after they've been calculated a first time or moved up/down a level if they were calculated previously. I'm guessing this has something to do with how the multi-level sort class moves the items around. This code is meant to serve as a starting point. I'm really busy (unfortunately), so I may or may not be able to fix this issue in the future, but either way this code should serve as a great starting point.

How do I change the default color (#267114) of region when I use only one parameter Country in geochart

I use a geochart same like this link
jsfiddle.net
code .
I use only one parameter City or country for data-set in geochart , I am unable to change his default data fill region color .
I want to change only circle color they are currently #267114 some thing like green .
Better you can give the full information (OR) Check with this site,
https://developers.google.com/chart/interactive/docs/gallery/geochart
var options = {
defaultColor: '#F9CB1C'
}
It's not in the documentation for some reason. #hth

Zend Framework Lucene Boolean / "Google"-like search

I'm working on the application at http://demos.zatechcorp.com/codeigniter/
In its current incarnation running on my machine, I loaded the ZendFramework inside Codeigniter, and generated an index, like this:
// ... Some code that loads all the markets
foreach ($markets as $market)
{
$doc = new Zend_Search_Lucene_Document();
// Id for retrieval
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('id', $market->id));
// Store document URL to identify it in search result.
$doc->addField(Zend_Search_Lucene_Field::Text('url', $market->permalink));
// Index document content
$doc->addField(Zend_Search_Lucene_Field::UnStored('contents', $market->description));
// Title
$doc->addField(Zend_Search_Lucene_Field::Text('title', $market->title));
// Phone
$doc->addField(Zend_Search_Lucene_Field::Keyword('phone', $market->phone));
// Fax
$doc->addField(Zend_Search_Lucene_Field::Keyword('fax', $market->fax));
// Street
$doc->addField(Zend_Search_Lucene_Field::Keyword('street', $market->street));
// City
$doc->addField(Zend_Search_Lucene_Field::Keyword('city', $market->city));
// State
$doc->addField(Zend_Search_Lucene_Field::Keyword('state', $market->state));
// Zip
$doc->addField(Zend_Search_Lucene_Field::Keyword('zip', $market->zip));
// Type
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('type', 'market'));
// Store Document
$index->addDocument($doc);
}
In my search, I do this:
$hits = $index->find($q);
This works with simple words, but when I want to do a search like "Sheba Foods" (quotes included), it returns one result, but the wrong one, which doesn't even have the word "Sheba".
I moved away from MySQL full-text search because of its obvious problems, and can't make any headway with this.
I've been looking at the Zend_Search_Lucene_Search_QueryParser::parse() method. Does the answer lie in this method?
I figured it out. With Lucene, you can add a field with the name 'id', but retrieving id from a hit gives you something different -- I'll guess this is the id of the search term within the entire search results.
What I had to do in this case was use a different field name like this:
// Id for retrieval
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('item_id', $market->id));
I have used MySQL full-text search in the past, but it's really CPU intensive.
You could always rely on a SELECT * FROM table WHERE column = '%query%'

javascript and php on the fly calendar

I have the code for a javascript calendar and it works perfectly as it creates it when the page loads. However I was wondering if it's possible to add events to it. I found a plugin (jQuery) that enables the user to hover over a td with class "event" and an event will be displayed. So since this calendar will not be used by me but by someone else who knows nothing about developing I was wondering if there is a way to make a php file or upload or something so she can upload the event. I mean, let's say she wants an event on the 3rd then she uploads a file php reads it and tells javascript to add the class "event" that date and jQuery does the rest. Is it possible? I can't even figure out how to do it and I really hope I explained myself. Here's my javascript btw.
function buildCal(){
var d = new Date();
var month = d.getMonth()+1;
var year = d.getFullYear();
var monthName=['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'];
var daysInMonth=[31,0,31,30,31,30,31,31,30,31,30,31];
var objectDay = new Date(year, month-1, 1); //fix date bug when current day is 31st
objectDay.od=objectDay.getDay()+1; //fix date bug when current day is 31st
var todaydate=new Date()
var scanfortoday=(year==todaydate.getFullYear() && month==todaydate.getMonth()+1)? todaydate.getDate() : 0 //DD added
daysInMonth[1]=(((objectDay.getFullYear()%100!=0)&&(objectDay.getFullYear()%4==0))||(objectDay.getFullYear()%400==0))?29:28;
var t='<div class="main"><table class="main" cols="7" cellpadding="0" border="0" cellspacing="0">';
t+='<h3 class="monthCSS" align="center">'+monthName[month-1]+' - '+year+'</h3><tr align="center">';
for(s=0;s<7;s++)t+='<td class="daysofweek">'+"DoLuMaMiJuViSa".substr(s*2,2)+'</td>';
t+='</tr><tr align="center">';
for(i=2;i<=42;i++){
var x=((i-objectDay.od>=0)&&(i-objectDay.od<daysInMonth[month-1]))? i-objectDay.od+1 : ' ';
if (x==scanfortoday)
x='<td class="today">'+x+'</td>'
t+='<td class="days">'+x+'</td>';
if(((i)%7==0)&&(i<36))t+='</tr><tr align="center">';
}
return t+='</tr></table></div>';
}
Something else, as you can see here, it adds blankspaces until it gets to an actual date. I was trying to make it check if(x was not a number) then add a td class="padding" however to do this I was trying to use x.match(/[0-9]+/) but it didn't seem to work and it would also be the first time I try to use regex with javascript would anyone know why is that wrong? or how to actually check for it?
Edit
Something odd is happening with this script and I don't know why, I tried to change from
t+='<td class="days">'+x+'</td>';
to
t+='<td class="days' + x +'">'+x+'</td>';
this, so I could select each td, but when I do this a new td is generated which contains
<td id="days<td class=" today="">1</td>
I have NO idea why this happens, I just know it is messing with the code because afterwards I get a "> printed (because of quotes mis-match caused by this new td...why is this happening?
The calendar systems I've created use a full php array of the month. so that you can iterate over it and for every corresponding blank day table cell there is a blank array for the day.
e.g.
$calendar_dates = array(
[week_1] = array(
[sun] = Null
[mon] = NULL
[tue] = array(
[events] = array(
event_id => 'event name'
event_name => ''
event_time => ''
)
[wed]
...
)
[week_1] => array()
...........
)
I build the days array by just creating an array from the specified date and current week
then I hit the databse to get events in that range
then cycle through the events and attatch them to the calendar array.
works like charm.
To get it to work with javascript just have it echo some specific javascript in the head of the html file that control the opening and closing of the calendar days.
give you client a simple login page to input/edit events in a webform.
It sounds like you're wanting to push event data from the server to your webpage containing the calendar. While this is possible, it's difficult and generally not worth the effort. You would be better off building some AJAX into your calendar and polling the server for event updates every 5 or 10 minutes or so. This will introduce some delay between when new events are uploaded and when they display on the calendar, but will be much easier to develop.

Categories