1/* 2 * Title : Pinpoint Booking System 3 * File : application/assets/js/calendars/calendar-day.js 4 * Author : Dot on Paper 5 * Copyright : © 2017 Dot on Paper 6 * Website : https://www.dotonpaper.net 7 * Description : Calendar day JavaScript class. 8 */ 9 10DOT.methods.calendar_day = new function(){ 11 'use strict'; 12 13 /* 14 * Private variables. 15 */ 16 var $ = jQuery.noConflict(); 17 18 /* 19 * Constructor 20 * 21 * @usage 22 * The constructor is called when a class instance is created. 23 * 24 * @params 25 * - 26 * 27 * @post 28 * - 29 * 30 * @get 31 * - 32 * 33 * @sessions 34 * - 35 * 36 * @cookies 37 * - 38 * 39 * @constants 40 * - 41 * 42 * @globals 43 * - 44 * 45 * @functions 46 * - 47 * 48 * @hooks 49 * - 50 * 51 * @layouts 52 * - 53 * 54 * @return 55 * - 56 * 57 * @return_details 58 * - 59 * 60 * @dv 61 * - 62 * 63 * @tests 64 * - 65 */ 66 this.__construct = function(){ 67 }; 68 69 /* 70 * Get default day data. 71 * 72 * @usage 73 * - 74 * 75 * @params 76 * - 77 * 78 * @post 79 * - 80 * 81 * @get 82 * - 83 * 84 * @sessions 85 * - 86 * 87 * @cookies 88 * - 89 * 90 * @constants 91 * - 92 * 93 * @globals 94 * - 95 * 96 * @functions 97 * - 98 * 99 * @hooks 100 * - 101 * 102 * @layouts 103 * - 104 * 105 * @return 106 * Default day data. 107 * 108 * @return_details 109 * - 110 * 111 * @dv 112 * - 113 * 114 * @tests 115 * - 116 */ 117 this.default = function(){ 118 return {"available": 0, 119 "bind": 0, 120 "hours_definitions": [{"value": "00:00"}], 121 "hours": {}, 122 "info": "", 123 "info_body": "", 124 "info_tooltip": "", 125 "notes": "", 126 "price": 0, 127 "promo": 0, 128 "status": "none"}; 129 }; 130 131 /* 132 * Get day data. 133 * 134 * @usage 135 * - 136 * 137 * @params 138 * id (Number): calendar ID 139 * date (String): date in "YYYY-MM-DD" format 140 * 141 * @post 142 * - 143 * 144 * @get 145 * - 146 * 147 * @sessions 148 * - 149 * 150 * @cookies 151 * - 152 * 153 * @constants 154 * - 155 * 156 * @globals 157 * DOT.methods.calendar_schedule.data (Array): calendar schedule 158 * 159 * @functions 160 * this : unavailable() // Get unavailable day data. 161 * this : weekday() // Get weekday. 162 * 163 * @hooks 164 * - 165 * 166 * @layouts 167 * - 168 * 169 * @return 170 * Day data. 171 * 172 * @return_details 173 * - 174 * 175 * @dv 176 * - 177 * 178 * @tests 179 * - 180 */ 181 this.get = function(id, 182 date){ 183 var weekday = DOT.methods.calendar_day.weekday(date); 184 185 /* 186 * Verify if weekday is available, if not return an unavailable day. 187 */ 188 if (!DOT.methods.calendar_days.settings[id].available[weekday]){ 189 return DOT.methods.calendar_day.unavailable(); 190 } 191 192 /* 193 * Verify if day is set in schedule, if yes return it. 194 */ 195 if (DOT.methods.calendar_schedule.data[id][date] !== undefined && DOT.methods.calendar_schedule.data[id][date] !== null){ 196 return DOT.methods.calendar_schedule.data[id][date]; 197 } 198 199 /* 200 * Return default schedule. 201 */ 202 return DOT.methods.calendar_schedule.default[id]; 203 }; 204 205 /* 206 * Get unavailable day data. 207 * 208 * @usage 209 * - 210 * 211 * @params 212 * - 213 * 214 * @post 215 * - 216 * 217 * @get 218 * - 219 * 220 * @sessions 221 * - 222 * 223 * @cookies 224 * - 225 * 226 * @constants 227 * - 228 * 229 * @globals 230 * - 231 * 232 * @functions 233 * - 234 * 235 * @hooks 236 * - 237 * 238 * @layouts 239 * - 240 * 241 * @return 242 * Unavailable day data. 243 * 244 * @return_details 245 * 246 * 247 * @dv 248 * - 249 * 250 * @tests 251 * - 252 */ 253 this.unavailable = function(){ 254 return {"available": 0, 255 "bind": 0, 256 "hours_definitions": [{"value": "00:00"}], 257 "hours": {}, 258 "info": "", 259 "info_body": "", 260 "info_tooltip": "", 261 "notes": "", 262 "price": 0, 263 "promo": 0, 264 "status": "unavailable"}; 265 }; 266 267 /* 268 * Get weekday. 269 * 270 * @usage 271 * - 272 * 273 * @params 274 * date (String): date in "YYYY-MM-DD" format 275 * 276 * @post 277 * - 278 * 279 * @get 280 * - 281 * 282 * @sessions 283 * - 284 * 285 * @cookies 286 * - 287 * 288 * @constants 289 * - 290 * 291 * @globals 292 * - 293 * 294 * @functions 295 * - 296 * 297 * @hooks 298 * - 299 * 300 * @layouts 301 * - 302 * 303 * @return 304 * Weekday index. 305 * 306 * @return_details 307 * [weekday index] : [day] 308 * 309 * 0 : Sunday 310 * 1 : Monday 311 * 2 : Tuesday 312 * 3 : Wednesday 313 * 4 : Thursday 314 * 5 : Friday 315 * 6 : Saturday 316 * 317 * @dv 318 * - 319 * 320 * @tests 321 * - 322 */ 323 this.weekday = function(date){ 324 var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], 325 datePieces = date.split('-'), 326 year = datePieces[0],
327 month = datePieces[1], 328 day = datePieces[2], 329 dateFull = new Date(eval('"'+day+' '+months[parseInt(month, 10)-1]+', '+year+'"')); 330 331 return dateFull.getDay(); 332 }; 333 334 return this.__construct(); 335};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.