時差を計算し、値を分単位で返すphpプログラムがあります。
メッセージポップアップにはjGrowlを使用します
私がやりたいことは、戻り値を取得し、30 分未満の場合は jquery メッセージを表示することです。
そして最も重要なことは、ライブで実行する必要があることです。したがって、ユーザーが移動または更新せずにページにいる場合、時間が 30 分未満の場合、ポップアップはリアルタイムで表示されます。
上記の要件を達成するために戻り値を使用する方法を教えてください。
以下は、時差を計算するために使用しているコードの場合
function time($dbtime, $currtime)
{
//format year-month-day hour:min:secs
$current = strtotime($currtime);
$indb = strtotime($dbtime);
$minits = round(abs($current - $indb) / 60,2);
return $minits;
}
現在、日付のメッセージのみをポップアップ表示しています
<script type="text/javascript">
(function($){
$(document).ready(function(){
// jGrowl
if ($.fn.jGrowl) {
// This value can be true, false or a function to be used as a callback when the closer is clciked
$.jGrowl.defaults.closer = function() {
console.log("Closing everything!", this);
};
// A callback for logging notifications.
$.jGrowl.defaults.log = function(e,m,o) {
$('#logs').append("<div><strong>#" + $(e).attr('id') + "</strong> <em>" + (new Date()).getTime() + "</em>: " + m + " (" + o.theme + ")</div>")
}
<?php foreach ($dailies as $daily):?>
$.jGrowl("<?php echo $daily['calendars'][0]['Title']?>", { header: 'At <?php echo $daily['calendars'][0]['Start'];?>', sticky: true });
<?php endforeach;?>
$.jGrowl.defaults.closerTemplate = '<div>hide everything</div>';
}
});
})(jQuery);
</script>