• timepicker php strtotime 8hours


    https://jqueryui.com/datepicker/

    w

    timepicker

    datepicker

    日期 时间 选择器

        <script src="static/jquery-3.1.0.min.js"></script>
        <link rel="stylesheet" href="static/jquery-ui.css">
        <script src="static/jquery-timepicker-master/jquery.timepicker.min.js"></script>
        <script src="static/jquery-ui.min.js"></script>
        <script>
            $(function () {
                $("#jqueryui-datepicker_wmiss").datepicker({
                    dateFormat: "yy-mm-dd",
                    changeMonth: true
                });
                $("#ui-datepicker-div").css('opacity', '1')
                $("#ui-datepicker-div").css('z-index', 99999);
            });
        </script>
    
    
    开始同步日期:<input class="form-control" type="text" name="wmiss" id="jqueryui-datepicker_wmiss" >
    <meta charset="UTF-8">
    <?php
    setcookie('userid', 'all');
    include('conn.php');
    include('w_fun.php');
    include('config_lang.php');
    include('w_fun_this_project.php');
    $sql = 'SET GLOBAL  connect_timeout=31536000';
    mysqli_query($link, $sql);
    $wclock0 = 8;
    $wclock1 = 21;
    
    
    $wtoday = date('Y-m-d');
    $wts = strtotime($wtoday);
    $wts += $wclock0 * 3600;
    //$wts += $wclock1 * 3600 - 10 * 24 * 3600;
    
    //var_dump($_REQUEST);
    $wsearch = false;
    if (isset($_REQUEST['wmiss']) && $_REQUEST['wmiss'] != '') {
        $wsearch = true;
        $wd = $_REQUEST['wmiss'] . '0000';
        $wd = strtotime($wd);
        $wts = $wd - 8 * 3600 + $wclock0 * 3600;
        $wtsb = $wts + +$wclock1 * 3600;
    }
    
    $wdate_easyb = array();
    $sql = 'SELECT id FROM room ';
    $wrooms = db_multiple_rows_link($link, $sql);
    
    //遍历会议室
    foreach ($wrooms AS $wr) {
        $ww = ' WHERE  ro.wstart>=' . $wts;
        if ($wsearch) $ww = ' WHERE  ro.wstart>=' . $wts . ' AND ro.wend<=' . $wtsb . ' ';
        $ww .= ' AND  ro.rid = ' . $wr['id'];
    
        $wf = 'ro.*,r.name,r.wdes,r.num,FROM_UNIXTIME(ro.wstart,"%Y%m%d") AS wdate,FROM_UNIXTIME(ro.wstart,"%H%i") AS wshi, FROM_UNIXTIME(ro.wend,"%H%i") AS wehi';
        $sql = 'SELECT ' . $wf . ' FROM room_order ro LEFT JOIN room r ON ro.rid=r.id ' . $ww . '  ORDER  BY ro.wstart  ASC ';
    
        //var_dump($sql);
        $wrows = array();
        $wrows = db_multiple_rows_link($link, $sql);
    
        $w = 0;
        $wb = 0;
        $wtmpdate = '';
        $wdate_arr = array();
        //定会议室,按日期建立2维数组
        foreach ($wrows AS $one) {
            if ($wb == 0) {
                $wdate_arr[$w][] = $one;
                $wb = 1;
            } else {
                if ($wtmpdate == $one['wdate']) {
                    $wdate_arr[$w][] = $one;
                } else {
                    $w++;
                    $wdate_arr[$w][] = $one;
                }
            }
            $wtmpdate = $one['wdate'];
        }
    
    
        $wdate_easy = array();
        $w = 0;
        //定会议室、日期,计算各个时间子区间的会议起止时间和会议发起者
        foreach ($wdate_arr AS $one) {
    
            $wdate_easy[$w]['wdate'] = $one['0']['wdate'];
            $wdate_easy[$w]['name'] = $one['0']['name'];
            $wdate_easy[$w]['wdes'] = $one['0']['wdes'];
            $wdate_easy[$w]['num'] = $one['0']['num'];
            $wdate_easy[$w]['rid'] = $one['0']['rid'];
            //建立填充结构,初始为空,即会议室未被预订
            for ($wi = $wclock0; $wi < $wclock1; $wi++) {
                $wii = 100 * $wi;
                $wdate_easy[$w][$wii . 's'] = '';
                $wdate_easy[$w][$wii . 'e'] = '';
                //每个时间区间、粒度下,@w假定w@只有一个时间起点、终点、起点和终点、终点和起点:有且只有4种情况
                //关注起点
                $wdate_easy[$w][$wii . 's' . 'sysuser'] = '';
                $wdate_easy[$w][$wii . 's' . 'id'] = '';
    
                $wii = 100 * $wi + 30;
                $wdate_easy[$w][$wii . 's'] = '';
                $wdate_easy[$w][$wii . 'e'] = '';
                $wdate_easy[$w][$wii . 's' . 'sysuser'] = '';
                $wdate_easy[$w][$wii . 's' . 'id'] = '';
    
            }
            $w++;
        }
    
        $w = 0;
        //遍历日期
        foreach ($wdate_arr AS $one) {
            //遍历时间区间
            foreach ($one AS $oneb) {
                $wshi = $oneb['wshi'];
                $wehi = $oneb['wehi'];
                $wcon = $wshi . '-' . $wehi . $oneb['sysuser'] . '-' . $oneb['wtheme'];
    
                for ($wi = $wclock0; $wi < $wclock1; $wi++) {
                    //在数据库选出时,已按会议开始时间降序排列
                    $wii = 100 * $wi;
                    if ($wshi >= $wii && $wshi < ($wii + 30)) {
                        $wdate_easy[$w][$wii . 's'] = $wcon;
                        $wdate_easy[$w][$wii . 's' . 'sysuser'] = $oneb['sysuser'];
                        $wdate_easy[$w][$wii . 's' . 'id'] = $oneb['id'];
                    }
                    if ($wehi >= $wii && $wehi < ($wii + 30)) {
                        $wdate_easy[$w][$wii . 'e'] = $wcon;
                    }
                    $wii = 100 * $wi + 30;
                    if ($wshi >= $wii && $wshi < ($wii + 30)) {
                        $wdate_easy[$w][$wii . 's'] = $wcon;
                        $wdate_easy[$w][$wii . 's' . 'sysuser'] = $oneb['sysuser'];
                        $wdate_easy[$w][$wii . 's' . 'id'] = $oneb['id'];
                    }
                    if ($wehi >= $wii && $wehi < ($wii + 30)) {
                        $wdate_easy[$w][$wii . 'e'] = $wcon;
                    }
                }
            }
            $w++;
        }
    
        $wdate_easyb[] = $wdate_easy;
    }
    
    ////var_dump($wdate_easyb);
    
    if (isset($_REQUEST['wsu'])) {
        ////var_dump($_REQUEST);
        $wstart = wampm_millseconds($_REQUEST['wts']);
        $wend = wampm_millseconds($_REQUEST['wte']);
    
        if ($wend <= $wstart) {
            js_pure_alert('起止时间错误!');
        } else {
            $wd = $_REQUEST['wd'] . '0000';
    
            $wd = strtotime($wd);
    
            $wstart += $wd - 8 * 3600;
            $wend += $wd - 8 * 3600;
    
            $wtheme = $_REQUEST['wtheme'];
            $rid = $_REQUEST['wrid'];
    
            $sql = 'SELECT id FROM room_order WHERE rid=' . $rid . ' AND wstart>=' . $wstart . ' AND wstart<' . $wend . ' AND wend>' . $wend;
            $wcheck0 = db_check_exist_link($link, $sql);
    
            $sql = 'SELECT id FROM room_order WHERE rid=' . $rid . ' AND wstart<=' . $wstart . ' AND wend>=' . $wend;
            $wcheck1 = db_check_exist_link($link, $sql);
    
            $sql = 'SELECT id FROM room_order WHERE rid=' . $rid . ' AND wstart<=' . $wstart . ' AND wend>' . $wstart . ' AND wend<=' . $wend;
            $wcheck2 = db_check_exist_link($link, $sql);
    
            $sql = 'SELECT id FROM room_order WHERE rid=' . $rid . ' AND ( wstart=' . $wstart . ' OR wstart=' . $wend . ' OR wend=' . $wstart . ' OR wend=' . $wend . ' )';
            $wcheck3 = db_check_exist_link($link, $sql);
    
            if ($wcheck0 || $wcheck1 || $wcheck2 || $wcheck3) {
                js_pure_alert('房间预订时间冲突!');
            } else {
                $sql = 'INSERT INTO room_order (sysuser,wstart,wend,rid,wtheme) VALUE ("' . $_COOKIE['userid'] . '",' . $wstart . ',' . $wend . ',' . $rid . ',"' . $wtheme . '")';
                ////var_dump($sql);
                mysqli_query($link, $sql);
    
                js_window_location(w_get_this_filename_url());
            }
        }
    
    }
    
    if (isset($_REQUEST['del'])) {
        ////var_dump($_REQUEST);
        $sql = 'DELETE FROM room_order WHERE id=' . $_REQUEST['del'];
        ////var_dump($sql);
        mysqli_query($link, $sql);
        js_window_location(w_get_this_filename_url());
    
    
    }
    
    ?>
    <script>
        console.log(document.cookie);
    </script>
    <!doctype html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>order room - 离散度30min </title>
        <link rel="stylesheet" href="static/bootstrap/css/bootstrap.min.css">
        <link rel="stylesheet" href="static/bootstrap/css/bootstrap-theme.min.css">
        <link rel="stylesheet" href="static/base.css">
        <script src="static/jquery-3.1.0.min.js"></script>
        <script src="static/bootstrap/js/bootstrap.min.js"></script>
    
        <link rel="stylesheet" href="static/jquery-timepicker-master/jquery.timepicker.css">
        <script src="static/jquery-timepicker-master/jquery.timepicker.min.js"></script>
    
        <link rel="stylesheet" href="static/jquery-ui.css">
        <script src="static/jquery-ui.min.js"></script>
    
        <style>
            td {
                background-color: #fff;
            }
        </style>
    </head>
    <body>
    <form method="POST" action="">
        <input class="form-control" type="text" name="wmiss" id="jqueryui-datepicker_wmiss"
               style="display: inline; 10%">
        <button type="submit" class="btn" name="btn_wmiss" style="display: inline">检索日期</button>
    </form>
    <script>
        $(function () {
            $("#jqueryui-datepicker_wmiss").datepicker({
                dateFormat: "yy-mm-dd"
            });
        });
    </script>
    
    <?php
    $wtr = '<table class="table table-striped table-bordered">
    <tr><td>日期</td><td>会议室编号</td><td>会议室名称</td>';
    for ($w = $wclock0; $w < $wclock1; $w++) {
        $wtr .= '<td>' . $w . ':00</td>';
        $wtr .= '<td>' . $w . ':30</td>';
    }
    //$wtr .= '<td>' . $wclock1 . ':00</td></tr>';
    foreach ($wdate_easyb AS $wdate_easy) {
        foreach ($wdate_easy AS $one) {
            $wtr .= '<tr><td>' . $one['wdate'] . '</td><td> ' . $one['num'] . '</td><td>' . $one['name'] . '</td>';
            $wcolor = 0;
            $wstyle[0] = ' ';
            $wstyle[1] = ' style="background-color: yellow"  ';
    
            for ($wi = $wclock0; $wi < $wclock1; $wi++) {
                $wii = 100 * $wi;
                $wid = $one['wdate'] . $wii . $one['rid'];
    
                if ($one[$wii . 's'] != '' || $one[$wii . 'e'] != '') {
                    $wcolor = 1;
                }
    
                if ($one[$wii . 's'] != '' || $one[$wii . 'e'] != '') {
                    //将 “删除按钮”置于会议开始位置
                    if ($one[$wii . 's' . 'sysuser'] == $_COOKIE['userid']) {
                        $wtr .= '<td ' . $wstyle[$wcolor] . ' id="' . $wid . '" >' . $one[$wii . 's'] . '<br><br><br>' . $one[$wii . 'e'] . '<form method="POST" action="" ><button type="submit"  class="btn btn-danger" name="del" value="' . $one[$wii . 's' . 'id'] . '">删除</button></form>' . '</td> ';
                    } else {
                        $wtr .= '<td ' . $wstyle[$wcolor] . ' id="' . $wid . '" >' . $one[$wii . 's'] . '<br><br><br>' . $one[$wii . 'e'] . '</td> ';
                    }
                } else {
                    $wtr .= '<td ' . $wstyle[$wcolor] . ' id="' . $wid . '"   data-toggle="modal" data-target="#w' . $wid . '">' . $one[$wii . 's'] . '' . '<br><br><br>' . $one[$wii . 'e'] . '</td> '; ?>
                    <div class="modal fade  " id="<?= 'w' . $wid ?>" tabindex="-1" role="dialog"
                         aria-labelledby="<?= 'wt' . $wid ?>"
                         aria-hidden="true">
                        <div class="modal-dialog">
                            <form method="post" action="">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                            &times;
                                        </button>
                                        <h4 class="modal-title" id="<?= 'wt' . $wid ?>">
                                            会议室预订
                                        </h4>
                                    </div>
                                    <div class="modal-body">
                                        <table class="table">
                                            <tr>
                                                <td>会议日期</td>
                                                <td id="wd<?= $wid ?>"><input class="form-control jqueryui-datepicker"
                                                                              type="text" name="wd"
                                                                              id="jqueryui-datepicker<?= $wid ?>"
                                                                              value="<?= $one['wdate'] ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>会议室名称</td>
                                                <td id="wr<?= $wid ?>"><input class="form-control" type="text"
                                                                              id="wr<?= $wid ?>"
                                                                              value="<?= $one['name'] ?>" disabled="true">
                                                    <input type="hidden" name="wrid" value="<?= $one['rid'] ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>会议主题</td>
                                                <td><input class="form-control" type="text" name="wtheme"
                                                           id="wt<?= $wid ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="">开始时间</td>
                                                <td><input class="form-control" id="jq_timepicker<?= $wid ?>s" type="text"
                                                           name="wts"
                                                           value="<?= substr($wii, 0, strlen($wii) - 2) . ':' . substr($wii, strlen($wii) - 2, 2); ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>结束时间</td>
    
                                                <td><input class="form-control" id="jq_timepicker<?= $wid ?>e" type="text"
                                                           name="wte">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>预定人</td>
                                                <td><input class="form-control" type="text" name="wu" id="wu<?= $wid ?>"
                                                           value="<?= $_COOKIE['userid'] ?>" disabled="true">
                                            </tr>
    
                                        </table>
                                        <script>
                                            $('#jq_timepicker<?=$wid ?>s').timepicker({
                                                'minTime': '8:00am',
                                                'maxTime': '9:00pm',
                                                'showDuration': false,
                                                'step': 1
                                            });
    
                                            $('#jq_timepicker<?=$wid ?>e').timepicker({
                                                'minTime': '8:00am',
                                                'maxTime': '9:00pm',
                                                'showDuration': false,
                                                'step': 1
                                            });
    
                                            $(function () {
                                                $("#jqueryui-datepicker<?=$wid ?>").datepicker({
                                                    dateFormat: "yy-mm-dd"
                                                });
                                            });
                                        </script>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-default" data-dismiss="modal">取消
                                        </button>
                                        <button type="submit" class="btn btn-primary" name="wsu" id="wo<?= $wid ?>">
                                            提交预订
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <?php
                }
                ?>
                <?php
    
                if (($one[$wii . 's'] == '' && $one[$wii . 'e'] != '') || ($one[$wii . 's'] != '' && $one[$wii . 'e'] != '')) {
                    $wcolor = 0;
                }
    
                $wii = 100 * $wi + 30;
                $wid = $one['wdate'] . $wii . $one['rid'];
                if ($one[$wii . 's'] != '' || $one[$wii . 'e'] != '') {
                    $wcolor = 1;
                }
                if ($one[$wii . 's'] != '' || $one[$wii . 'e'] != '') {
                    if ($one[$wii . 's' . 'sysuser'] == $_COOKIE['userid']) {
                        $wtr .= '<td ' . $wstyle[$wcolor] . ' id="' . $wid . '" >' . $one[$wii . 's'] . '<br><br><br>' . $one[$wii . 'e'] . '<form method="POST" action="" ><button type="submit"  class="btn btn-danger" name="del" value="' . $one[$wii . 's' . 'id'] . '">删除</button></form>' . '</td> ';
                    } else {
                        $wtr .= '<td ' . $wstyle[$wcolor] . ' id="' . $wid . '" >' . $one[$wii . 's'] . '<br><br><br>w2w2--' . $one[$wii . 'e'] . '</td> ';
                    }
                } else {
                    $wtr .= '<td ' . $wstyle[$wcolor] . ' id="' . $wid . '"   data-toggle="modal" data-target="#w' . $wid . '">' . $one[$wii . 's'] . '<br><br><br>' . $one[$wii . 'e'] . '</td> '; ?>
    
                    <div class="modal fade" id="<?= 'w' . $wid ?>" tabindex="-1" role="dialog"
                         aria-labelledby="<?= 'wt' . $wid ?>"
                         aria-hidden="true">
                        <div class="modal-dialog">
                            <form method="post" action="">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                            &times;
                                        </button>
                                        <h4 class="modal-title" id="<?= 'wt' . $wid ?>">
                                            会议室预订
                                        </h4>
                                    </div>
                                    <div class="modal-body">
                                        <table class="table">
                                            <tr>
                                                <td>会议日期</td>
                                                <td id="wd<?= $wid ?>"><input class="form-control jqueryui-datepicker"
                                                                              type="text" name="wd"
                                                                              id="jqueryui-datepicker<?= $wid ?>"
                                                                              value="<?= $one['wdate'] ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>会议室名称</td>
                                                <td id="wr<?= $wid ?>"><input class="form-control" type="text"
                                                                              id="wr<?= $wid ?>"
                                                                              value="<?= $one['name'] ?>" disabled="true">
    
                                                    <input type="hidden" name="wrid" value="<?= $one['rid'] ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>会议主题</td>
                                                <td><input class="form-control" type="text" name="wtheme"
                                                           id="wt<?= $wid ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="">开始时间</td>
                                                <td><input class="form-control" id="jq_timepicker<?= $wid ?>s" type="text"
                                                           name="wts"
                                                           value="<?= substr($wii, 0, strlen($wii) - 2) . ':' . substr($wii, strlen($wii) - 2, 2); ?>">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>结束时间</td>
    
                                                <td><input class="form-control" id="jq_timepicker<?= $wid ?>e" type="text"
                                                           name="wte">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>预定人</td>
                                                <td><input class="form-control" type="text" id="wu<?= $wid ?>"
                                                           value="<?= $_COOKIE['userid'] ?>" disabled="true">
                                            </tr>
                                        </table>
                                        <script>
                                            $('#jq_timepicker<?=$wid ?>s').timepicker({
                                                'minTime': '8:00am',
                                                'maxTime': '9:00pm',
                                                'showDuration': false,
                                                'step': 1
                                            });
                                            $('#jq_timepicker<?=$wid ?>e').timepicker({
                                                'minTime': '8:00am',
                                                'maxTime': '9:00pm',
                                                'showDuration': false,
                                                'step': 1
                                            });
                                            $(function () {
                                                $("#jqueryui-datepicker<?=$wid ?>").datepicker({
                                                    dateFormat: "yy-mm-dd"
                                                });
                                            });
                                        </script>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-default" data-dismiss="modal">取消
                                        </button>
                                        <button type="submit" class="btn btn-primary" name="wsu" id="wo<?= $wid ?>">
                                            提交预订
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <?php
                }
                ?>
                <?php
                if (($one[$wii . 's'] == '' && $one[$wii . 'e'] != '') || ($one[$wii . 's'] != '' && $one[$wii . 'e'] != '')) {
                    $wcolor = 0;
                }
            }
            $wtr .= '</tr>';
        }
    }
    
    $wtr .= '</table>';
    echo $wtr;
    ?>
    
    </body>
    </html>
    
    <script>
    
    
        var w = document.querySelectorAll("td");
        console.log(w);
        for (var wi = 0, wl = w.length; wi < wl; wi++) {
            var wattr = w[wi].style.backgroundColor
            console.log(wattr)
    
            if (wattr == 'yellow') {
                console.log(w[wi].id)
                w[wi].id = null
                console.log(w[wi].id)
                // w[wi].id=null
                // w[wi].onclick=function(){alert(3)}
                w[wi].disabled = true;
    
    
    //            console.log(w[wi].attributes['data-target'])
    //            w[wi].attributes['data-target'].value=null
    //            console.log(w[wi].attributes['data-target'])
    
    
            }
    
        }
    
    </script>
      1 /*!
      2  * jquery-timepicker v1.11.10 - A jQuery timepicker plugin inspired by Google Calendar. It supports both mouse and keyboard navigation.
      3  * Copyright (c) 2017 Jon Thornton - http://jonthornton.github.com/jquery-timepicker/
      4  * License: MIT
      5  */
      6 
      7 !
      8 function(a) {
      9     "object" == typeof exports && exports && "object" == typeof module && module && module.exports === exports ? a(require("jquery")) : "function" == typeof define && define.amd ? define(["jquery"], a) : a(jQuery)
     10 } (function(a) {
     11     function b(a) {
     12         var b = a[0];
     13         return b.offsetWidth > 0 && b.offsetHeight > 0
     14     }
     15     function c(b) {
     16         if (b.minTime && (b.minTime = t(b.minTime)), b.maxTime && (b.maxTime = t(b.maxTime)), b.durationTime && "function" != typeof b.durationTime && (b.durationTime = t(b.durationTime)), "now" == b.scrollDefault) b.scrollDefault = function() {
     17             return b.roundingFunction(t(new Date), b)
     18         };
     19         else if (b.scrollDefault && "function" != typeof b.scrollDefault) {
     20             var c = b.scrollDefault;
     21             b.scrollDefault = function() {
     22                 return b.roundingFunction(t(c), b)
     23             }
     24         } else b.minTime && (b.scrollDefault = function() {
     25             return b.roundingFunction(b.minTime, b)
     26         });
     27         if ("string" === a.type(b.timeFormat) && b.timeFormat.match(/[gh]/) && (b._twelveHourTime = !0), b.showOnFocus === !1 && -1 != b.showOn.indexOf("focus") && b.showOn.splice(b.showOn.indexOf("focus"), 1), b.disableTimeRanges.length > 0) {
     28             for (var d in b.disableTimeRanges) b.disableTimeRanges[d] = [t(b.disableTimeRanges[d][0]), t(b.disableTimeRanges[d][1])];
     29             b.disableTimeRanges = b.disableTimeRanges.sort(function(a, b) {
     30                 return a[0] - b[0]
     31             });
     32             for (var d = b.disableTimeRanges.length - 1; d > 0; d--) b.disableTimeRanges[d][0] <= b.disableTimeRanges[d - 1][1] && (b.disableTimeRanges[d - 1] = [Math.min(b.disableTimeRanges[d][0], b.disableTimeRanges[d - 1][0]), Math.max(b.disableTimeRanges[d][1], b.disableTimeRanges[d - 1][1])], b.disableTimeRanges.splice(d, 1))
     33         }
     34         return b
     35     }
     36     function d(b) {
     37         var c = b.data("timepicker-settings"),
     38         d = b.data("timepicker-list");
     39         if (d && d.length && (d.remove(), b.data("timepicker-list", !1)), c.useSelect) {
     40             d = a("<select />", {
     41                 "class": "ui-timepicker-select"
     42             });
     43             var g = d
     44         } else {
     45             d = a("<ul />", {
     46                 "class": "ui-timepicker-list"
     47             });
     48             var g = a("<div />", {
     49                 "class": "ui-timepicker-wrapper",
     50                 tabindex: -1
     51             });
     52             g.css({
     53                 display: "none",
     54                 position: "absolute"
     55             }).append(d)
     56         }
     57         if (c.noneOption) if (c.noneOption === !0 && (c.noneOption = c.useSelect ? "Time...": "None"), a.isArray(c.noneOption)) {
     58             for (var i in c.noneOption) if (parseInt(i, 10) == i) {
     59                 var k = e(c.noneOption[i], c.useSelect);
     60                 d.append(k)
     61             }
     62         } else {
     63             var k = e(c.noneOption, c.useSelect);
     64             d.append(k)
     65         }
     66         if (c.className && g.addClass(c.className), (null !== c.minTime || null !== c.durationTime) && c.showDuration) {
     67             "function" == typeof c.step ? "function": c.step;
     68             g.addClass("ui-timepicker-with-duration"),
     69             g.addClass("ui-timepicker-step-" + c.step)
     70         }
     71         var l = c.minTime;
     72         "function" == typeof c.durationTime ? l = t(c.durationTime()) : null !== c.durationTime && (l = c.durationTime);
     73         var n = null !== c.minTime ? c.minTime: 0,
     74         o = null !== c.maxTime ? c.maxTime: n + v - 1;
     75         n > o && (o += v),
     76         o === v - 1 && "string" === a.type(c.timeFormat) && c.show2400 && (o = v);
     77         var p = c.disableTimeRanges,
     78         w = 0,
     79         x = p.length,
     80         z = c.step;
     81         "function" != typeof z && (z = function() {
     82             return c.step
     83         });
     84         for (var i = n,
     85         A = 0; o >= i; A++, i += 60 * z(A)) {
     86             var B = i,
     87             C = s(B, c);
     88             if (c.useSelect) {
     89                 var D = a("<option />", {
     90                     value: C
     91                 });
     92                 D.text(C)
     93             } else {
     94                 var D = a("<li />");
     95                 D.addClass(v / 2 > B % v ? "ui-timepicker-am": "ui-timepicker-pm"),
     96                 D.data("time", u(B, c)),
     97                 D.text(C)
     98             }
     99             if ((null !== c.minTime || null !== c.durationTime) && c.showDuration) {
    100                 var E = r(i - l, c.step);
    101                 if (c.useSelect) D.text(D.text() + " (" + E + ")");
    102                 else {
    103                     var F = a("<span />", {
    104                         "class": "ui-timepicker-duration"
    105                     });
    106                     F.text(" (" + E + ")"),
    107                     D.append(F)
    108                 }
    109             }
    110             x > w && (B >= p[w][1] && (w += 1), p[w] && B >= p[w][0] && B < p[w][1] && (c.useSelect ? D.prop("disabled", !0) : D.addClass("ui-timepicker-disabled"))),
    111             d.append(D)
    112         }
    113         if (g.data("timepicker-input", b), b.data("timepicker-list", g), c.useSelect) b.val() && d.val(f(t(b.val()), c)),
    114         d.on("focus",
    115         function() {
    116             a(this).data("timepicker-input").trigger("showTimepicker")
    117         }),
    118         d.on("blur",
    119         function() {
    120             a(this).data("timepicker-input").trigger("hideTimepicker")
    121         }),
    122         d.on("change",
    123         function() {
    124             m(b, a(this).val(), "select")
    125         }),
    126         m(b, d.val(), "initial"),
    127         b.hide().after(d);
    128         else {
    129             var G = c.appendTo;
    130             "string" == typeof G ? G = a(G) : "function" == typeof G && (G = G(b)),
    131             G.append(g),
    132             j(b, d),
    133             d.on("mousedown click", "li",
    134             function(c) {
    135                 b.off("focus.timepicker"),
    136                 b.on("focus.timepicker-ie-hack",
    137                 function() {
    138                     b.off("focus.timepicker-ie-hack"),
    139                     b.on("focus.timepicker", y.show)
    140                 }),
    141                 h(b) || b[0].focus(),
    142                 d.find("li").removeClass("ui-timepicker-selected"),
    143                 a(this).addClass("ui-timepicker-selected"),
    144                 q(b) && (b.trigger("hideTimepicker"), d.on("mouseup.timepicker click.timepicker", "li",
    145                 function(a) {
    146                     d.off("mouseup.timepicker click.timepicker"),
    147                     g.hide()
    148                 }))
    149             })
    150         }
    151     }
    152     function e(b, c) {
    153         var d, e, f;
    154         return "object" == typeof b ? (d = b.label, e = b.className, f = b.value) : "string" == typeof b ? d = b: a.error("Invalid noneOption value"),
    155         c ? a("<option />", {
    156             value: f,
    157             "class": e,
    158             text: d
    159         }) : a("<li />", {
    160             "class": e,
    161             text: d
    162         }).data("time", String(f))
    163     }
    164     function f(a, b) {
    165         return a = b.roundingFunction(a, b),
    166         null !== a ? s(a, b) : void 0
    167     }
    168     function g(b) {
    169         if (b.target != window) {
    170             var c = a(b.target);
    171             c.closest(".ui-timepicker-input").length || c.closest(".ui-timepicker-wrapper").length || (y.hide(), a(document).unbind(".ui-timepicker"), a(window).unbind(".ui-timepicker"))
    172         }
    173     }
    174     function h(a) {
    175         var b = a.data("timepicker-settings");
    176         return (window.navigator.msMaxTouchPoints || "ontouchstart" in document) && b.disableTouchKeyboard
    177     }
    178     function i(b, c, d) {
    179         if (!d && 0 !== d) return ! 1;
    180         var e = b.data("timepicker-settings"),
    181         f = !1,
    182         d = e.roundingFunction(d, e);
    183         return c.find("li").each(function(b, c) {
    184             var e = a(c);
    185             if ("number" == typeof e.data("time")) return e.data("time") == d ? (f = e, !1) : void 0
    186         }),
    187         f
    188     }
    189     function j(a, b) {
    190         b.find("li").removeClass("ui-timepicker-selected");
    191         var c = t(l(a), a.data("timepicker-settings"));
    192         if (null !== c) {
    193             var d = i(a, b, c);
    194             if (d) {
    195                 var e = d.offset().top - b.offset().top; (e + d.outerHeight() > b.outerHeight() || 0 > e) && b.scrollTop(b.scrollTop() + d.position().top - d.outerHeight()),
    196                 d.addClass("ui-timepicker-selected")
    197             }
    198         }
    199     }
    200     function k(b, c) {
    201         if ("" !== this.value && "timepicker" != c) {
    202             var d = a(this);
    203             if (!d.is(":focus") || b && "change" == b.type) {
    204                 var e = d.data("timepicker-settings"),
    205                 f = t(this.value, e);
    206                 if (null === f) return void d.trigger("timeFormatError");
    207                 var g = !1;
    208                 if (null !== e.minTime && null !== e.maxTime && (f < e.minTime || f > e.maxTime) && (g = !0), a.each(e.disableTimeRanges,
    209                 function() {
    210                     return f >= this[0] && f < this[1] ? (g = !0, !1) : void 0
    211                 }), e.forceRoundTime) {
    212                     var h = e.roundingFunction(f, e);
    213                     h != f && (f = h, c = null)
    214                 }
    215                 var i = s(f, e);
    216                 g ? (m(d, i, "error") || b && "change" == b.type) && d.trigger("timeRangeError") : m(d, i, c)
    217             }
    218         }
    219     }
    220     function l(a) {
    221         return a.is("input") ? a.val() : a.data("ui-timepicker-value")
    222     }
    223     function m(a, b, c) {
    224         if (a.is("input")) {
    225             a.val(b);
    226             var d = a.data("timepicker-settings");
    227             d.useSelect && "select" != c && "initial" != c && a.data("timepicker-list").val(f(t(b), d))
    228         }
    229         return a.data("ui-timepicker-value") != b ? (a.data("ui-timepicker-value", b), "select" == c ? a.trigger("selectTime").trigger("changeTime").trigger("change", "timepicker") : -1 == ["error", "initial"].indexOf(c) && a.trigger("changeTime"), !0) : (a.trigger("selectTime"), !1)
    230     }
    231     function n(a) {
    232         switch (a.keyCode) {
    233         case 13:
    234         case 9:
    235             return;
    236         default:
    237             a.preventDefault()
    238         }
    239     }
    240     function o(c) {
    241         var d = a(this),
    242         e = d.data("timepicker-list");
    243         if (!e || !b(e)) {
    244             if (40 != c.keyCode) return ! 0;
    245             y.show.call(d.get(0)),
    246             e = d.data("timepicker-list"),
    247             h(d) || d.focus()
    248         }
    249         switch (c.keyCode) {
    250         case 13:
    251             return q(d) && (k.call(d.get(0), {
    252                 type: "change"
    253             }), y.hide.apply(this)),
    254             c.preventDefault(),
    255             !1;
    256         case 38:
    257             var f = e.find(".ui-timepicker-selected");
    258             return f.length ? f.is(":first-child") || (f.removeClass("ui-timepicker-selected"), f.prev().addClass("ui-timepicker-selected"), f.prev().position().top < f.outerHeight() && e.scrollTop(e.scrollTop() - f.outerHeight())) : (e.find("li").each(function(b, c) {
    259                 return a(c).position().top > 0 ? (f = a(c), !1) : void 0
    260             }), f.addClass("ui-timepicker-selected")),
    261             !1;
    262         case 40:
    263             return f = e.find(".ui-timepicker-selected"),
    264             0 === f.length ? (e.find("li").each(function(b, c) {
    265                 return a(c).position().top > 0 ? (f = a(c), !1) : void 0
    266             }), f.addClass("ui-timepicker-selected")) : f.is(":last-child") || (f.removeClass("ui-timepicker-selected"), f.next().addClass("ui-timepicker-selected"), f.next().position().top + 2 * f.outerHeight() > e.outerHeight() && e.scrollTop(e.scrollTop() + f.outerHeight())),
    267             !1;
    268         case 27:
    269             e.find("li").removeClass("ui-timepicker-selected"),
    270             y.hide();
    271             break;
    272         case 9:
    273             y.hide();
    274             break;
    275         default:
    276             return ! 0
    277         }
    278     }
    279     function p(c) {
    280         var d = a(this),
    281         e = d.data("timepicker-list"),
    282         f = d.data("timepicker-settings");
    283         if (!e || !b(e) || f.disableTextInput) return ! 0;
    284         switch (c.keyCode) {
    285         case 96:
    286         case 97:
    287         case 98:
    288         case 99:
    289         case 100:
    290         case 101:
    291         case 102:
    292         case 103:
    293         case 104:
    294         case 105:
    295         case 48:
    296         case 49:
    297         case 50:
    298         case 51:
    299         case 52:
    300         case 53:
    301         case 54:
    302         case 55:
    303         case 56:
    304         case 57:
    305         case 65:
    306         case 77:
    307         case 80:
    308         case 186:
    309         case 8:
    310         case 46:
    311             f.typeaheadHighlight ? j(d, e) : e.hide()
    312         }
    313     }
    314     function q(a) {
    315         var b = a.data("timepicker-settings"),
    316         c = a.data("timepicker-list"),
    317         d = null,
    318         e = c.find(".ui-timepicker-selected");
    319         return e.hasClass("ui-timepicker-disabled") ? !1 : (e.length && (d = e.data("time")), null !== d && ("string" != typeof d && (d = s(d, b)), m(a, d, "select")), !0)
    320     }
    321     function r(a, b) {
    322         a = Math.abs(a);
    323         var c, d, e = Math.round(a / 60),
    324         f = [];
    325         return 60 > e ? f = [e, w.mins] : (c = Math.floor(e / 60), d = e % 60, 30 == b && 30 == d && (c += w.decimal + 5), f.push(c), f.push(1 == c ? w.hr: w.hrs), 30 != b && d && (f.push(d), f.push(w.mins))),
    326         f.join(" ")
    327     }
    328     function s(b, c) {
    329         if ("number" != typeof b) return null;
    330         var d = parseInt(b % 60),
    331         e = parseInt(b / 60 % 60),
    332         f = parseInt(b / 3600 % 24),
    333         g = new Date(1970, 0, 2, f, e, d, 0);
    334         if (isNaN(g.getTime())) return null;
    335         if ("function" === a.type(c.timeFormat)) return c.timeFormat(g);
    336         for (var h, i, j = "",
    337         k = 0; k < c.timeFormat.length; k++) switch (i = c.timeFormat.charAt(k)) {
    338         case "a":
    339             j += g.getHours() > 11 ? w.pm: w.am;
    340             break;
    341         case "A":
    342             j += g.getHours() > 11 ? w.PM: w.AM;
    343             break;
    344         case "g":
    345             h = g.getHours() % 12,
    346             j += 0 === h ? "12": h;
    347             break;
    348         case "G":
    349             h = g.getHours(),
    350             b === v && (h = c.show2400 ? 24 : 0),
    351             j += h;
    352             break;
    353         case "h":
    354             h = g.getHours() % 12,
    355             0 !== h && 10 > h && (h = "0" + h),
    356             j += 0 === h ? "12": h;
    357             break;
    358         case "H":
    359             h = g.getHours(),
    360             b === v && (h = c.show2400 ? 24 : 0),
    361             j += h > 9 ? h: "0" + h;
    362             break;
    363         case "i":
    364             var e = g.getMinutes();
    365             j += e > 9 ? e: "0" + e;
    366             break;
    367         case "s":
    368             d = g.getSeconds(),
    369             j += d > 9 ? d: "0" + d;
    370             break;
    371         case "\":
    372             k++,
    373             j += c.timeFormat.charAt(k);
    374             break;
    375         default:
    376             j += i
    377         }
    378         return j
    379     }
    380     function t(a, b) {
    381         if ("" === a || null === a) return null;
    382         if ("object" == typeof a) return 3600 * a.getHours() + 60 * a.getMinutes() + a.getSeconds();
    383         if ("string" != typeof a) return a;
    384         a = a.toLowerCase().replace(/[s.]/g, ""),
    385         ("a" == a.slice( - 1) || "p" == a.slice( - 1)) && (a += "m");
    386         var c = "(" + w.am.replace(".", "") + "|" + w.pm.replace(".", "") + "|" + w.AM.replace(".", "") + "|" + w.PM.replace(".", "") + ")?",
    387         d = new RegExp("^" + c + "([0-9]?[0-9])\W?([0-5][0-9])?\W?([0-5][0-9])?" + c + "$"),
    388         e = a.match(d);
    389         if (!e) return null;
    390         var f = parseInt(1 * e[2], 10);
    391         if (f > 24) {
    392             if (b && b.wrapHours === !1) return null;
    393             f %= 24
    394         }
    395         var g = e[1] || e[5],
    396         h = f;
    397         if (12 >= f && g) {
    398             var i = g == w.pm || g == w.PM;
    399             h = 12 == f ? i ? 12 : 0 : f + (i ? 12 : 0)
    400         }
    401         var j = 1 * e[3] || 0,
    402         k = 1 * e[4] || 0,
    403         l = 3600 * h + 60 * j + k;
    404         if (12 > f && !g && b && b._twelveHourTime && b.scrollDefault) {
    405             var m = l - b.scrollDefault();
    406             0 > m && m >= v / -2 && (l = (l + v / 2) % v)
    407         }
    408         return l
    409     }
    410     function u(a, b) {
    411         return a == v && b.show2400 ? a: a % v
    412     }
    413     var v = 86400,
    414     w = {
    415         am: "am",
    416         pm: "pm",
    417         AM: "AM",
    418         PM: "PM",
    419         decimal: ".",
    420         mins: "mins",
    421         hr: "hr",
    422         hrs: "hrs"
    423     },
    424     x = {
    425         appendTo: "body",
    426         className: null,
    427         closeOnWindowScroll: !1,
    428         disableTextInput: !1,
    429         disableTimeRanges: [],
    430         disableTouchKeyboard: !1,
    431         durationTime: null,
    432         forceRoundTime: !1,
    433         maxTime: null,
    434         minTime: null,
    435         noneOption: !1,
    436         orientation: "l",
    437         roundingFunction: function(a, b) {
    438             if (null === a) return null;
    439             if ("number" != typeof b.step) return a;
    440             var c = a % (60 * b.step),
    441             d = b.minTime || 0;
    442             return c -= d % (60 * b.step),
    443             c >= 30 * b.step ? a += 60 * b.step - c: a -= c,
    444             u(a, b)
    445         },
    446         scrollDefault: null,
    447         selectOnBlur: !1,
    448         show2400: !1,
    449         showDuration: !1,
    450         showOn: ["click", "focus"],
    451         showOnFocus: !0,
    452         step: 30,
    453         stopScrollPropagation: !1,
    454         timeFormat: "g:ia",
    455         typeaheadHighlight: !0,
    456         useSelect: !1,
    457         wrapHours: !0
    458     },
    459     y = {
    460         init: function(b) {
    461             return this.each(function() {
    462                 var e = a(this),
    463                 f = [];
    464                 for (var g in x) e.data(g) && (f[g] = e.data(g));
    465                 var h = a.extend({},
    466                 x, b, f);
    467                 if (h.lang && (w = a.extend(w, h.lang)), h = c(h), e.data("timepicker-settings", h), e.addClass("ui-timepicker-input"), h.useSelect) d(e);
    468                 else {
    469                     if (e.prop("autocomplete", "off"), h.showOn) for (var i in h.showOn) e.on(h.showOn[i] + ".timepicker", y.show);
    470                     e.on("change.timepicker", k),
    471                     e.on("keydown.timepicker", o),
    472                     e.on("keyup.timepicker", p),
    473                     h.disableTextInput && e.on("keydown.timepicker", n),
    474                     k.call(e.get(0), null, "initial")
    475                 }
    476             })
    477         },
    478         show: function(c) {
    479             var e = a(this),
    480             f = e.data("timepicker-settings");
    481             if (c && c.preventDefault(), f.useSelect) return void e.data("timepicker-list").focus();
    482             h(e) && e.blur();
    483             var k = e.data("timepicker-list");
    484             if (!e.prop("readonly") && (k && 0 !== k.length && "function" != typeof f.durationTime || (d(e), k = e.data("timepicker-list")), !b(k))) {
    485                 e.data("ui-timepicker-value", e.val()),
    486                 j(e, k),
    487                 y.hide(),
    488                 k.show();
    489                 var m = {};
    490                 f.orientation.match(/r/) ? m.left = e.offset().left + e.outerWidth() - k.outerWidth() + parseInt(k.css("marginLeft").replace("px", ""), 10) : m.left = e.offset().left + parseInt(k.css("marginLeft").replace("px", ""), 10);
    491                 var n;
    492                 n = f.orientation.match(/t/) ? "t": f.orientation.match(/b/) ? "b": e.offset().top + e.outerHeight(!0) + k.outerHeight() > a(window).height() + a(window).scrollTop() ? "t": "b",
    493                 "t" == n ? (k.addClass("ui-timepicker-positioned-top"), m.top = e.offset().top - k.outerHeight() + parseInt(k.css("marginTop").replace("px", ""), 10)) : (k.removeClass("ui-timepicker-positioned-top"), m.top = e.offset().top + e.outerHeight() + parseInt(k.css("marginTop").replace("px", ""), 10)),
    494                 k.offset(m);
    495                 var o = k.find(".ui-timepicker-selected");
    496                 if (!o.length) {
    497                     var p = t(l(e));
    498                     null !== p ? o = i(e, k, p) : f.scrollDefault && (o = i(e, k, f.scrollDefault()))
    499                 }
    500                 if (o && o.length) {
    501                     var q = k.scrollTop() + o.position().top - o.outerHeight();
    502                     k.scrollTop(q)
    503                 } else k.scrollTop(0);
    504                 return f.stopScrollPropagation && a(document).on("wheel.ui-timepicker", ".ui-timepicker-wrapper",
    505                 function(b) {
    506                     b.preventDefault();
    507                     var c = a(this).scrollTop();
    508                     a(this).scrollTop(c + b.originalEvent.deltaY)
    509                 }),
    510                 a(document).on("touchstart.ui-timepicker mousedown.ui-timepicker", g),
    511                 a(window).on("resize.ui-timepicker", g),
    512                 f.closeOnWindowScroll && a(document).on("scroll.ui-timepicker", g),
    513                 e.trigger("showTimepicker"),
    514                 this
    515             }
    516         },
    517         hide: function(c) {
    518             var d = a(this),
    519             e = d.data("timepicker-settings");
    520             return e && e.useSelect && d.blur(),
    521             a(".ui-timepicker-wrapper").each(function() {
    522                 var c = a(this);
    523                 if (b(c)) {
    524                     var d = c.data("timepicker-input"),
    525                     e = d.data("timepicker-settings");
    526                     e && e.selectOnBlur && q(d),
    527                     c.hide(),
    528                     d.trigger("hideTimepicker")
    529                 }
    530             }),
    531             this
    532         },
    533         option: function(b, e) {
    534             return "string" == typeof b && "undefined" == typeof e ? a(this).data("timepicker-settings")[b] : this.each(function() {
    535                 var f = a(this),
    536                 g = f.data("timepicker-settings"),
    537                 h = f.data("timepicker-list");
    538                 "object" == typeof b ? g = a.extend(g, b) : "string" == typeof b && (g[b] = e),
    539                 g = c(g),
    540                 f.data("timepicker-settings", g),
    541                 k.call(f.get(0), {
    542                     type: "change"
    543                 },
    544                 "initial"),
    545                 h && (h.remove(), f.data("timepicker-list", !1)),
    546                 g.useSelect && d(f)
    547             })
    548         },
    549         getSecondsFromMidnight: function() {
    550             return t(l(this))
    551         },
    552         getTime: function(a) {
    553             var b = this,
    554             c = l(b);
    555             if (!c) return null;
    556             var d = t(c);
    557             if (null === d) return null;
    558             a || (a = new Date);
    559             var e = new Date(a);
    560             return e.setHours(d / 3600),
    561             e.setMinutes(d % 3600 / 60),
    562             e.setSeconds(d % 60),
    563             e.setMilliseconds(0),
    564             e
    565         },
    566         isVisible: function() {
    567             var a = this,
    568             c = a.data("timepicker-list");
    569             return ! (!c || !b(c))
    570         },
    571         setTime: function(a) {
    572             var b = this,
    573             c = b.data("timepicker-settings");
    574             if (c.forceRoundTime) var d = f(t(a), c);
    575             else var d = s(t(a), c);
    576             return a && null === d && c.noneOption && (d = a),
    577             m(b, d),
    578             b.data("timepicker-list") && j(b, b.data("timepicker-list")),
    579             this
    580         },
    581         remove: function() {
    582             var a = this;
    583             if (a.hasClass("ui-timepicker-input")) {
    584                 var b = a.data("timepicker-settings");
    585                 return a.removeAttr("autocomplete", "off"),
    586                 a.removeClass("ui-timepicker-input"),
    587                 a.removeData("timepicker-settings"),
    588                 a.off(".timepicker"),
    589                 a.data("timepicker-list") && a.data("timepicker-list").remove(),
    590                 b.useSelect && a.show(),
    591                 a.removeData("timepicker-list"),
    592                 this
    593             }
    594         }
    595     };
    596     a.fn.timepicker = function(b) {
    597         return this.length ? y[b] ? this.hasClass("ui-timepicker-input") ? y[b].apply(this, Array.prototype.slice.call(arguments, 1)) : this: "object" != typeof b && b ? void a.error("Method " + b + " does not exist on jQuery.timepicker") : y.init.apply(this, arguments) : this
    598     }
    599 });
  • 相关阅读:
    [Functional Programming] Running though a serial number prediction functions for tagging, pairing the result into object
    [Angular] Communicate with Angular Elements using Inputs and Events
    [Tools] Target specific browsers with babel-preset-env and the babel pollyfill (browserslist)
    [Webpack] Externalize Dependencies to be Loaded via CDN with webpack
    [Webpack] Analyze a Production JavaScript Bundle with webpack-bundle-analyzer
    [Algorithm] Largest sum of non-adjacent numbers
    [Angular] Use ngx-build-plus to compile Angular Elements
    [Algorithm] Search for matching words
    Is life always hard?
    poj3177 Redundant Paths
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6422293.html
Copyright © 2020-2023  润新知