Code

HTML Schedule

HTML Schedule

Milbytes Schedule

Milbytes Schedule has been built with HTML5, CSS3 and Javascript. This control allows you to visualize events in a grid inside your web page. It has many parameters to define its behavior, visualization and you can capture actions generated when you interact with the elements of the schedule.

HTML Schedule - 1 HTML Schedule - 2

The code

– HTML5 & CSS3
– Javascript (You do not need the jQuery library)

The JavaScript code is in the file schedule_week_class.js and the styles used in the file schedule_week.css

The code used can be easily understood and stands out for its simplicity.

Use of external scripts

– Bootstrap : Bootstrap is an open source toolkit for developing with HTML, CSS, and Javascript. Version 4.3.0 from February 2019.
– Moment.js : JavaScript library to parse, validate, manipulate, and display dates and times. Version 2.24.0 from January 2019.

Data

The data to show in the schedule is passed to the control in JSON format. This data can have the origin in an Ajax request to the server or saved in a Javascript variable.

Control configuration

Once the web page is loaded you can dynamically create the time control and assign it to a specific DIV element.
It has a large number of options and events that you can use or not depending on your needs.

  • cfg_start_date : Indicates the first day.
  • cfg_title : Text in the title.
  • cfg_header_column_date_format : Date format in the header of the day column.
  • cfg_number_of_days : Number of days (columns). The value to show a week would be 7.
  • cfg_num_pixels_cell_height_px : Number of pixels of the height of each cell hour.
  • cfg_num_minutes_interval : Number of minutes represented in each cell hour.
  • cfg_num_cells_height_default : Number of cells default time in case of not having the number of elements of the element to be displayed.
  • cfg_bool_approach_time : Boolean value true/false. Make an approximation to the nearest hour if you can not find a time cell with a specific time. For example, approximate 14:05 to 14:00.
    If the value of this parameter is false, then the element will not be shown if the cell with the exact time does not exist.
  • cfg_event_accions : Name of the Javascript function that must be executed when performing an action in the schedule.
  • cfg_event_click_element : Name of the Javascript function that must be executed when a element is clicked.
  • cfg_event_doubleclick_cell : Name of the Javascript function handles a double clicking action on a cell.
  • cfg_bool_allow_drag_and_drop : Boolean value true/false. Execute a JavaScript function when performing a drag & drop a element.
  • cfg_event_drag_and_drop : Name of the Javascript function handles a drag & drop action..
  • cfg_time_start : Start time. Formatted text “HH:mm”
  • cfg_time_end : End time. Formatted text “HH:mm”
  • cfg_item_default_background_color : RGB color by default of an element. Default : gray color (202020)
  • cfg_cell_hour_format : Text that indicates the time format in the cells of the schedule. Default HH:mm
  • cfg_bool_show_btns_clear_fill : Boolean value true/false. Show or not the buttons to clear or fill the items in the schedule.
  • cfg_bool_style_weekend : Boolean value true/false. Apply a different style for the columns of the weekend.


  • Example JavaScript code for initializing a schedule in the DIV element with id ‘id_div_schedule’.

    var l_obj_data_aux = moment(); var l_parameters = {  cfg_start_date : l_obj_data_aux,  cfg_title : "Schedule 2 Week",  cfg_header_column_date_format :'DD-MM-YYYY',  cfg_number_of_days : 7,  cfg_num_pixels_cell_height_px : 24,  cfg_num_minutes_interval : 60,  cfg_num_cells_height_default : 4,  cfg_bool_approach_time : true,  cfg_event_click_element : event_click_element,  cfg_event_doubleclick_cell : event_doubleclick_cell,  cfg_event_accions : event_schedule_action,  cfg_bool_allow_drag_and_drop : false,  cfg_event_drag_and_drop : null,  cfg_time_start : "09:00",  cfg_time_end : "21:00",  cfg_item_default_background_color : "000000",  cfg_cell_hour_format : "hh:mm A",  cfg_bool_show_btns_clear_fill : true,  cfg_bool_style_weekend : true }; var g_obj_SCHEDULE = new Schedule_Class(<b>'id_div_schedule'</b>); g_obj_SCHEDULE.cm_initialize(l_parameters, event_schedule_loaded); function event_schedule_loaded(p_id_container) {  g_obj_SCHEDULE.cm_build();  g_obj_SCHEDULE.cm_set_json_data(g_json_data);  g_obj_SCHEDULE.cm_items_show(); }

    Functions to handle events

    The class schedule contains some functions to prepare the control and functions to handle the events that occur.

    • cm_initialize(p_list_keys_values_p_config, p_function_callback) : Initialize control.
    • cm_set_json_data(p_json_schedule_elements) : Assign data elements. JSON Format

    • cm_items_show() : Show items.

    • cm_items_clear() : Clear items.

    • cm_get_json_data() : Get JSON data from schedule.

    • cm_set_spinner_visible(p_boolean_is_visible) : Show / Hide loading spinner.

    JSON

    Review the example schedules on the demo page to get more information.

    - required atributes
    id : unique identifier,
    date_sql : string represents a date-time format yyyy-mm-dd hh:mm,

    - optional atributes
    text : text in the div
    minutes : number of minutes
    color : rgb code (example FF0000) is the color of the item in the schedule

    - other atributes
    atribute1, atribute2, ...

    Example JSON data:

    {‘id’:’c0010’,’text’:’Item 10’,’date_sql’:’2019-03-21 14:30’,’minutes’:30}
    {‘id’:’c0011’,’text’:’Item 11’,’date_sql’:’2019-02-21 10:30’,’minutes’:120}
    {‘id’:’c0012’,’text’:’Item 12’,’date_sql’:’2019-03-18 10:45’,’minutes’:90}

 

Features

  • Show events in a schedule
  • Capture actions
  • JSON Data
  • Drag & Drop (even between different schedules)
  • Fully customizable & easy integration
  • No JQuery
  • Example demo included
  • NO installation. Just open index.html in the browser.

Compatible browsers

IE11, Firefox, Safari, Opera, Chrome, Edge. Android & IOS Browsers.

Changelog

12 Feb, 2019 – Version 1.0 released

Screenshots

HTML Schedule - 3 HTML Schedule - 4 HTML Schedule - 5 HTML Schedule - 6
by
by
by
by
by
by