NewDAR

update DAR faster

  1. // ==UserScript==
  2. // @name NewDAR
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.5.23
  5. // @description update DAR faster
  6. // @author Conan
  7. // @match https://*.itinerisonline.com/affiliate/
  8. // @require https://code.jquery.com/jquery-2.2.4.min.js
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=itinerisonline.com
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13.  
  14.  
  15. $(document).ready(function() {
  16. 'use strict';
  17. let isExternal=false;
  18. let noteType=0; // noteType: 0:Attx 1:External, 2:Medication
  19. let prts=getPrtsArr();
  20. let attx=[];
  21.  
  22. let attxCode=""
  23. //console.log("11111---------",JSON.stringify(prts[1].noAM?false:true))
  24.  
  25. //jquery extend
  26. $.getUrlParam=function(name){
  27.  
  28. let reStr="",hrefStr=window.location.href;
  29.  
  30. if(hrefStr.indexOf(name)>=0){
  31. reStr=hrefStr.split("?")[1].split(name+"=")[1].split("&")[0]
  32. }
  33.  
  34.  
  35. return reStr
  36. }
  37.  
  38. //add the attendance days button function
  39. $(".footer:first").html($(".footer:first").html()+`<button id='day1' class='attxDay btn btn-primary'>Monday</button>
  40. <button id='day2' class='attxDay btn btn-primary'>Tuesday</button>
  41. <button id='day3' class='attxDay btn btn-primary'>Wednesday</button>
  42. <button id='day4' class='attxDay btn btn-primary'>Thursday</button>
  43. <button id='day5' class='attxDay btn btn-primary'>Friday</button>
  44. <!--<button id="dar" class="hideTable btn btn-primary">switch</button>-->
  45. <button id="External" class="btn btn-success">External</button>
  46. <button id="Medication" class="btn btn-success">Medication</button>
  47. <button id="Acupuncture" class="btn btn-success">Acupuncture</button>
  48. <button id="popOutCode" class="popOutCode btn btn-danger">popOutCode</button>
  49. `)
  50.  
  51. $(".footer:first").html($(".footer:first").html()+`
  52. <div id='hightLightPrt'>
  53. <button id="rt1" class="selectedRoute">1</button>
  54. <button id="rt2" class="selectedRoute">2</button>
  55. <button id="rt3" class="selectedRoute">3</button>
  56. <button id="rt4" class="selectedRoute">4</button>
  57. <button id="rt5" class="selectedRoute">5</button>
  58. <button id="rt6" class="selectedRoute">6</button>
  59. <button id="rt7" class="selectedRoute">7</button>
  60. <button id="rt8" class="selectedRoute">8</button>
  61. <button id="rt9" class="selectedRoute">9</button>
  62. <button id="rt10" class="selectedRoute">10</button>
  63. <button id="rtjow" class="selectedRoute">joe</button>
  64. <button id="rtwilson" class="selectedRoute">wilson</button>
  65. </div>
  66. <div id='mainTable'>
  67. <form><table style="width:100%;font-size:20px;background:#4E2236;color:#4E2236" id="dar_table"></table></form>
  68. </div>`);
  69. $('#hightLightPrt').hide();
  70. let tableInner=`
  71. <tr style="color:#F26363">
  72. <th style="width:3%"><input type="reset" name="prts" id="check_all" value="reset"></th>
  73. <th style="width:7%">Prt ID</th>
  74. <th style="width:15%">Prt Name</th>
  75. <th style="width:10%">A Leg location</th>
  76. <th style="width:10%">B leg Location</th>
  77. <th style="width:10%">Begin Time</th>
  78. <th style="width:10%">End Time</th>
  79. <th style="width:12%">Appt Type</th>
  80. <th style="width:15%">Notes</th>
  81. <th style="width:8%">AM/PM</th>
  82. </tr>`;
  83.  
  84. //fill the prt to the table
  85. console.log(JSON.stringify(prts))
  86. for(let prt of prts){
  87. let temp="<tr class='each_prt' style='background:#E997A7;border-bottom:1px solid #000000'>";
  88. temp+=`<td><input type="checkbox" class="prtBox" name="prts" id="${prt.id}" style="zoom:200%"></td>`;
  89. temp+=`<td class="prt_id_">${prt.id}</td>`;
  90. temp+=`<td>${prt.name}</td>`;
  91. temp+=`<td><input style='background-color:transparent' size='10' type="text" class="A_leg" id="${prt.id}_A_leg_id" value="${prt.address?prt.address:prt.id}"><input type="hidden" class="org_A_lag" value="${prt.address?prt.address:prt.id}"</td>`;
  92. temp+=`<td><input style='background-color:transparent' size='10' type="text" class="B_leg" id="${prt.id}_B_leg_id" value="490078"><br></td>`;
  93. temp+=`<td><input style='background-color:transparent' size='10' class="beginTime" type="text" id="${prt.id}_Begin_Time" value="${prt.amTime?prt.amTime:'10:00'}"></td>`;
  94. temp+=`<td><input style='background-color:transparent' size='10' class="endTime" type="text" id="${prt.id}_End_Time" value="15:30"></td>`;
  95. temp+=`<td><input style='background-color:transparent' class="AppType" type="text" id="${prt.id}_appt_type" value="Center Attendance"></td>`;
  96. temp+=`<td><input style='background-color:transparent' class="prtNote" type="text" id="${prt.id}_note" value="${prt.note?prt.note:''}"></td>`;
  97. temp+=`<td>am:<input style='background-color:transparent;zoom:180%' class="am" type="checkBox" id="${prt.id}_am" ${!prt.noAm?"checked":""}>
  98. pm:<input style='background-color:transparent;zoom:180%' class="pm" type="Checkbox" id="${prt.id}_pm" ${!prt.noPm?"checked":""}></td>`;
  99.  
  100.  
  101. temp+="</tr>";
  102. tableInner+=temp;
  103. }
  104. tableInner+=`<tr><td colspan="8"><button id="submit">submit</button></td></tr>`;
  105.  
  106.  
  107. $("#dar_table").html(tableInner);
  108.  
  109.  
  110. $(".prtBox").click(function(e){
  111.  
  112. let temp = buildPrtList(this.id)
  113.  
  114. if($(this).is(":checked")){
  115. //temp+=(prt.id+'\n')
  116. attx.push(temp);
  117. }else{
  118. attx=attx.filter(p=>p!=temp)
  119. }
  120. //alert(attxList)
  121. $("#pasteArea").val(attx.join("\n"));
  122. attxCode=attx.join("\n");
  123.  
  124. })
  125.  
  126. //add the listener to the button
  127. $(".attxDay").click(function(e){
  128. attxCode=""
  129. let day=this.id.replace("day","")
  130. attx=[];
  131. for(let prt of prts){
  132. let temp = buildPrtList(prt.id)
  133. if(prt.comeDay.indexOf(day)>=0 && !$("#"+prt.id).is(":checked")){
  134. $("#"+prt.id).prop("checked",true)
  135. attx.push(temp);
  136.  
  137. }else{
  138. $("#"+prt.id).prop("checked",false);
  139. attx=attx.filter(p=>p!=temp);
  140. }
  141. }
  142. attxCode=attx.join("\n");
  143. $("#pasteArea").val(attx.join("\n"));
  144. })
  145.  
  146. //Mouseover high light the prt
  147. $(".each_prt").mouseover(function(){
  148. $(this).css("background-color","#F26363");
  149.  
  150. }).mouseout(function(){
  151. $(this).css("background-color","#E997A7");
  152. })
  153.  
  154. //add a button to show and close
  155. $('.hideTable').click(function(e){
  156. let hightLight=$('#hightLightPrt');
  157. let mainTable=$("#mainTable")
  158. if(this.id=="dar"){//switch to be hight Light mode
  159. this.id="hl";
  160. hightLight.show();
  161. mainTable.hide();
  162. }else{//switch to be dar mode
  163. this.id="dar";
  164. mainTable.show();
  165. hightLight.hide();
  166. }
  167. })
  168.  
  169. $('.selectedRoute').click(function(e){
  170. let route=this.id.substr(2,this.id.length);
  171. //console.log(route)
  172. $(".da-pending").css({
  173. background:"white"
  174. });
  175. for(let i=0;i<prts.length;i++){
  176. let obj=prt[i];
  177. //if(obj.name.indexOf()
  178. }
  179. })
  180.  
  181. $("#External").click(function(e){
  182. if(this.innerText==="External"){
  183. $(".each_prt").each(function(){
  184. $(this).find(".AppType")[0].value="External Appointment";
  185. $(this).find(".A_leg")[0].value="490078";
  186. $(this).find(".B_leg")[0].value="";
  187. })
  188. this.innerText="Attendance"
  189. isExternal=true;
  190. noteType=1
  191. }else{
  192. $(".each_prt").each(function(){
  193. $(this).find(".AppType")[0].value="Center Attendance"
  194. $(this).find(".A_leg")[0].value=$(this).find(".org_A_lag")[0].value;
  195. $(this).find(".B_leg")[0].value="490078";
  196. })
  197. this.innerText="External";
  198. isExternal=false;
  199. noteType=0
  200. }
  201.  
  202. })
  203.  
  204. $(".popOutCode").click(function(e){
  205. /*
  206. $("body").prepend(`<div id="pastedButtonDiv"><button id="pastedCode" class="btn btn-success">pastedCode</button></div>`)
  207. $("#pastedCode").css("z-index",999999)
  208. */
  209. $(".btn-block")[0].click()
  210. let createPastedCode = setInterval(function(){
  211. if($("#note_input").length>0){
  212. clearInterval(createPastedCode);
  213. $("#note_input").val(attxCode);
  214. }
  215. },1000)
  216. console.log(attxCode)
  217. })
  218.  
  219. $("#Medication").click(function(e){
  220. if(this.innerText==="Medication"){
  221. $(".each_prt").each(function(){
  222. $(this).find(".AppType")[0].value="Medication";
  223. $(this).find(".B_leg")[0].value="490078";
  224. $(this).find(".A_leg")[0].value=$(this).find(".org_A_lag")[0].value;
  225. $(this).find(".endTime")[0].value="15:29"
  226. $(this).find(".prtNote")[0].value=80
  227. })
  228. this.innerText="Attendance"
  229. isExternal=true;
  230. noteType=2
  231. }else{
  232. $(".each_prt").each(function(){
  233. $(this).find(".AppType")[0].value="Center Attendance"
  234. $(this).find(".A_leg")[0].value=$(this).find(".org_A_lag")[0].value;
  235. $(this).find(".B_leg")[0].value="490078";
  236. $(this).find(".endTime")[0].value="15:30"
  237. $(this).find(".prtNote")[0].value=""
  238. })
  239. this.innerText="Medication";
  240. isExternal=false;
  241. noteType=0
  242. }
  243.  
  244. })
  245.  
  246. $("#Acupuncture").click(function(){
  247. document.getElementById("External").click();
  248. $(".B_leg").val("176624");
  249. $(".beginTime").val("1100");
  250. $(".endTime").val("1300");
  251. $(".AppType").val("Acupuncture");
  252. $(".prtNote").val(" KOKO ");
  253. //isExternal=true;
  254. //noteType=0
  255. })
  256.  
  257. // Function
  258.  
  259. function buildPrtList(prtId){
  260. let tempALeg=[
  261. /*prtId*/ prtId,
  262. /*pickUpTime*/ "",
  263. /*dropOffTime*/ $(`#${prtId}_Begin_Time`).val(),
  264. /*aLegLocId*/ $(`#${prtId}_A_leg_id`).val(),
  265. /*bLegLocId*/ $(`#${prtId}_B_leg_id`).val(),
  266. /*appt_type*/ $(`#${prtId}_appt_type`).val()
  267. ];
  268. let tempBLeg=[
  269. /*prtId*/ prtId,
  270. /*pickUpTime*/ $(`#${prtId}_End_Time`).val(),
  271. /*dropOffTime*/ "",
  272. /*aLegLocId*/ $(`#${prtId}_B_leg_id`).val(),
  273. /*bLegLocId*/ $(`#${prtId}_A_leg_id`).val(),
  274. /*appt_type*/ $(`#${prtId}_appt_type`).val()
  275. ];
  276. //alert($("#External").innerText)
  277. if(noteType==1){
  278. tempALeg.push(
  279. /*note*/ $(`#${prtId}_note`).val()
  280. )
  281. tempBLeg.push(
  282. /*note*/ $(`#${prtId}_note`).val()
  283. )
  284. }else if(noteType==2){
  285.  
  286. tempALeg.push(
  287. /*note*/ "80"
  288. )
  289. tempBLeg.push(
  290. /*note*/ "80"
  291. )
  292. }else{
  293. tempALeg.push("")
  294. tempBLeg.push("")
  295. }
  296.  
  297. let returnStrAM=$("#"+prtId+"_am").is(":checked")?tempALeg.join('\t')+"\n":"";
  298. let returnStrPM=$("#"+prtId+"_pm").is(":checked")?tempBLeg.join('\t'):"";
  299.  
  300.  
  301. return noteType==2?tempBLeg.join('\t'):(returnStrAM+returnStrPM)
  302. }
  303.  
  304.  
  305.  
  306. });