Firebug shows data stream but not calendar? - mysql

after many days [9] I have come to a point where I need to either look for another calendar or just give up.. Using fullcalendar I have json-events.php sending mysql data through to my staff_calendar.php page, the datastream shows in firebug, the calendar shows in the page but the data doesnt appear in the actual fullcalendar, can anyone please help?
What could be stopping this data rendering in my page?
xxjson-events.php
<?php
mysql_select_db($database_ghl_portal, $ghl_portal);
$query_rsXXCal = "Select events.* , UNIX_TIMESTAMP(start_date) as start_date, UNIX_TIMESTAMP(end_date) as end_date From events";
$rsXXCal = mysql_query($query_rsXXCal, $ghl_portal) or die(mysql_error());
$row_rsXXCal = mysql_fetch_assoc($rsXXCal);
$totalRows_rsXXCal = mysql_num_rows($rsXXCal);
$result = mysql_query($query_rsXXCal) or die(mysql_error());
while($row = mysql_fetch_assoc($result)){
$eventsArray = array();
$eventsArray['title'] = $row['title'];
$eventsArray['start'] = $row['start_date'];
$eventsArray['end'] = $row['end_date'];
}
header('Content-type: application/json');
echo json_encode($eventsArray)
?>
This outputs both in browser & firebug as:
{"title":"Visit","start":"1330077690","end":"1330081890"}
calendar.php
script type='text/javascript'>
$(document).ready(function() {
$('#calendar').fullCalendar({
editable: false,
eventSources: [
{
url: '/xxjson-events.php',
async: 'false' // No longer asynchronous
}
],
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}
}); });
</script>
Thanks to anyone who can shed any light on this, however small it may be!

Well first I suspect it is because
async: 'false'
Should be...
async: false
and also, by default allDayDefault is set to true so if you are not displaying allDay events then you won't actually see them.
If you don't want to show allDay events then add...
allDayDefault: false
...to the initialization. On the other hand if you do want to show allDay events then you need to add another field to your database table called allDay and set it to true or false depending on what the event calls for. Pull it out through the array and it should display. Let me know if this helps.

I HAVE GOT IT! So, there were no errors from fullcalendar parser. I though JSON is a one standard... Unfortunately it isn't (mayby only in my situation :P ).
So, JSON response from servlet looks like below:
{"id":"68","title":"ddd","start":"2012-03-28","end":"2012-03-29"}
I just add "[" and "]" before sent from servlet and it works!
[{"id":"68","title":"ddd","start":"2012-03-28","end":"2012-03-29"}]
I hope it will be helpful for someone like me ;-)

Related

innerHTML call to receive a url

