console log

by aidankirrane

HTML

<div id="console-log"></div>
<table border="0" width="100%">
  <tr>
    <td>
      <label class="label">Shift Start</label>
      <select id="shiftStart" >
             </select>
    </td>
    <td>
      <label class="label">Shift End</label>
      <select id="shiftEnd" >
             </select>
    </td>
    </tr>
    <tr>
    <td>
      <label class="label">SERVERShiftStart</label>
      <br> I a hidden field should be set by whatever is from server <br>if I exist and les sthan 24 hr otehrwis eset by client
      <input id="defaultShiftStart"  value="2018-09-06 12:05">
             </input>
    </td>
    <td>
      <label class="label">definedShiftStart</label>
      <br> SHIFT END from server
      <input id="defaultShiftEnd"  value="2018-09-06 21:11">
             </input>
    </td>
    <td>
      <label class="label">defaultShiftStart</label>
      <input id="defaultShiftDuration" value="08:00"></input>
    </td>
    <td>
      <label class="label">Shift Duration</label>
      <select id="shiftDuration" data-mini="true">
                <option value="00:01">00h 1m</option>
                <option value="00:15">00h 15m</option>
                <option value="00:30">00h 30m</option>
                <option value="00:45">00h 45m</option>
                <option value="01:00">01h 00m</option>
                <option value="01:15">01h 15m</option>
                <option value="01:30">01h 30m</option>
                <option value="01:45">01h 45m</option>
                <option value="02:00">02h 00m</option>
                <option value="02:15">02h 15m</option>
                <option value="02:30">02h 30m</option>
                <option value="02:45">02h 45m</option>
                <option value="03:00">03h 00m</option>
                <option value="03:15">03h 15m</option>
                <option value="03:30">03h 30m</option>
                <option value="03:45">03h 45m</option>
                <option value="04:00">04h 00m</option>
               ...

CSS

.console-line {
  font-family: monospace;
  margin: 2px;
}

JavaScript

//NEW DIV TO HTML <div id="console-log"></div>

var consoleLine = "<p class=\"console-line\"></p>";
console = {
  log: function(text) {
    $("#console-log").append($(consoleLine).html(text));
 }
};
console.log("TEST Console Replaced")


//window.onload = function () {
//    if (localStorage.getItem("hasUPRunBefore") === null) {
//        localStorage.setItem("hasUPRunBefore", true);
//    }
//}

var d = new Date();

console.log(d)

function formatShiftStart(d) {

  var m_names = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
  
  return right("0" + d.getDate(), 2) + '-' + m_names[d.getMonth()] + '-' + d.getFullYear() + ' ' + right("0" + d.getHours(), 2) + ':' + right("0" + d.getMinutes(), 2);


}
function setOptionValue(optionId, sValue) {
   $("#" + optionId + " option[value='" + sValue + "']").attr('selected', "true");
  // $("#" + optionId).selectmenu('refresh', true);
}
       
function roundTimeQuarterHour(time) {
    var timeToReturn = new Date(time);
    timeToReturn.setMilliseconds(Math.round(time.getMilliseconds() / 1000) * 1000);
    timeToReturn.setSeconds(Math.round(timeToReturn.getSeconds() / 60) * 60);
    timeToReturn.setMinutes(Math.round(timeToReturn.getMinutes() / 15) * 15);
    return timeToReturn;
}

function right(s, n) {
    return s.slice(n * -1);
}
Date.prototype.addHours = function(h) {
    this.setTime(this.getTime() + (h * 60 * 60 * 1000));
    return this;
}

Date.prototype.addMinutes = function(m) {
    this.setTime(this.getTime() + (m * 60 * 1000));
    return this;
}

function isEmpty(str) {
    return (!str || 0 === str.length);
}

if (!String.prototype.startsWith) {
    String.prototype.startsWith = function(searchString, position){
      position = position || 0;
      return this.substr(position, searchString.length) === searchString;
  };
}
       

function loadShiftStart() {
  try {
    var pShiftStart;
    

    
    var pDate = roundTimeQuarterHour(new Date());
    var...