<?
/*
require_once "api.php";
$boardid = r('boardid');

$boards = getboards();
$cards = getmycards();
//we($mycards);
//$lists = getlists($boardid);
//$cards = getcards($boardid,array_keys($lists));
$users = getusers();

$list = array();
foreach($cards as $cid=>$card){
	$borderid = $card['boardId'];
	if($list[$borderid])continue;
	if(!$boards[ $borderid ]['title'])continue;
	$list[ $borderid ] = array(
		"archived"=>false,
		"title"=> $boards[ $borderid ]['title'],
		"_id"=> $borderid
	);
}

$DATA = array(
	'boardid' => $boardid,
	'boards' => $boards,
	'lists' => $list,
	'cards' => $cards,
	'users'=>$users
);
*/
?>

<!DOCTYPE html>
<html>
<head>
    <? require_once "header.html"; ?>
    <link rel="stylesheet" type="text/css" href="css/fullcalendar.css">
    <script src='fullcalendarjs/jquery-ui-1.10.2.custom.min.js'></script>
    <script src='fullcalendarjs/fullcalendar.min.js'></script>
</head>
<body>
<? require_once "leftbar.html"; ?>
<? require_once "projectheader.html"; ?>

<div id="wrap">
    <div id="calendar" style="margin:15px;">

    </div>
</div>

<script type="text/javascript">


    $(function () {
        $('.projectheader h1').html('我的日程');

        var date = new Date();
        var d = date.getDate();
        var m = date.getMonth();
        var y = date.getFullYear();

        $('#calendar').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },
            firstDay: 1,
            aspectRatio: 2.4,
            editable: false,
            timeFormat: 'H:mm',
            axisFormat: 'H:mm',

            events: function (start, end, callback) {
                var _start = Math.round(start.getTime() / 1000);
                var _end = Math.round(end.getTime() / 1000);

                $.ajax({
                    url: './?app=api&apiact=get_mem_time',
                    dataType: 'json',
                    data: {
                        start: _start,
                        end: _end,
                        who: "mime"
                    },
                    success: function (doc) {
                        callback(doc.calendarData);
                    }
                });
            },

            eventRender: function (event, element) {
                element.html('<i class="eventboardtitle">' + event.boardtitle + "</i> " + event.title.substr(0, 40)).css('background', fmtColorByBID(event.boardid));
            },
        });

    });

    var bid2color = {};

    function fmtColorByBID(bid) {
        if (!bid2color[bid]) bid2color[bid] = getRandomSafeColor();
        return bid2color[bid];
    }

    function getRandomSafeColor() {
        var base = ['00', '11', '22', '33', '44', '55', '66', '77', '88', '99', 'aa', 'bb', 'cc'];//基础色代码
        var res = '#';
        for (var i = 0; i < 3; i++) {
            res += base[Math.floor(Math.random() * base.length)];
        }
        return res;
    }

</script>

<style>
    .fc-week .fc-sun{
        color: red;
    }
    .fc-week .fc-sat{
        color: red;
    }



</style>

</body>
</html>