I am trying to make a call so that when a title of a video is clicked on in my playlist, it will call back a particular videos url to be shown in the metadata field box that I have created.
So far I am getting results but the function below that I am using is giving me rmtp url's like this:
(rtmp://brightcove.fcod.llnwd.net/a500/d16/&mp4:media/1978114949001/1978114949001_2073371902001_How-to-Fish-the-Ice-Worm.mp4&1358870400000&7b1c5b2e65a7c051419c7f50bd712b1b
)
Brightcove has said to use (FLVURL&media_delivery=http).
I have tried every way I know of to put a media delivery in my function but always come up with nothing but the rmtp or a blank.
Can you please help with the small amount of code I have shown. If I need to show more that is not a problem. Thanks
function showMetaData(idx) {
$("tr.select").removeClass("select");
$("#tbData>tr:eq("+idx+")").addClass("select");
var v = oCurrentVideoList[idx];
//URL Metadata
document.getElementById('divMeta.FLVURL').innerHTML = v.FLVURL;
Here is my Population call for my list.
//For PlayList by ID
function buildMAinVideoList() {
//Wipe out the old results
$("#tbData").empty();
console.log(oCurrentMainVideoList);
oCurrentVideoList = oCurrentMainVideoList;
// Display video count
document.getElementById('divVideoCount').innerHTML = oCurrentMainVideoList.length + " videos";
document.getElementById('nameCol').innerHTML = "Video Name";
//document.getElementById('headTitle').innerHTML = title;
document.getElementById('search').value = "Search Videos";
document.getElementById('tdMeta').style.display = "block";
document.getElementById('searchDiv').style.display = "inline";
document.getElementById('checkToggle').style.display = "inline";
$("span[name=buttonRow]").show();
$(":button[name=delFromPlstButton]").hide();
//For each retrieved video, add a row to the table
var modDate = new Date();
$.each(oCurrentMainVideoList, function(i,n){
modDate.setTime(n.lastModifiedDate);
$("#tbData").append(
"<tr style=\"cursor:pointer;\" id=\""+(i)+"\"> \
<td>\
<input type=\"checkbox\" value=\""+(i)+"\" id=\""+(i)+"\" onclick=\"checkCheck()\">\
</td><td>"
+n.name +
"</td><td>"
+(modDate.getMonth()+1)+"/"+modDate.getDate()+"/"+modDate.getFullYear()+"\
</td><td>"
+n.id+
"</td><td>"
+((n.referenceId)?n.referenceId:'')+
"</td></tr>"
).children("tr").bind('click', function(){
showMetaData(this.id);
})
});
//Zebra stripe the table
$("#tbData>tr:even").addClass("oddLine");
//And add a hover effect
$("#tbData>tr").hover(function(){
$(this).addClass("hover");
}, function(){
$(this).removeClass("hover");
});
//if there are videos, show the metadata window, else hide it
if(oCurrentMainVideoList.length > 1){showMetaData(0);}
else{closeBox("tdMeta");}
}
If looking for HTTP paths, when the API call to Brightcove is correct you won't see the rtmp:// urls.
Since you're getting the rtmp URLs, this verifies you're using an API token with URL access, which is good. A request like this should return the playlist and the http URLs (insert your token and playlist ID).
http://api.brightcove.com/services/library?command=find_playlist_by_id&token={yourToken}&playlist_id={yourPlaylist}&video_fields=FLVURL&media_delivery=http
This API test tool can help build the queries for you, and show the expected results:
http://opensource.brightcove.com/tool/api-test-tool
I'm not seeing what would be wrong in your code, but in case you haven't tried this already, debugging in the browser can help you confirm the API results being returned, without having to access it via code. This help you root out any issues with the code you're using to access the values, vs problems with the values themselves. This is an overview on step-debugging in Chrome if you haven't used this before:
https://developers.google.com/chrome-developer-tools/docs/scripts-breakpoints

Get a users youtube feed with knockout js?

Is this possible.. here's what I have atm, but my data object is just returning a load of jargon, what am I doing wrong? Am I doing anything.. right, for that matter?
I basically want to print out a list of a users videos (thumbnail and title, and make each one a clickable link to the video itself)
Thanks!
$(document).ready(function(){
$player.init();
})
var $player = (function(){
var player = {};
player.init = function(){
//init Youtube knockout
player.initYoutubeKnockout();
}
player.knockoutModel = {
videoData : ko.observableArray([]),
}
player.initYoutubeKnockout = function()
{
//load the Youtube json feed
$.ajax({
url: 'http://gdata.youtube.com/feeds/api/users/USERNAME/uploads?v=2&alt=json',
type: 'GET',
dataType: 'jsonp',
data: {
count: 5
},
success: function(data, textStatus, xhr) {
player.doYoutubeKnockout(data.item);
}
});
}
player.doYoutubeKnockout = function( data )
{
player.knockoutModel.videoData(data);
ko.applyBindings(player.knockoutModel, $('#youtube-feed')[0]);
console.log($(this));
}
return player;
})();
Frankly you weren't doing much at all.
The JSON data you get back from YouTube is not from data.item, it's in a completely different structure.
I'm assuming you wish to get 5 uploads from the user. The parameter name would be max-results, not count.
Probably the only thing you did fine was set up the url but that's about it.
You need to examine how the JSON returned looks like. Check the API reference for the structure of an atom feed. This is in XML but the corresponding JSON responses will have pretty much the same format with some minor differences. Examine the object by writing it to the console to verify you're getting the right properties.
Once you understand that, you need to use the correct query to get what you're expecting. Check out their API reference on their query parameters.
To help simplify your knockout code, I would strongly recommend you take the response you get back and map it to an object with simplified property names. For instance, to get the thumbnails for an entry, you would have to access the media$group.media$thumbnail array. It would be easier if you can just access it through thumbnail.
Also, if your elements you are binding to need to bind multiple values, it would help to map the values in such a way that your bindings are made easier. For instance, when using the attr binding, you'd set up a property for each of the attributes you want to add. Instead you could just group all the properties in an object and bind to that.
I wrote up a fiddle applying all that I said above to do as you had asked for. This should help give you an idea of what you can do and how to do it.
Demo

Trouble with onload and collecting field information in IE. Fine in Chrome

In the body I have the following:
<body onload="loadCheck1();">
Which points to the following function:
function loadCheck1() {
var chkme1 = "<?php echo $_GET['update']; ?>";
if (chkme1 ==1){
window.location = "viewrecipe.php?recipe_name="+recipe_name.value+"&update=2&texty1="+texty1.value+"&texty2="+texty2.value+"&texty3="+texty3.value+"&texty4="+texty4.value+"&texty5="+texty5.value;
}
if (last==3){
window.location = "viewrecipe.php?recipe_name="+recipe_name.value+"&NewFG1="+texty4.value+"&NewAlc="+texty5.value;
}
}
The URL being viewrecipe.php?update=1 should load the first window.location and viewrecipe.php?update=3 should load the 2nd.
In Chrome this works absolutely fine. In IE I get an error saying "recipe_name" undefined.
The only thing I can think of is that in Chrome the code only activates after the actual loading of the page. As by that time all the field values will be filled in.
Is there an alternative method to running a function once the page has loaded?
There are several variables not defined in your function:
- recipe_name
- last
Are they defined somewhere else?
I guess that texty1 to texty5 are form inputs. If not these variables are not defined too.
You should give us more of your code so we can help you.

Integrate Facebook Credits with AS3-SDK

I’m trying to integrate Facebook Credits as a paying method using the as3-sdk. I managed to get “earn_credits” and “buy_credits” working. However the third and most important option, “buy_item”, doesn’t show up the pay dialog. Somehow the connection to the callback.php seems the reason for the issue. Note: I have typed in the callback URL in my apps settings, so I didn’t forget that. I use the example php file from the Facebook Developer docs.
This is my as3 code.
public static function buyItem ():void
{
var theAction:String = "buy_item";
var order_info:Object = { "item_id":"1a" };
var jOrder:String = JSON.encode(order_info);
var data:Object = {
action:theAction,
order_info:jOrder,
dev_purchase_params: {"oscif":true}
};
Facebook.ui("pay", data, purchaseCallback);
}
I think the json encoding might be the problem, but i'm not sure.
I use the example php file from the Facebook Developer docs (excerpt):
<?php
$app_secret = '***********************';
// Validate request is from Facebook and parse contents for use.
$request = parse_signed_request($_POST['signed_request'], $app_secret);
// Get request type.
// Two types:
// 1. payments_get_items.
// 2. payments_status_update.
$request_type = $_POST['method'];
// Setup response.
$response = '';
if ($request_type == 'payments_get_items') {
// Get order info from Pay Dialog's order_info.
// Assumes order_info is a JSON encoded string.
$order_info = json_decode($request['credits']['order_info'], true);
// Get item id.
$item_id = $order_info['item_id'];
// Simulutates item lookup based on Pay Dialog's order_info.
if ($item_id == '1a') {
$item = array(
'title' => '100 some game cash',
'description' => 'Spend cash in some game.',
// Price must be denominated in credits.
'price' => 1,
'image_url' => '**********************/banner1.jpg',
);
// Construct response.
$response = array(
'content' => array(
0 => $item,
),
'method' => $request_type,
);
// Response must be JSON encoded.
$response = json_encode($response);
}
Any help, is really appreciated.
Okay so I cannot confirm that this works but according to this forum, it does:
var title:String = "TITLE FOO";
var desc:String = "FOO";
var price:String = "200";
var img_url:String = [some image url];
var product_url:String = [some product url];
// create order info object
var order_info:Object = {
"title":title,
"description":desc,
"price":price,
"image_url":img_url,
"product_url":product_url
};
// calling the API ...
var obj:Object = {
method: 'pay.prompt',
order_info: order_info,
purchase_type: 'item',
credits_purchase: false
};
Facebook.ui('pay', obj, callbackFunction);
I see that this example differs from yours slightly on the AS3 side so hopefully this nfo will help you resolve your problem. I realize that this isn't the best way to go about answering questions but I can see after a couple of days on here, no one has a answered you so I figured anything could help at this point. :)
Thank you #Ascension Systems!
This worked out well and is much better than creating a pop-up via html, and using navigateToURL etc...
One caveat though, which caused your solution not to work for me initially:
If you are relying on the callback.php sample provided by Facebook ( at the end of this page: http://developers.facebook.com/docs/credits/callback/ ), then you need to add this tag to your order_info object:
var item_id:String = "1a";
var order_info:Object = {
"title":title,
"description":desc,
"price":price,
"image_url":img_url,
"product_url":product_url,
"item_id":item_id
};
Without item_id defined, the if statement in Facebook's callback.php ( if ($item_id == '1a') ... ) will fail, and you'll get an unpleasant window: "App Not Responding
The app you are using is not responding. Please try again later."

MediaWiki Extension question / suggestion

Complete beginner here. I want to create a new tab on each page that has a custom action. When clicked, it takes you to a new page which has custom HTML on it along with the text or the original article.
So far I could create a new Tab and could give a custom action mycustomaction to it. I am pasting what I did so far here. Please let me know if I am using the correct hooks etc. and what is a better way to achieve this basic functionality.
So far with their docs I have done this:
#Hook for Tab
$wgHooks['SkinTemplateContentActions'][] = 'myTab';
#Callback
function myTab( $content_actions) {
global $wgTitle;
$content_actions['0'] = array(
'text' => 'my custom label',
'href' => $wgTitle->getFullURL( 'action=mycustomaction' ),
);
return true;
}
#new action hook
$wgHooks['UnknownAction'][] = 'mycustomaction';
#callback
function mycustomaction($action, $article) {
echo $action;
return true;
}
This gives me error:
No such action
The action specified by the URL is invalid. You might have mistyped the URL, or followed an incorrect link. This might also indicate a bug in the software used by yourplugin
What I was doing wrong:
$content_actions[‘0’] should simply be $content_actions[] (minor nitpick)
$content_actions is passed-by-reference, it should be function myTab( &$content_actions ) {}
mycustomaction() should do something along the lines of
if ( $action == ‘mycustomaction’ ) {
do stuff; return false;
}
else {
return true;
}
It should use $wgOut->addHTML() instead of echo
Thanks a lot everyone for your help!