├── cache └── index.php ├── alma_hours_widget.css ├── LICENSE ├── alma_hours_widget.js ├── readme.md └── alma_hours_widget.php /cache/index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /alma_hours_widget.css: -------------------------------------------------------------------------------- 1 | .alma_hours_widget {display:none; float:left; border-top-left-radius: 5px; border-top-right-radius: 5px;} 2 | .alma_hours_widget_title {background-color:darkred; color:white; text-align:center; padding:10px; font-size:24px; border-top-left-radius: 5px; border-top-right-radius: 5px;} 3 | .alma_hours_list {list-style-type: none; padding:0; margin:0;} 4 | .alma_hours_row {background-color:brown; color:white; padding:4px 10px; margin:1px 0;} 5 | .alma_hours_row_date {margin-right:10px;} 6 | .alma_hours_row_open {margin-right:5px;} 7 | .alma_hours_row_close {margin-left:5px;} -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Portland State University Library 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /alma_hours_widget.js: -------------------------------------------------------------------------------- 1 | /* ALMA HOURS WIDGET */ 2 | 3 | /* requires jQuery library */ 4 | 5 | var script_path = "alma_hours_widget.php"; 6 | 7 | jQuery(document).ready(function(){ 8 | // load all widgets 9 | jQuery(".alma_hours_widget").each(function(){ 10 | 11 | // extract html5 parameters for widgets 12 | var input_library = jQuery(this).attr("data-library"); 13 | var input_title = jQuery(this).attr("data-title"); 14 | var input_start_date = jQuery(this).attr("data-start-date"); 15 | var input_end_date = jQuery(this).attr("data-end-date"); 16 | var input_date_format = jQuery(this).attr("data-date-format"); 17 | var input_time_format = jQuery(this).attr("data-time-format"); 18 | var widget = $(this); 19 | 20 | // console.log(" | " + input_library + " | " + input_start_date + " | " + input_end_date + " | " + input_date_format + " | " + input_time_format); 21 | 22 | // load hours 23 | $.getJSON( script_path, { library: input_library, from: input_start_date, to: input_end_date, date_format: input_date_format, time_format: input_time_format } ) 24 | .done(function( json ) { 25 | var widget_days = []; 26 | $.each(json,function(date,day) { 27 | if(day.closed) 28 | widget_days.push( "
  • "+day.date+"Closed
  • "); 29 | else if(day.open24hours) 30 | widget_days.push( "
  • "+day.date+"Open 24 Hours
  • "); 31 | else 32 | { 33 | var hours_html = ""; 34 | $.each(day.hours,function(index,hours) { 35 | if(hours_html == "") 36 | hours_html = "" + hours.open + "-" + hours.close + ""; 37 | else 38 | hours_html += ", " + hours.open + "-" + hours.close + ""; 39 | }); 40 | widget_days.push( "
  • "+day.date+""+hours_html+"
  • " ); 41 | } 42 | }); 43 | $(widget).html($( "