I have a video website, and in the source I have a javascript variable named ajax_switch.post_status which has 2 values, on or off.
Also I have a slide button with 2 options on and off. This button turn on or off publish to facebook. So when I press play to a video after 10 seconds publish to facebook. The button is a jquery one so when I press on or off made a update in database. How can I change the variable of ajax_switch.post_status in real time in source so if the user access the video page and will deactivate the facebook post without refreshing click play to not publish?
I use this in wordpress. My functions are:
Show the button code in single php
And the condition for posting:
Also I have a slide button with 2 options on and off. This button turn on or off publish to facebook. So when I press play to a video after 10 seconds publish to facebook. The button is a jquery one so when I press on or off made a update in database. How can I change the variable of ajax_switch.post_status in real time in source so if the user access the video page and will deactivate the facebook post without refreshing click play to not publish?
I use this in wordpress. My functions are:
Show the button code in single php
Code:
<div class="left" id="1"></div>
<div id="ajax" style="padding-left: 10px; line-height: 13px; height: 27px; vertical-align:middle; display: table-cell;" >
Permiteți Video Best să distribuie acest video pe Facebook cu acordul dvs. Debifând această casetă va opri distribuirea și va șterge postarea de pe cronologia dvs.
</div>
<div class="clear"></div>
<script type="text/javascript">
$('#1').iphoneSwitch(ajax_switch.post_status, function()
{
$.post(ajax_switch.templateUrl+'on.php', function(data)
{
$('#ajax').html(data);
ajax_switch.post_status = 'on';
});
},
function()
{
$.post(ajax_switch.templateUrl+'off.php', function(data)
{
$('#ajax').html(data);
ajax_switch.post_status = 'off';
});
},
{
switch_on_container_path: ajax_switch.templateUrl+'iphone_switch_container_off.png'
});
</script>
And the condition for posting:
Code:
if(ajax_switch.post_status == 'on')
{
FB.api(
'/me/video.watches',
'post',
{
'movie': '<?php the_permalink() ?>?ex=257957417674441',
'access_token': '<?php echo $token; ?>'
},
function(response)
{
if (!response || response.error)
{
console.log(response.error);
}
else
{
console.log('Ewww!');
}
});
}