Kapi Hospital Helper

A UserScript that's made to help you play!

  1. // ==UserScript==
  2. // @name Kapi Hospital Helper
  3. // @description A UserScript that's made to help you play!
  4. // @date 19.07.2015
  5. // @version 2.4.8.9
  6. // @author IreuN
  7. // @include http://*kapihospital.com/*
  8. // @grant GM_getValue
  9. // @grant GM_setValue
  10. // @grant GM_addStyle
  11. // @grant GM_xmlhttpRequest
  12. // @require http://code.jquery.com/jquery-2.1.4.min.js
  13. // @namespace https://greasyfork.org/users/5507
  14. // @supportURL https://github.com/ireun/Kapi-Hospital-Berater/issues
  15. // ==/UserScript==
  16.  
  17. window.addEventListener("load", function () {
  18.  
  19. var info = "[Helper] ";
  20.  
  21. console.log( info + "Start");
  22.  
  23. // Special Characters - DE
  24. var ae_de = "\u00E4"; // ä
  25. var oe_de = "\u00F6"; // ö
  26. var ue_de = "\u00FC"; // ü
  27. var Ae_de = "\u00C4"; // Ä
  28. var Oe_de = "\u00D6"; // Ö
  29. var Ue_de = "\u00DC"; // Ü
  30. var sz_de = "\u00DF"; // ß
  31.  
  32. // Special Characters - PL
  33. var a_pl = "\u0105"; // ą
  34. var c_pl = "\u0107"; // ć
  35. var e_pl = "\u0119"; // ę
  36. var l_pl = "\u0142"; // ł
  37. var n_pl = "\u0144"; // ń
  38. var o_pl = "\u00F3"; // ó
  39. var s_pl = "\u015B"; // ś
  40. var z_pl = "\u017C"; // ź
  41. var x_pl = "\u017A"; // ż
  42.  
  43. // Special Characters - CZ
  44. var a_cz = "\u00E1"; // á
  45. var c_cz = "\u010D"; // č
  46. var d_cz = "\u010F"; // ď
  47. var e_cz = "\u00E9"; // é
  48. var i_cz = "\u00ED"; // í
  49. var o_cz = "\u00F3"; // ó
  50. var r_cz = "\u0159"; // ř
  51. var s_cz = "\u0161"; // š
  52. var t_cz = "\u0165"; // ť
  53. var u_cz = "\u00FA"; // ú
  54. var y_cz = "\u00FD"; // ý
  55. var z_cz = "\u017E"; // ž
  56. var e2_cz = "\u011B"; // ě
  57. var u2_cz = "\u016F"; // ů
  58. var u3_cz = "\u00DA"; // Ú
  59.  
  60. // global definitions
  61. var texte = {};
  62. var medi = {};
  63.  
  64. var reg2 = /http:\/\/(s\d+\.|www\.|)kapihospital\.com\/(.*)/i;
  65. var delimThou = ".";
  66. var regDelimThou = /\./g;
  67. var delimDeci = ",";
  68. var regDelimDeci = /,/;
  69.  
  70. var ccode = [
  71. ["de", "de", ".de.kapihospital.com"],
  72. ["en", "uk", ".uk.kapihospital.com"],
  73. ["en", "uk", ".uk.kapihospital.com"],
  74. ["en", "nl", ".nl.kapihospital.com"],
  75. ["en", "fr", ".fr.kapihospital.com"],
  76. ["en", "tr", ".tr.kapihospital.com"],
  77. ["en", "bg", ".bg.kapihospital.com"],
  78. ["en", "es", ".es.kapihospital.com"],
  79. ["pl", "pl", ".pl.kapihospital.com"],
  80. ["en", "ro", ".ro.kapihospital.com"],
  81. ["en", "ru", ".ru.kapihospital.com"],
  82. ["cz", "cz", ".cz.kapihospital.com"],
  83. ["en", "se", ".se.kapihospital.com"],
  84. ["en", "pt", ".pt.kapihospital.com"],
  85. ["en", "hu", ".hu.kapihospital.com"],
  86. ["en", "gr", ".gr.kapihospital.com"],
  87. ["en", "us", ".us.kapihospital.com"],
  88. ["en", "it", ".it.kapihospital.com"],
  89. ["en", "dk", ".dk.kapihospital.com"],
  90. ["en", "br", ".br.kapihospital.com"],
  91. ["en", "ir", ".ir.kapihospital.com"],
  92. ["en", "no", ".no.kapihospital.com"],
  93. ["en", "ae", ".ae.kapihospital.com"]];
  94.  
  95. var lng;
  96. var reg;
  97. var gamepages = {};
  98.  
  99. ccode.forEach(function (ccode) {
  100. if (document.location.href.search(ccode[1] + ".kapihospital.com") != -1) {
  101. lng = ccode[0];
  102. reg = new RegExp("http://s(\\d+)\\." + ccode[1] + "\\.kapihospital\\.com/(.*?)\\.php(.*)", "i");
  103. gamepages[ccode[1]] = "http://www" + ccode[2];
  104. console.log( info + "Setting language: " + lng);
  105. loadLanguage(lng);
  106. }
  107. });
  108. //***********************************************************************************************************
  109.  
  110. var scriptUrl = "https://greasyfork.org/scripts/5182-kapi-hospital-berater";
  111. var Global = unsafeWindow.Global;
  112. var loc = reg.exec(document.location.href);
  113. var all = document.getElementsByTagName("body")[0];
  114. var now = Math.floor((new Date()).getTime() / 1000);
  115. var nie = 2147483000;
  116. var questcnt = 0;
  117.  
  118. var server = "";
  119. var page = "";
  120. var pageZusatz = "";
  121. var developer = true;
  122. var candtable = document.getElementsByTagName("table");
  123. var username = "";
  124.  
  125. var valRackLimit = "";
  126. var valMaxRackLimit = "";
  127. var valGlobalClockInTitle = "";
  128. var questTime = "";
  129. var valStartQuestAutomatic = false;
  130. var logindata = [];
  131.  
  132.  
  133. if (loc) {
  134. server = loc[1];
  135. page = loc[2];
  136. pageZusatz = loc[3];
  137. developer = (pageZusatz == "?dev");
  138. candtable = document.getElementsByTagName("table");
  139. username = GM_getValue(lng + "_" + server + "_username", "");
  140.  
  141. switch (page) {
  142. case "main":
  143. do_main();
  144. break;
  145.  
  146. case "logout":
  147. do_login();
  148. break;
  149. }
  150. }
  151. else {
  152. do_login();
  153. }
  154.  
  155.  
  156. //***********************************************************************************************************
  157.  
  158. function do_main() {
  159.  
  160. console.log( info + "Start do_main()");
  161. //if (!username) document.location.href = "http://www"+gamepage;
  162. // CSS
  163. GM_addStyle("tr:hover{background-color:lightblue;}");
  164. GM_addStyle("table.hoveryellow tr:hover{background-color:yellow;}");
  165. GM_addStyle("div.hoverlightblue:hover{background-color:lightblue;}");
  166. GM_addStyle("div.hoverblue:hover{background-color:blue;}");
  167. GM_addStyle("#quicklinks{position:fixed;right:-100px;top:0px;width:100px;height:100%;padding-left:15px;background-color:#999;z-index:200;}");
  168. GM_addStyle("#quicklinks:hover{right:0px;!important}");
  169. GM_addStyle("#quicklinks>div{float:left;}");
  170. GM_addStyle("#quicklinks>div>div{position:relative;width:50px;height:50px;}");
  171. GM_addStyle(".miniicon{font-weight:bold;padding:2px;border:1px inset white;}");
  172. GM_addStyle(".allcured{border:3px solid green!important;}");
  173. GM_addStyle(".needminitreatment{border:3px solid yellow;border-left:3px solid yellow!important;}");
  174. GM_addStyle(".unhealable{border:3px solid red;border-top:3px solid red!important;border-right:3px solid red!important;}");
  175. GM_addStyle(".racklow{" + GM_getValue(lng + "_" + server + "_" + username + "_css_racklow", "background-color:orangered;") + "}");
  176. GM_addStyle(".cursorstandard{ cursor: default!important;}");
  177.  
  178. console.log( info + "Updatecheck");
  179. if (GM_getValue("valUpdate", true)) {
  180. valLastUpdate = GM_getValue("valLastUpdate", "");
  181. if (valLastUpdate == "") {
  182. GM_xmlhttpRequest({
  183. method: "GET",
  184. url: "https://greasyfork.org/scripts/5182-kapi-hospital-berater/code/Kapi%20Hospital%20Berater.meta.js",
  185. onload: function (response) {
  186. keyusoversion = /uso:version\s+(\d+)/;
  187. serverversion = keyusoversion.exec(response.responseText)[1];
  188. GM_setValue("valLastUpdate", serverversion);
  189. }
  190. });
  191. } else {
  192. GM_xmlhttpRequest({
  193. method: "GET",
  194. url: "https://greasyfork.org/scripts/5182-kapi-hospital-berater/code/Kapi%20Hospital%20Berater.meta.js",
  195. onload: function (response) {
  196. keyusoversion = /uso:version\s+(\d+)/;
  197. serverversion = keyusoversion.exec(response.responseText)[1];
  198. if (valLastUpdate != serverversion) {
  199. GM_setValue("valLastUpdate", serverversion);
  200. if (confirm(texte["confirmUpdate"])) {
  201. document.location.href = "https://greasyfork.org/scripts/5182-kapi-hospital-berater/code/Kapi%20Hospital%20Berater.user.js";
  202. }
  203. }
  204. }
  205. });
  206. }
  207. }
  208.  
  209. var documentTitle = document.title;
  210. try {
  211. var maincontainer = $("border4").parentNode;
  212. } catch (err) {
  213. var maincontainer = all;
  214. }
  215. try {
  216. var werbecontainer = document.getElementsByTagName("form")[0].parentNode;
  217. } catch (err) {
  218. var werbecontainer = all;
  219. }
  220.  
  221. var lastXmlRequest = 0;
  222.  
  223. var rooms = [];
  224. var patients = [];
  225. var roomTimes = {};
  226.  
  227. roomTimes["global"] = [0, 0];
  228. roomTimes["allrooms"] = [0, 0];
  229. roomTimes["emptyrooms"] = [0, 0];
  230.  
  231.  
  232. for (var v in Global.availableMedics[0]) {
  233. medi[Global.availableMedics[0][v]["diseases"]] = Global.availableMedics[0][v];
  234. }
  235. var cand = document.getElementsByClassName("room");
  236.  
  237. valRackLimit = GM_getValue(lng + "_" + server + "_" + username + "_valRackLimit", 50);
  238. valMaxRackLimit = GM_getValue(lng + "_" + server + "_" + username + "_valMaxRackLimit", 100);
  239. valGlobalClockInTitle = GM_getValue(lng + "_" + server + "_" + username + "_valGlobalClockInTitle", true);
  240. questTime = GM_getValue(lng + "_" + server + "_" + username + "_questTime", 0);
  241. valStartQuestAutomatic = GM_getValue(lng + "_" + server + "_" + username + "_valStartQuestAutomatic", true);
  242.  
  243. if (developer) {
  244. createElement("div", {
  245. id: "help1",
  246. style: "z-index:2;position:absolute;top:15px;left:0px;background-color:#CCC;border:2px solid black;padding:3px;"
  247. }, all);
  248. }
  249.  
  250. console.log( info + "Points");
  251. // punkte
  252. GM_xmlhttpRequest({
  253. method: "GET",
  254. url: "service.help.php?mode=level",
  255. // synchronous: true,
  256. onload: function (response) {
  257. var text = JSON.parse(response.responseText);
  258. var dom = (new DOMParser()).parseFromString(text["message"], "text/xml");
  259. var tbdy = dom.getElementsByTagName("tbody").item(0);
  260. var tz = tbdy.getElementsByTagName("tr");
  261.  
  262.  
  263. $("pkt").addEventListener("mouseover", function () {
  264. var punkte = parseInt(this.innerHTML.replace(/\./g, ""), 10);
  265.  
  266. for (var z = 0; z < tz.length; z++) {
  267. if (punkte < parseInt(tz.item(z).getElementsByTagName("td").item(1).textContent.replace(/\./g, ""), 10)) {
  268. break;
  269. }
  270.  
  271. this.title = texte["noch"] + " " + number_format(parseInt(tz.item(z).getElementsByTagName("td").item(1).textContent.replace(/\./g, ""), 10) - punkte);
  272. }
  273. }, false);
  274. }
  275. });
  276.  
  277. patientDiseases = {};
  278. console.log( info + "patientDiseases");
  279. // patientDiseases[patientId][diseaseNr]: heartbeat,cured,notreatment,comesnext,""=ill
  280. // patientDiseases[patientId][room]: current room (type)
  281. // patientDiseases[patientId][floor]: current floor
  282. // patientDiseases[patientId][roomX]: needed room to go (type)
  283. // patientDiseases[patientId][m]: count of needed minitreatments
  284. // patientDiseases[patientId][state]: 0=waitingroom,1=bed,2=nurse,3=in room,4=treatment,5=cured
  285. // patientDiseases[patientId][unhealable]: if not healable
  286. /*try{ patientDiseases = explode(GM_getValue(lng+"_"+server+"_"+username+"_patientDiseases","{}")); }catch(err){}
  287.  
  288. for(var pat in patientDiseases)
  289. {
  290. if(!Global.refPatients.get("p"+pat)){ delete patientDiseases[pat]; }
  291. else {
  292. if(!patientDiseases[pat]["state"]){ patientDiseases[pat]["state"]=1; }
  293. if(!patientDiseases[pat]["room"]){ patientDiseases[pat]["room"]=6; }
  294. if(!patientDiseases[pat]["floor"]){ patientDiseases[pat]["floor"]=1; }
  295. }
  296. }*/
  297.  
  298. console.log( info + "For non Premium Players, read patient stats from Server");
  299. if (!Global.ISPREMIUM) {
  300. console.log( info + "User not premium");
  301. var patids = Global.refPatients.values();
  302. /*for (var v = 0; v < patids.length; v++) {
  303. refreshPatient(patids[v]["id"], false);
  304. }*/
  305. }
  306.  
  307. if (developer) {
  308. console.log( info + "You are a developer");
  309. $("garten_komplett").addEventListener("mouseover", function (event) {
  310. $("help1").innerHTML = "";
  311. var roomId = 0;
  312. var patientId = 0;
  313. if (!isNaN(event.target.id.replace("r", ""))) {
  314. roomId = event.target.id.replace("r", "");
  315. patientId = Global.refRooms.get(event.target.id).patient;
  316. }
  317. else if (!isNaN(event.target.id.replace("p", ""))) {
  318. roomId = (Global.refPatients.get(event.target.id).room + "").replace("r", "");
  319. patientId = event.target.id.replace("p", "");
  320. }
  321. if (patientId != 0) {
  322. var help = Global.refPatients.get("p" + patientId);
  323. for (var v in help) {
  324. if (typeof(help[v]) != "function") {
  325. $("help1").innerHTML += "<br>" + v + " : " + help[v];
  326. }
  327. }
  328. $("help1").innerHTML += "<br>";
  329. if (patientDiseases[patientId]) {
  330. for (var v in patientDiseases[patientId]) {
  331. $("help1").innerHTML += "<br>" + v + " : " + patientDiseases[patientId][v];
  332. }
  333. }
  334.  
  335. $("help1").innerHTML += "<br>"
  336. }
  337. if (roomId != 0) {
  338. var help = Global.refRooms.get("r" + roomId);
  339. for (var v in help) {
  340. if (typeof(help[v]) != "function") {
  341. $("help1").innerHTML += "<br>" + v + " : " + help[v];
  342. }
  343. //else $("help1").innerHTML += "<br>"+v+" : Fkt";
  344. }
  345. $("help1").innerHTML += "<br>";
  346. var help = Global.availableRooms[help["roomid"]];
  347. for (var v in help) {
  348. if (typeof(help[v]) != "function") {
  349. $("help1").innerHTML += "<br>" + v + " : " + help[v];
  350. }
  351. }
  352.  
  353. }
  354. }, false);
  355.  
  356. help = Global.availableRooms[1];
  357. help = Global.availableDiseases[6];
  358. help = Global.availableMedics[0]["med6"];
  359. help = Global.availableMedics[0];
  360. //Log(help);
  361. }
  362.  
  363. //Mediregal durchblaetterfunktion
  364. $("racknavigation_right").removeAttribute("onclick");
  365. $("racknavigation_left").removeAttribute("onclick");
  366.  
  367. $("racknavigation_left").addEventListener("click",
  368. function () {
  369. var prev = unsafeWindow.Rack._curPage - 1;
  370. var max = Math.ceil(unsafeWindow.Rack["_elements"].size() / 16);
  371. if (unsafeWindow.Rack._curPage == 1) {
  372. unsafeWindow.Rack.update(max);
  373. }
  374. else {
  375. unsafeWindow.Rack.update(prev);
  376. }
  377. }, false);
  378.  
  379.  
  380. $("racknavigation_right").addEventListener("click",
  381. function () {
  382. var next = unsafeWindow.Rack._curPage + 1;
  383. var max = Math.ceil(unsafeWindow.Rack["_elements"].size() / 16);
  384. if (next > max) {
  385. unsafeWindow.Rack.update(1);
  386. }
  387. else {
  388. unsafeWindow.Rack.update(next);
  389. }
  390.  
  391. }, true);
  392.  
  393.  
  394. var newdiv, newdiv1, newbutton;
  395. // Werbung
  396. if (werbecontainer) {
  397. werbecontainer.style.display = "";
  398. maincontainer.style.marginTop = "5px";
  399. }
  400. if ($("getcoinsnow")) {
  401. $("getcoinsnow").style.display = "none";
  402. }
  403. if ($("nicelink")) {
  404. $("nicelink").style.display = "none";
  405. }
  406. newdiv = document.getElementsByTagName("div");
  407. for (var v = 0; v < newdiv.length; v++) {
  408. if (newdiv[v].hasAttribute("onclick") && newdiv[v].getAttribute("onclick").search("facebook") != -1) {
  409. newdiv[v].style.display = "none";
  410. }
  411. }
  412.  
  413. // MiniIcons
  414. newdiv = createElement("div", {
  415. id: "berater_miniicons ",
  416. style: "color:white;height:50px;position:absolute;width:13px;z-index:10;top:186px;left:5px;"
  417. }, maincontainer);
  418. newdiv1 = createElement("div", {class: "miniicon hoverblue cursorclickable", style: "border:0;"}, newdiv, "P");
  419. newdiv1.addEventListener("click", function () {
  420. buildInfoPanel("patients");
  421. }, false);
  422. createElement("div", {style: "height:10px;"}, newdiv);
  423.  
  424. /*
  425. var floors = 2;
  426. for(var v=floors;v>0;v--){
  427. newdiv1 = createElement("div",{id:"miniiconSelectFloor"+v,class:"miniicon hoverblue cursorclickable"},newdiv,v);
  428. newdiv1.addEventListener("click",function(){unsafeWindow.Map.jumpTo("floor"+this.id.replace("miniiconSelectFloor",""));miniiconSelectFloor();},false);
  429. }
  430. function miniiconSelectFloor(){
  431. for(var v=1;v<=floors;v++) $("miniiconSelectFloor"+v).style.backgroundColor = (v==parseInt(Global.selectedFloor,10)?"blue":"");
  432. }
  433. miniiconSelectFloor();
  434. */
  435. console.log( info + "Button list");
  436.  
  437. // Button-Leiste
  438. newdiv = createElement("div", {style: "position:absolute;top:784px;display:inline;"}, maincontainer);
  439. newbutton = createElement("button", {
  440. type: "button",
  441. class: "cursorclickable",
  442. style: "margin-left:3px;"
  443. }, newdiv, texte["set_ScriptHomepage"]);
  444. newbutton.addEventListener("click", function () {
  445. window.open(scriptUrl);
  446. }, false);
  447. newbutton.addEventListener("mouseover", function () {
  448. this.style.backgroundColor = "#cc9";
  449. }, false);
  450. newbutton.addEventListener("mouseout", function () {
  451. this.style.backgroundColor = "";
  452. }, false);
  453. newbutton = createElement("button", {
  454. id: "berateroptionen",
  455. type: "button",
  456. class: "cursorclickable",
  457. style: "margin-left:3px;"
  458. }, newdiv, texte["options"]);
  459. newbutton.addEventListener("click", function () {
  460. console.log( info + "Opening settings..");
  461. buildInfoPanel("options");
  462. }, false);
  463. newbutton.addEventListener("mouseover", function () {
  464. this.style.backgroundColor = "#cc9";
  465. }, false);
  466. newbutton.addEventListener("mouseout", function () {
  467. this.style.backgroundColor = "";
  468. }, false);
  469.  
  470. // InfoPanel
  471. createElement("div", {
  472. id: "infoPanel",
  473. name: "",
  474. style: "position:absolute;top:184px;left:252px;width:600px;height:500px;background-image:url('http://pics.kapihospital.de/bg_referral_01.jpg');z-index:101;display:none;"
  475. }, all);
  476.  
  477. // Quicklinks
  478. var arrQuicklinks = [
  479. [],
  480. [[texte["shop1"]], "shop1", 1, 1],
  481. [[texte["quildhouse"]], "guildhouse", 3, 1],
  482. [[texte["townhall"]], "townhall", 3, 1],
  483. [[texte["shop2"]], "shop2", 1, 1],
  484. [[texte["editoraloffice"]], "editoraloffice", 3, 1],
  485. [[texte["ambulancestore"]], "ambulancestore", 3, 2],
  486. [[texte["rcenter"]], "rcenter", 3, 2],
  487. [],
  488. [[texte["shop3"]], "shop3", 1, 2],
  489. [[texte["architect"]], "architect", 3, 2],
  490. [[texte["shop4"]], "shop4", 1, 2],
  491. [[texte["busstop"]], "busstop", 3, 1],
  492. [[texte["speakers"]], "speakers", 3, 1],
  493. [[texte["garage"]], "garage", 2, 1],
  494. [[texte["bank"]], "bank", 3, 1],
  495. [[texte["exchange"]], "exchange", 2, 1],
  496. [[texte["goodgirl"]], "goodgirl", 3, 1],
  497. [[texte["badboy"]], "badboy", 3, 2]
  498. ];
  499.  
  500. newdiv = createElement("div", {id: "quicklinks"}, all);
  501.  
  502. var day = (new Date()).getDay();
  503. var city2Allowed = (Global.ISPREMIUM || (day == 3) || (day == 6));
  504.  
  505. for (var mode = 1; mode < 4; mode++) {
  506. for (var v = 1; v < arrQuicklinks.length; v++) {
  507. if (arrQuicklinks[v][2] == mode) {
  508. newdiv1 = createElement("div", {
  509. id: v,
  510. class: "hoverlightblue",
  511. title: arrQuicklinks[v][0]
  512. }, newdiv);
  513. createElement("div", {
  514. class: "cursorclickable c1_a_50 c1_" + v + "_50",
  515. title: arrQuicklinks[v][0]
  516. }, newdiv1);
  517.  
  518.  
  519. if ((arrQuicklinks[v][3] == 1) || city2Allowed) {
  520. newdiv1.addEventListener("click", function () {
  521. unsafeWindow.show_page(arrQuicklinks[this.id][1]);
  522. }, false);
  523. }
  524. else {
  525. newdiv1.style.opacity = "0.3";
  526. }
  527.  
  528. }
  529. }
  530. createElement("div", {style: "clear:both;"}, newdiv);
  531. createElement("div", {style: "height:20px;width:100px;"}, newdiv);
  532. }
  533.  
  534. var breaker = createElement("div", {style: "height:20px;width:100px;"}, newdiv);
  535. createElement("hr", {style: "height:2px;color:blue; background: blue; width:100%;"}, breaker);
  536.  
  537. // Autobuttons
  538. var arrQuicklinks2 = [
  539. [texte["autoBuy"]],
  540. [texte["autoNurse"]],
  541. [texte["autoClean"]],
  542. [texte["autoDisposeMedi"], 3]
  543. ];
  544.  
  545.  
  546. for (var v = 0; v < arrQuicklinks2.length; v++) {
  547. newdiv1 = createElement("div", {
  548. id: "auto" + v,
  549. class: "hoverlightblue",
  550. title: arrQuicklinks2[v][0]
  551. }, newdiv);
  552.  
  553. if (v == 0) {
  554. // Medi Buy Button
  555. createElement("div", {
  556. class: "cursorclickable c1_a_50 c1_" + 15 + "_50",
  557. title: arrQuicklinks2[v][0]
  558. }, newdiv1);
  559. newdiv1.addEventListener("click", function () {
  560. var medstoBuy = [];
  561. var price_overall = 0.00;
  562. //var buytext ="";
  563.  
  564. var dialogdiv = createElement("div", {
  565. "id": "buyquest",
  566. "style": "text-align:center; background-color:white; padding: 4px; height:500px; position:absolute; left:50%; top:50%; margin-left:-200px; margin-top:-200px; widht:400px; z-index:999;font-size:normal;"
  567. }, all);
  568. var dialogdiv2 = createElement("div", {
  569. "id": "buyquest2",
  570. "style": "overflow:auto; width:400px; height:475px;"
  571. }, dialogdiv);
  572. var dialogdiv3 = createElement("div", {
  573. "id": "buyquest3",
  574. "style": "height:25px;text-align:center;"
  575. }, dialogdiv);
  576. createElement("h2", {}, dialogdiv2, texte["BuyingMedics"]);
  577.  
  578. var newtab = createElement("table", {
  579. border: "1px",
  580. cellspacing: "0px",
  581. cellpadding: "0px",
  582. style: "text-align:left;width:100%;"
  583. }, dialogdiv2);
  584. tabrow = createElement("tr", "", newtab);
  585. createElement("td", {style: "text-align:center;"}, tabrow, texte["Buying"]);
  586. createElement("td", {style: "text-align:center;"}, tabrow, texte["Dsignation"]);
  587. createElement("td", {style: "text-align:center;"}, tabrow, texte["Price"]);
  588.  
  589. for (var i = 0; i < unsafeWindow.Rack["_elements"].length; i++) {
  590. for (var k in Global.availableMedics[0]) {
  591. if (Global.availableMedics[0][k]["id"] == unsafeWindow.Rack["_elements"][i]["product"]) {
  592. if (Global.availableMedics[0][k]["shop"] != 0) {
  593. if (Global.availableMedics[0][k]["shop"] < 3 || city2Allowed) {
  594. //console.log(Global.availableMedics[0][k]);
  595. if (( diff = valMaxRackLimit - parseInt(unsafeWindow.Rack["_elements"][i]["amount"], 10) ) > 0) {
  596. medprice = number_format((Global.availableMedics[0][k]["price"] * diff), 2, ',', '.');
  597. //console.log("medprice >"+ medprice + "<" );
  598.  
  599. price_overall += parseFloat((Global.availableMedics[0][k]["price"] * diff), 2);
  600. console.log( info + "price_overall >" + price_overall + "<");
  601.  
  602. //medstoBuy.push( { "itemid":Global.availableMedics[0][k]["id"], "amount":diff } );
  603. //buytext += diff + " x " +Global.availableMedics[0][k]["name"] + ": " + medprice + Global._KH_CURRENCY + "\n";
  604.  
  605. tabrow = createElement("tr", "", newtab);
  606. tabcell = createElement("td", {style: "text-align:center;"}, tabrow);
  607.  
  608. newinput = createElement("input", {
  609. "id": Global.availableMedics[0][k]["id"] + "#" + diff,
  610. "type": "checkbox",
  611. "checked": "checked",
  612. "title": Global.availableMedics[0][k]["name"],
  613. "style": "margin-right:0px;margin-left:1px;"
  614. }, tabcell);
  615. newinput.addEventListener("click", function () {
  616.  
  617. price = Global.availableMedics[0]["med" + this.id.split('#')[0]]["price"];
  618. price *= parseInt(this.id.split('#')[1]);
  619.  
  620. if (this.checked) {
  621. price_overall = parseFloat(price_overall) + parseFloat(price);
  622. }
  623. else {
  624. price_overall = parseFloat(price_overall) - parseFloat(price);
  625. }
  626.  
  627. if ($('prover')) {
  628. $('prover').innerHTML = hT_format(price_overall);
  629. }
  630.  
  631.  
  632. }, false);
  633.  
  634. newinput = createElement("input", {
  635. "id": "am_" + Global.availableMedics[0][k]["id"],
  636. "type": "text",
  637. "maxlength": "3",
  638. "size": "3",
  639. "value": diff,
  640. "title": "Menge",
  641. "style": "width:25px;margin-left:5px;"
  642. }, tabcell);
  643. newinput.addEventListener("keyup", function () {
  644. this.value = keepDigits(this.value);
  645.  
  646. if (!isNaN(this.value)) {
  647. calc_overall();
  648. }
  649.  
  650. }, false);
  651.  
  652.  
  653. tabcell = createElement("td", "", tabrow, Global.availableMedics[0][k]["name"]);
  654. tabcell = createElement("td", {
  655. id: "prc" + Global.availableMedics[0][k]["id"],
  656. style: "text-align:right;"
  657. }, tabrow, medprice + " " + Global._KH_CURRENCY);
  658. break;
  659. }
  660. }
  661. }
  662. }
  663. }
  664. }
  665.  
  666.  
  667. tabrow = createElement("tr", "", newtab);
  668. createElement("td", {}, tabrow, "Gesamtsumme");
  669. createElement("td", {
  670. id: "prover",
  671. colspan: "2",
  672. style: "text-align:right;font-color:red;font-weigth:bold;"
  673. }, tabrow, hT_format(price_overall));
  674.  
  675.  
  676. newbutton = createElement("button", {
  677. type: "button",
  678. class: "cursorclickable",
  679. id: "buyok",
  680. style: "width:100px;height:20px;margin:3px;"
  681. }, dialogdiv3, texte["buy"]);
  682. newbutton.addEventListener("click", function () {
  683. var checkboxes = dialogdiv2.querySelectorAll('input[type="checkbox"]');
  684. for (var i = 0; i < checkboxes.length; i++) {
  685. if (checkboxes[i].checked) {
  686. medstoBuy.push({
  687. "itemid": checkboxes[i].id.split('#')[0],
  688. "amount": $('am_' + checkboxes[i].id.split('#')[0]).value
  689. })
  690. }
  691. }
  692.  
  693. if (medstoBuy.length > 0) {
  694. medstoBuy.push("send");
  695. var payload = JSON.stringify(medstoBuy);
  696. //console.log(payload);
  697. unsafeWindow.Cart._sendRequest("city.shop", "get", payload, true);
  698. }
  699.  
  700. all.removeChild(dialogdiv);
  701. }, false);
  702.  
  703. newbutton = createElement("button", {
  704. type: "button",
  705. class: "cursorclickable",
  706. id: "buycancel",
  707. style: "width:100px;height:20px;margin:3px;"
  708. }, dialogdiv3, texte["cancel"]);
  709. newbutton.addEventListener("click", function () {
  710. all.removeChild(dialogdiv);
  711. dialogdiv = null;
  712.  
  713. }, false);
  714. }, false);
  715. }
  716.  
  717. if (v == 1) {
  718. var actpat;
  719.  
  720. // Autoschwester Button
  721. createElement("div", {
  722. class: "cursorclickable c1_a_50 c1_" + 2 + "_50",
  723. title: arrQuicklinks2[v][0]
  724. }, newdiv1);
  725. newdiv1.addEventListener("click", function () {
  726. rooms = Global.refRooms.values();
  727.  
  728. for (var v = 0; v < rooms.length; v++) {
  729. if (( rooms[v].roomid == 6 )) {
  730. console.log( info + "Checking room: " + rooms[v].topleft);
  731.  
  732. //If pateint has a room
  733. if (rooms[v].patient != 0) {
  734. console.log( info + "Room " + rooms[v].topleft + " belongs to patient: " + rooms[v].patient);
  735. refreshPatient(rooms[v].patient, true);
  736. }
  737.  
  738. }
  739. }
  740.  
  741. }, false);
  742. }
  743.  
  744. //Dreckige R�ume s�ubern
  745. if (v == 2) {
  746. createElement("div", {
  747. class: "cursorclickable c1_a_50 c1_" + 8 + "_50",
  748. title: arrQuicklinks2[v][0]
  749. }, newdiv1);
  750. newdiv1.addEventListener("click", cleaningfunc, false);
  751. }
  752.  
  753. //MEdis verteilen
  754. if (v == 3) {
  755. createElement("div", {
  756. class: "cursorclickable c1_a_50 c1_" + 1 + "_50",
  757. title: arrQuicklinks2[v][0]
  758. }, newdiv1);
  759. newdiv1.addEventListener("click", medifunc, false);
  760. }
  761. }
  762.  
  763. createElement("div", {style: "clear:both;"}, newdiv);
  764. createElement("div", {style: "height:20px;width:100px;"}, newdiv);
  765.  
  766.  
  767. // Hotkeys
  768. if (GM_getValue(lng + "_" + server + "_" + username + "_valHotkey", true)) {
  769. window.addEventListener("keydown", function (event) {
  770. if (event.altKey) {
  771. switch (event.keyCode) {
  772. case 49:
  773. if ($("floor_jump_1")) {
  774. closeInfoPanel();
  775. click($("floor_jump_1"));
  776. }
  777. event.preventDefault();
  778. break; // Ebene 1
  779. case 50:
  780. if ($("floor_jump_2")) {
  781. closeInfoPanel();
  782. click($("floor_jump_2"));
  783. }
  784. event.preventDefault();
  785. break; // Ebene 2
  786. case 51:
  787. if ($("floor_jump_3")) {
  788. closeInfoPanel();
  789. click($("floor_jump_3"));
  790. }
  791. event.preventDefault();
  792. break; // Ebene 3
  793. case 52:
  794. if ($("floor_jump_4")) {
  795. closeInfoPanel();
  796. click($("floor_jump_4"));
  797. }
  798. event.preventDefault();
  799. break; // Ebene 3
  800. case 66:
  801. unsafeWindow.show_page("exchange");
  802. event.preventDefault();
  803. break; // B:Boerse
  804. case 71:
  805. unsafeWindow.show_page("garage");
  806. event.preventDefault();
  807. break; // G:Garage
  808. case 80:
  809. buildInfoPanel("patients");
  810. event.preventDefault();
  811. break; // P:Patients
  812. }
  813. }
  814. }, false);
  815. }
  816.  
  817.  
  818. window.setInterval(function () {
  819. now = Math.floor((new Date()).getTime() / 1000);
  820. rooms = Global.refRooms.values();
  821. patients = Global.refPatients.values();
  822.  
  823. var currPatientId = 0;
  824. var currRoom = null;
  825.  
  826. if (!roomTimes[Global.selectedFloor]) {
  827. roomTimes[Global.selectedFloor] = {};
  828. }
  829. var calcGlobalTime = false;
  830. roomTimes["allrooms"][Global.selectedFloor] = 0;
  831.  
  832. // Rooms
  833. var cand = document.getElementsByClassName("room");
  834.  
  835. /* room states ...so far
  836. 0:
  837. 1:
  838. 2: ready
  839. 3: treatment
  840. 4:
  841. 5:
  842. 6: cleaning
  843. 7: dirty
  844.  
  845. */
  846. if (Global.nonEmptyFields[0]) {
  847. for (var v = 0; v < cand.length; v++) {
  848. if ((currRoom = Global.refRooms.get(cand[v].id) )) {
  849. if (currRoom["roomid"] == 6) {
  850. // Bed
  851. if (currPatientId = parseInt(currRoom["patient"], 10)) {
  852. if (patientDiseases[currPatientId]) {
  853. if (!$("p" + currPatientId)) {
  854. patientDiseases[currPatientId]["state"] = 2;
  855. patientDiseases[currPatientId]["floor"] = 1;
  856. patientDiseases[currPatientId]["room"] = 6;
  857. }
  858. }
  859. else {
  860. initPatient(currPatientId);
  861. }
  862.  
  863. if ($("treatmentr" + currRoom["topleft"])) {
  864. if ((!roomTimes[Global.selectedFloor][currRoom["topleft"]]) || (currRoom["ends"] != roomTimes[Global.selectedFloor][currRoom["topleft"]][0])) {
  865. roomTimes[Global.selectedFloor][currRoom["topleft"]] = [currRoom["ends"], now + currRoom["ends"], 3];
  866. }
  867.  
  868. if (!$("timeinfo_" + currRoom["topleft"])) {
  869. createElement("div", {
  870. id: "timeinfo_" + currRoom["topleft"],
  871. style: "position:absolute;top:0px;left:1px;background-color:white;"
  872. }, $("r" + currRoom["topleft"]));
  873. }
  874.  
  875. //console.log( time2str(roomTimes[Global.selectedFloor][currRoom["topleft"]][1]-now, 2) );
  876. $("timeinfo_" + currRoom["topleft"]).innerHTML = time2str(roomTimes[Global.selectedFloor][currRoom["topleft"]][1] - now, 2);
  877. }
  878. else {
  879. if ($("timeinfo_" + currRoom["topleft"])) {
  880. removeElement($("timeinfo_" + currRoom.topleft));
  881. }
  882. }
  883.  
  884. }
  885. }
  886. else if ((Global.availableRooms[currRoom["roomid"]] ) && (Global.availableRooms[currRoom["roomid"]]["diseases"].length > 0)) { // Behandlungsraum
  887. roomTimes["allrooms"][Global.selectedFloor]++;
  888.  
  889. if (currRoom["state"] == 3 || currRoom["state"] == 6) {
  890.  
  891. if ((!roomTimes[Global.selectedFloor][currRoom["topleft"]]) || (currRoom["ends"] != roomTimes[Global.selectedFloor][currRoom["topleft"]][0])) {
  892. roomTimes[Global.selectedFloor][currRoom["topleft"]] = [currRoom["ends"], now + currRoom["ends"], 3];
  893.  
  894. if (currRoom["state"] == 3) {
  895. calcGlobalTime = true;
  896. }
  897. }
  898.  
  899. if (!$("timeinfo_" + currRoom["topleft"])) {
  900. createElement("div", {
  901. id: "timeinfo_" + currRoom["topleft"],
  902. style: "position:absolute;bottom:23px;left:13px;font-weight:bold;background-color:white;"
  903. }, $("r" + currRoom["topleft"]));
  904. }
  905. $("timeinfo_" + currRoom["topleft"]).innerHTML = time2str(roomTimes[Global.selectedFloor][currRoom["topleft"]][1] - now);
  906.  
  907. // treatment?
  908. if ($("gradient_r" + currRoom["topleft"])) {
  909. if (currRoom["state"] == 3) {
  910. if (currPatientId = parseInt(currRoom["patient"], 10)) {
  911. if (patientDiseases[currPatientId]) {
  912. patientDiseases[currPatientId]["state"] = 4;
  913. patientDiseases[currPatientId]["floor"] = Global.selectedFloor;
  914. patientDiseases[currPatientId]["room"] = currRoom["roomid"];
  915. } else {
  916. initPatient(currPatientId);
  917. }
  918. }
  919.  
  920. // Medis
  921. if ($("alert" + currRoom.topleft)) {
  922. var currDisease = null;
  923. if (currDisease = calcCurrDisease(currRoom["patient"])) {
  924. if (!$("mediinfo_" + currRoom.topleft)) {
  925. createElement("div", {
  926. id: "mediinfo_" + currRoom.topleft,
  927. style: "position:absolute;top:5px;left:5px;font-weight:bold;background-color:white;-moz-border-radius:5px;"
  928. }, $("r" + currRoom.topleft));
  929. }
  930. $("mediinfo_" + currRoom.topleft).setAttribute("class", "m_a_30 m_" + medi[currDisease]["id"] + "_30");
  931. }
  932. } else {
  933. if ($("mediinfo_" + currRoom.topleft)) {
  934. removeElement($("mediinfo_" + currRoom.topleft));
  935. }
  936. }
  937. }
  938.  
  939. } else {
  940. if (currRoom["state"] == 3) {
  941. if ($("timeinfo_" + currRoom.topleft)) {
  942. removeElement($("timeinfo_" + currRoom.topleft));
  943. }
  944. if ($("mediinfo_" + currRoom.topleft)) {
  945. removeElement($("mediinfo_" + currRoom.topleft));
  946. }
  947. }
  948. }
  949. } else {
  950.  
  951. if ((!roomTimes[Global.selectedFloor][currRoom["topleft"]]) || (currRoom["state"] != roomTimes[Global.selectedFloor][currRoom["topleft"]][2])) {
  952. calcGlobalTime = true;
  953. }
  954. roomTimes[Global.selectedFloor][currRoom["topleft"]] = [0, 0, currRoom["state"]];
  955. if ($("timeinfo_" + currRoom.topleft)) {
  956. removeElement($("timeinfo_" + currRoom.topleft));
  957. }
  958. if ($("mediinfo_" + currRoom.topleft)) {
  959. removeElement($("mediinfo_" + currRoom.topleft));
  960. }
  961. }
  962. }
  963. }
  964. }
  965. }
  966.  
  967. if (roomTimes["global"][0] <= now) {
  968. calcGlobalTime = true;
  969. }
  970.  
  971. if (calcGlobalTime) {
  972. Log("calcGlobalTime");
  973. roomTimes["global"][0] = nie;
  974. //roomTimes["allrooms"][0] = 0;
  975. roomTimes["emptyrooms"][0] = 0;
  976. roomTimes["global"][Global.selectedFloor] = nie;
  977. for (var floor = 1; floor < roomTimes["global"].length; floor++) {
  978. roomTimes["global"][floor] = nie;
  979. roomTimes["emptyrooms"][floor] = 0;
  980. for (var help in roomTimes[floor]) {
  981. if (roomTimes[floor][help][1] <= now) {
  982. roomTimes["emptyrooms"][floor]++;
  983. }
  984. else {
  985. roomTimes["global"][floor] = Math.min(roomTimes["global"][floor], roomTimes[floor][help][1]);
  986. }
  987. }
  988. roomTimes["global"][0] = Math.min(roomTimes["global"][0], roomTimes["global"][floor]);
  989. //roomTimes["allrooms"][0] += roomTimes["allrooms"][floor];
  990. roomTimes["emptyrooms"][0] += roomTimes["emptyrooms"][floor];
  991. }
  992. }
  993. if (valGlobalClockInTitle) {
  994. document.title = (roomTimes["global"][0] < nie ? time2str(roomTimes["global"][0] - now) : texte["fertig"].toUpperCase()) + " - " + roomTimes["emptyrooms"][0] + " - " + documentTitle;
  995. } else {
  996. if (!$("globalclock")) {
  997. createElement("div", {
  998. id: "globalclock",
  999. title: texte["GlobalTime"],
  1000. style: "position:absolute;top:0px;left:0px;font-weight:bold;background-color:white;"
  1001. }, all);
  1002. }
  1003. $("globalclock").innerHTML = (roomTimes["global"][0] < nie ? time2str(roomTimes["global"][0] - now) : texte["fertig"].toUpperCase()) + " - " + roomTimes["emptyrooms"][0];
  1004. }
  1005. if (!$("floorclock")) {
  1006. createElement("div", {
  1007. id: "floorclock",
  1008. title: texte["FloorTime"],
  1009. style: "position:absolute;top:5px;left:20px;font-weight:bold;background-color:white;"
  1010. }, $("hospital_content"));
  1011. }
  1012. $("floorclock").innerHTML = ((roomTimes["allrooms"][Global.selectedFloor] > 0) ? (roomTimes["global"][Global.selectedFloor] < nie ? time2str(roomTimes["global"][Global.selectedFloor] - now) : texte["fertig"].toUpperCase()) : "---") + " - " + roomTimes["emptyrooms"][Global.selectedFloor];
  1013.  
  1014. // Patients Divs
  1015. var canddiv = $("hospital_content").getElementsByClassName("patient");
  1016. for (var pat = 0; pat < canddiv.length; pat++) {
  1017. currPatientId = parseInt(canddiv[pat].id.replace("p", ""), 10);
  1018. if (patientDiseases[currPatientId]) {
  1019. patientDiseases[currPatientId]["floor"] = Global.refPatients.get("p" + currPatientId)["floor"];
  1020. var classStr = canddiv[pat].getAttribute("class").replace(" allcured", "").replace(" unhealable", "").replace(" needminitreatment", "");
  1021.  
  1022. //dont remove, its flickring to much
  1023. if ($("mcont_" + currPatientId)) {
  1024. //removeElement( $("mcont_"+currPatientId) );
  1025. }
  1026.  
  1027. // 0=waitingroom,1=bed,2=nurse,3=in room,4=treatment,5=cured
  1028. if (patientDiseases[currPatientId]["state"] != 5) {
  1029. if (patientDiseases[currPatientId]["state"] == 2) {
  1030. patientDiseases[currPatientId]["m"]++;
  1031. calcEndTreatment(currPatientId);
  1032. }
  1033. else if (patientDiseases[currPatientId]["state"] == 4) {
  1034. calcEndTreatment(currPatientId);
  1035. }
  1036.  
  1037.  
  1038. patientDiseases[currPatientId]["room"] = Global.refRooms.get(Global.refPatients.get("p" + currPatientId)["room"])["roomid"];
  1039.  
  1040. if (patientDiseases[currPatientId]["room"] == 6) { // Is under nurse treatment
  1041. patientDiseases[currPatientId]["state"] = 1;
  1042.  
  1043. //in bed
  1044. if (!$("mcont_" + currPatientId)) {
  1045. createElement("div", {
  1046. id: "mcont_" + currPatientId,
  1047. style: "float:right;background-color:white;margin-right:2px;"
  1048. }, canddiv[pat]);
  1049.  
  1050. for (var m = 0; m < patientDiseases[currPatientId]["m"]; m++) {
  1051. createElement("div", {style: "width: 7px; height: 7px; margin: 1px;background-color:green;"}, $("mcont_" + currPatientId));
  1052. }
  1053.  
  1054. for (; m < 4; m++) {
  1055. createElement("div", {style: "width: 7px; height: 7px; margin: 1px;background-color:red;"}, $("mcont_" + currPatientId));
  1056. }
  1057. }
  1058. }
  1059. else {
  1060. patientDiseases[currPatientId]["state"] = 3;
  1061. }
  1062.  
  1063. //ist zu testen
  1064. calcEndTreatment(currPatientId);
  1065. }
  1066.  
  1067.  
  1068. if (patientDiseases[currPatientId]["state"] != 5) {
  1069. if (patientDiseases[currPatientId]["m"] < 4) {
  1070. classStr += " needminitreatment" + (patientDiseases[currPatientId]["unhealable"] ? " unhealable" : "");
  1071. }
  1072. else if (patientDiseases[currPatientId]["unhealable"]) {
  1073. classStr += " unhealable";
  1074. }
  1075. }
  1076. else {
  1077. classStr += " allcured";
  1078. }
  1079.  
  1080.  
  1081. canddiv[pat].setAttribute("class", classStr);
  1082. }
  1083. else {
  1084. initPatient(currPatientId);
  1085. }
  1086. }
  1087.  
  1088. // waiting patients
  1089. canddiv = $("waitingroom").getElementsByClassName("waitingpatient");
  1090. for (var pat = 0; pat < canddiv.length; pat++) {
  1091. canddiv[pat].style.opacity = ((Global.refPatients.get(canddiv[pat].id).referred != 0) ? "0.4" : "1"); //verkaufte
  1092. var currPatientId = parseInt(canddiv[pat].id.replace("p", ""), 10);
  1093. if (patientDiseases[currPatientId]) {
  1094. patientDiseases[currPatientId]["floor"] = 0;
  1095. patientDiseases[currPatientId]["room"] = 0;
  1096. if (patientDiseases[currPatientId]["unhealable"]) {
  1097. canddiv[pat].setAttribute("class", canddiv[pat].getAttribute("class").replace(" unhealable", "") + " unhealable");
  1098. }
  1099. if (patientDiseases[currPatientId]["state"] > 0) {
  1100. patientDiseases[currPatientId]["state"] = 0;
  1101. }
  1102. } else {
  1103. initPatient(currPatientId);
  1104. }
  1105. }
  1106. canddiv = null;
  1107.  
  1108. // QuestClock
  1109. if (!$("questclock")) {
  1110. createElement("div", {
  1111. id: "questclock",
  1112. title: texte["QuestTime"],
  1113. style: "position:absolute;bottom:0px;right:0px;font-weight:bold;background-color:white;"
  1114. }, $("waitingroom"));
  1115. }
  1116.  
  1117. $("questclock").innerHTML = ( (questTime > now) ? time2str(questTime - now) : texte["fertig"].toUpperCase() );
  1118.  
  1119. }, 1000);
  1120.  
  1121. window.setInterval(function () {
  1122. var now = Math.floor((new Date()).getTime() / 1000);
  1123.  
  1124. if (valStartQuestAutomatic) {
  1125. if (!(questTime > now) && questcnt < 8) {
  1126. start_Quest();
  1127. }
  1128. }
  1129. }, 3000);
  1130.  
  1131.  
  1132. window.setInterval(function () { // leaving patient
  1133. var cand = $("goingpatient").getElementsByClassName("patient");
  1134. for (var v = 0; v < cand.length; v++) {
  1135. var currPatientId = parseInt(cand[v].id.replace("p", ""), 10);
  1136. if (patientDiseases[currPatientId]) {
  1137. delete patientDiseases[currPatientId];
  1138. }
  1139. }
  1140. //<div style="position: absolute; left: 46px; width: 25px; height: 36px; top: 31px;
  1141. //background-image: url(&quot;http://pics.kapihospital.de/patient3_walksaway.gif&quot;); z-index: 1000;"
  1142. //class="patient cursordrag allcured" id="p9233468"></div>
  1143. }, 500);
  1144.  
  1145. window.setInterval(function () {
  1146. var cand = $("rackItems").getElementsByClassName("medamount");
  1147. for (var v in cand) {
  1148. if (cand[v].nodeType === 1) {
  1149. var help = cand[v].getAttribute("class");
  1150.  
  1151. if (parseInt(cand[v].innerHTML, 10) < valRackLimit) {
  1152. if (help.search(" racklow") == -1) {
  1153. cand[v].setAttribute("class", help + " racklow");
  1154. }
  1155. }
  1156. else {
  1157. if (help.search(" racklow") != -1) {
  1158. cand[v].setAttribute("class", help.replace(" racklow", ""));
  1159. }
  1160. }
  1161. }
  1162. }
  1163. for (var pat in patientDiseases) {
  1164. if ((patientDiseases[pat]["state"] == 0) && (!$("p" + pat))) { // waiting+gone
  1165. delete patientDiseases[pat];
  1166. }
  1167. }
  1168. GM_setValue(lng + "_" + server + "_" + username + "_patientDiseases", implode(patientDiseases));
  1169. cand = null;
  1170. }, 5000);
  1171.  
  1172. // Patient-MouseOver Diseases
  1173. var beraterDiseaseBubble = createElement("div", {
  1174. id: "beraterDiseaseBubble",
  1175. style: "z-index:2000;position:absolute;top:0px;left:0px;background-color:#CCC;-moz-border-radius:10px;border:2px solid black;padding:3px;margin-left:40px;"
  1176. }, all);
  1177. hiddenPatientDiv = createElement("div", {id: "hiddenPatientDiv", style: "display:;"}, all);
  1178.  
  1179. $("garten_komplett").addEventListener("mouseover", function (event) {
  1180. Log("MOUSEOVER " + event.target.id);
  1181. var patientId = 0;
  1182. if (!isNaN(event.target.id.replace("r", ""))) {
  1183. var currRoom = Global.refRooms.get(event.target.id);
  1184. highlightPatients(currRoom.roomid);
  1185. patientId = currRoom.patient;
  1186. }
  1187. else if (!isNaN(event.target.id.replace("p", ""))) {
  1188. patientId = event.target.id.replace("p", "");
  1189. }
  1190. beraterDiseaseBubble.innerHTML = "";
  1191. if (patientId != 0) {
  1192. beraterDiseaseBubble.style.display = "block";
  1193. beraterDiseaseBubble.setAttribute("name", patientId);
  1194. plotPatient(beraterDiseaseBubble);
  1195. //getPatientData(patientId);
  1196.  
  1197. if (Global.ISPREMIUM) {
  1198. var patdetail = $("treatico");
  1199. if (patdetail.childNodes.length > 0) {
  1200. patientDiseases[patientId]["m"] = 4;
  1201. }
  1202. }
  1203. }
  1204. }, false);
  1205. $("garten_komplett").addEventListener("mousemove", function (event) {
  1206. beraterDiseaseBubble.style.left = event.pageX + "px";
  1207. beraterDiseaseBubble.style.top = event.pageY + "px";
  1208. }, false);
  1209. $("garten_komplett").addEventListener("mouseout", function (event) {
  1210. beraterDiseaseBubble.style.display = "none";
  1211. unhighlightPatients();
  1212. }, false);
  1213.  
  1214. // Frame Observer
  1215. newswindowObserver = window.setInterval(function () {
  1216. if (($("newswindow").style.display != "none") && (!$("newswindowObserver"))) {
  1217. createElement("h1", {id: "newswindowObserver"}, $("newswindow"));
  1218. if ($("msgwindow")) {
  1219. var help = $("msgwindow").getAttribute("style");
  1220. if (help.search("medicalrecord_1.png") != -1) {
  1221. do_Patientenblatt();
  1222. }
  1223. else if (help.search("bg_exchange2.jpg") != -1) {
  1224. do_Patientenboerse();
  1225. }
  1226. else if (help.search("bg_notes.png") != -1) {
  1227. do_Notepad();
  1228. }
  1229. else if (help.search("bg_questfinished") != -1) {
  1230. do_Quest();
  1231. }
  1232. else if (help.search("bg_garage") != -1) {
  1233. do_Quest();
  1234. }
  1235. else if (help.search("quest_bg") != -1) {
  1236. do_Quest();
  1237. }
  1238. else if (help.search("bg_shop") != -1) {
  1239. do_Shop();
  1240. }
  1241. else if (help.search("bg_mail") != -1) {
  1242. do_Mail();
  1243. }
  1244. }
  1245. }
  1246. }, 200);
  1247.  
  1248. // Rack
  1249. $("rackItems").addEventListener("dblclick", function (event) {
  1250. var shop = Global.availableMedics[0]["med" + event.target.getAttribute("medid")]["shop"];
  1251. if ((shop < 3) || city2Allowed) {
  1252. unsafeWindow.show_page("shop" + shop);
  1253. } else {
  1254. alert(texte["shopNotAvailable"]);
  1255. }
  1256. }, false);
  1257.  
  1258. newdiv = null;
  1259. newdiv1 = null;
  1260. newbutton = null;
  1261. }
  1262.  
  1263. console.log( info + "End do_main()");
  1264.  
  1265. /*************************** end do_main() ******************************************/
  1266.  
  1267.  
  1268. /*************************** definition helper functions ****************************/
  1269. function loadLanguage(lang) {
  1270. switch (lang) {
  1271. case "en":
  1272. texte["berater"] = "Adviser";
  1273. texte["autologin1"] = "Checking active sessions. Please wait 5 seconds<br>...";
  1274. texte["autologin2"] = "All accounts logged in.";
  1275. texte["options"] = "Options";
  1276. texte["fertig"] = "Done";
  1277. texte["shopNotAvailable"] = "The shop is not available";
  1278. texte["noch"] = "Left";
  1279. texte["QuestTime"] = "Quest time";
  1280. texte["FloorTime"] = "Floor time";
  1281. texte["GlobalTime"] = "Global time";
  1282. // options panel
  1283. texte["set_ScriptHomepage"] = "Script Homepage";
  1284. texte["set_AutoLogin"] = "Automatic login";
  1285. texte["set_Update"] = "Update";
  1286. texte["set_RackLow"] = "Minimal rackamount";
  1287. texte["set_RackMax"] = "Automatic buying limit";
  1288. texte["set_valGlobalClockInTitle"] = "Time in page title";
  1289. texte["set_valStartQuestAutomatic"] = "AutoQuest";
  1290. texte["info_AutoLogin"] = "Once username and password information is given, all accounts will be logged in";
  1291. texte["info_Update"] = "Checks whether an updated version of this Advisor script is available.";
  1292. texte["info_RackLow"] = "A product is marked if its amount in your rack is falling below this value.";
  1293. texte["info_RackMax"] = "By Automatic buying product will be purchased until reaching this number.";
  1294. texte["info_valGlobalClockInTitle"] = "Global clock in title";
  1295. texte["info_valStartQuestAutomatic"] = "Should the next quest start automaticly, if the previous ends?";
  1296. texte["confirmUpdate"] = "There is new version of Kapi Hospital Berater. Would You like to install it?";
  1297. texte["zeigePasswoerter"] = "Show password";
  1298. texte["autoLogin"] = "Automatic loging in";
  1299. texte["accountAktiv"] = "Account is acrive";
  1300. texte["server"] = "Server";
  1301. texte["ungueltigerServer"] = "Wrong server";
  1302. texte["name"] = "Name";
  1303. texte["passwort"] = "Password";
  1304. texte["speichern"] = "Save";
  1305. texte["loeschen"] = "Erase";
  1306. texte["buy"] = "Buy";
  1307. texte["cancel"] = "Cancel";
  1308. texte["autoBuy"] = "Buy medics";
  1309. texte["autoClean"] = "Clean rooms";
  1310. texte["autoNurse"] = "Call nurse";
  1311. texte["autoDisposeMedi"] = "Dispose medics";
  1312. // patients panel
  1313. texte["zeigeGeheilteKrankheiten"] = "Show cured of the disease";
  1314. texte["minipics"] = "Minipics";
  1315. texte["Beschreibung"] = "untreated/overall";
  1316. texte["Beschreibung2"] = "helptext to understand this window: Number of untreated diseases without those currently treated/overall number";
  1317. texte["frei"] = "Hospital beds";
  1318. texte["inBehandlung"] = "in a room";
  1319. texte["waitingroom"] = "Waiting room";
  1320. texte["Gesamt"] = "Overall";
  1321. texte["Patients"] = "Patients";
  1322. texte["Rooms"] = "Rooms";
  1323. // Buy medics view
  1324. texte["BuyingMedics"] = "Buying medics";
  1325. texte["Buying"] = "Buying";
  1326. texte["Dsignation"] = "Designation";
  1327. texte["Price"] = "Price";
  1328. // Exchange
  1329. texte["showUncurable"] = "Show uncurable";
  1330. //Systemwords
  1331. texte["waehrung"] = "hT"; //Global._KH_CURRENCY
  1332. texte["coins"] = "Coins";
  1333. // Quicklinks
  1334. texte["shop1"] = "";
  1335. texte["quildhouse"] = "";
  1336. texte["townhall"] = "";
  1337. texte["shop2"] = "";
  1338. texte["editoraloffice"] = "";
  1339. texte["ambulancestore"] = "";
  1340. texte["rcenter"] = "";
  1341. texte["shop3"] = "";
  1342. texte["architect"] = "";
  1343. texte["shop4"] = "";
  1344. texte["busstop"] = "";
  1345. texte["speakers"] = "";
  1346. texte[""] = "";
  1347. texte["garage"] = "";
  1348. texte["bank"] = "";
  1349. texte["exchange"] = "";
  1350. texte["goodgirl"] = "";
  1351. texte["badboy"] = "";
  1352. //TODO: Add English translation
  1353. break;
  1354.  
  1355. case "de":
  1356. texte["berater"] = "Berater";
  1357. texte["autologin1"] = "Ermittle aktive Sessions. Bitte 5 Sekunden warten<br>...";
  1358. texte["autologin2"] = "Alle Accounts eingeloggt.";
  1359. texte["options"] = "Optionen";
  1360. texte["fertig"] = "Fertig";
  1361. texte["shopNotAvailable"] = "Shop heute nicht erreichbar";
  1362. texte["noch"] = "noch";
  1363. texte["QuestTime"] = "Quest time";
  1364. texte["FloorTime"] = "Etage time";
  1365. texte["GlobalTime"] = "Global time";
  1366. // options panel
  1367. texte["set_ScriptHomepage"] = "Scripthomepage";
  1368. texte["set_AutoLogin"] = "Automatisch einloggen";
  1369. texte["set_Update"] = "Update";
  1370. texte["set_RackLow"] = "Minimaler Lagerbestand";
  1371. texte["set_RackMax"] = "Maximaler Lagerbestand";
  1372. texte["set_valGlobalClockInTitle"] = "Globale Zeit im Titel";
  1373. texte["set_valStartQuestAutomatic"] = "Quests automatisch";
  1374. texte["info_AutoLogin"] = "Sobald Nutzerdaten und Passwort eingegeben sind, werden die Accounts wieder eingeloggt. Es m" + ue_de + "ssen Popups erlaubt werden bei mehreren Accounts.";
  1375. texte["info_Update"] = "Es wird gepr" + ue_de + "ft, ob eine neuere Version dieses Scriptes verf" + ue_de + "gbar ist.";
  1376. texte["info_RackLow"] = "Ein Medikament wird markiert, falls der Lagerbestand unter diese Grenze f" + ae_de + "llt.";
  1377. texte["info_RackMax"] = "Es werden beim automatischen Einkauf die Medikamente bis zu diesem Lagerbestand afgef" + ue_de + "llt.";
  1378. texte["info_valGlobalClockInTitle"] = "Die globale Zeit wird im Fenstertitel angezeigt. Ansonsten im Fenster.";
  1379. texte["info_valStartQuestAutomatic"] = "Soll sofort die n" + ae_de + "chste Quest gestartet werden, wenn eine beended wurde ( max. 8 )?";
  1380. texte["confirmUpdate"] = "Es liegt eine neue Script-Version vor. Diese installieren?";
  1381. texte["zeigePasswoerter"] = "zeige Passw" + oe_de + "rter";
  1382. texte["autoLogin"] = "Automatischer Login";
  1383. texte["accountAktiv"] = "Account aktiv";
  1384. texte["server"] = "Server";
  1385. texte["ungueltigerServer"] = "Ungueltiger Server";
  1386. texte["name"] = "Name";
  1387. texte["passwort"] = "Passwort";
  1388. texte["speichern"] = "speichern";
  1389. texte["loeschen"] = "l" + oe_de + "schen";
  1390. texte["buy"] = "Kaufen";
  1391. texte["cancel"] = "Abbrechen";
  1392. texte["autoBuy"] = "automatische Lagerauff" + ue_de + "llung";
  1393. texte["autoClean"] = "R" + ae_de + "ume s" + ae_de + "ubern";
  1394. texte["autoNurse"] = "Krankenschwester rufen";
  1395. texte["autoDisposeMedi"] = "Medikamente verteilen";
  1396. // patients panel
  1397. texte["zeigeGeheilteKrankheiten"] = "Zeige geheilte Krankheiten";
  1398. texte["minipics"] = "Minipics";
  1399. texte["Beschreibung"] = "unbehandelt/Gesamt";
  1400. texte["Beschreibung2"] = "Hilfetext um dieses Fenster zu verstehen: Anzahl dieser Krankheit unbehandelt ohne gerade in Behandlung befindliche/Anzahl Gesamt";
  1401. texte["frei"] = "Krankenbetten";
  1402. texte["inBehandlung"] = "in Behandlung";
  1403. texte["waitingroom"] = "Warteraum";
  1404. texte["Gesamt"] = "Gesamt";
  1405. texte["Patients"] = "Patients";
  1406. texte["Rooms"] = "R" + ae_de + "ume";
  1407. // Buy medics view
  1408. texte["BuyMedics"] = "Medis kaufen";
  1409. texte["Buying"] = "Kaufen";
  1410. texte["Dsignation"] = "Bezeichnung";
  1411. texte["Price"] = "Preis";
  1412. // Exchange
  1413. texte["showUncurable"] = "Zeige Unheilbare";
  1414. //Systemwords
  1415. texte["waehrung"] = "hT"; //Global._KH_CURRENCY
  1416. texte["coins"] = "Coins";
  1417. // Quicklinks
  1418. texte["shop1"] = "Apotheke Pillenexpress";
  1419. texte["quildhouse"] = Ae_de + "rztevereinigung und Wettbewerb";
  1420. texte["townhall"] = "Rathaus";
  1421. texte["shop2"] = "Medizinischer Gro";
  1422. texte["editoraloffice"] = "Zeitungsredaktion";
  1423. texte["ambulancestore"] = "Autoh" + ae_de + "ndler";
  1424. texte["rcenter"] = "Forschungszentrum";
  1425. texte["shop3"] = "Internetcafe";
  1426. texte["architect"] = "Architekturb" + ue_de + "ro";
  1427. texte["shop4"] = "Tante-Emma-Laden";
  1428. texte["busstop"] = "Bushaltestelle";
  1429. texte["speakers"] = "Speakers Corner";
  1430. texte["garage"] = "Garage";
  1431. texte["bank"] = "Bank";
  1432. texte["exchange"] = "Patientenb" + oe_de + "rse";
  1433. texte["goodgirl"] = "Fr" + ae_de + "ulein Rosenwasser";
  1434. texte["badboy"] = "Dr. Knievel";
  1435. break;
  1436.  
  1437. case "pl":
  1438. texte["berater"] = "Doradca";
  1439. texte["autologin1"] = "Sprawdzanie aktywnych sesji. Prosz" + e_pl + "odczekac 5 sekund...";
  1440. texte["autologin2"] = "Wszystkie konta zalogowane.";
  1441. texte["options"] = "Opcje";
  1442. texte["fertig"] = "Gotowe";
  1443. texte["shopNotAvailable"] = "Sklep jest teraz niedost" + e_pl + "pny";
  1444. texte["noch"] = "Pozosta" + l_pl + "o";
  1445. texte["QuestTime"] = "Czas questu";
  1446. texte["FloorTime"] = "Czas piętra";
  1447. texte["GlobalTime"] = "Czas globalny";
  1448. // options panel
  1449. texte["set_ScriptHomepage"] = "Strona domowa skryptu";
  1450. texte["set_AutoLogin"] = "Automatyczne logowanie";
  1451. texte["set_Update"] = "Aktualizacja";
  1452. texte["set_RackLow"] = "Minimalna ilo" + s_pl + c_pl + " lekarstw w regale";
  1453. texte["set_RackMax"] = "Limit zakupu";
  1454. texte["set_valGlobalClockInTitle"] = "Czas w tytule karty.";
  1455. texte["set_valStartQuestAutomatic"] = "AutoQuest.";
  1456. texte["info_AutoLogin"] = "Po wprowadzeniu nazwy u" + z_pl + "ytkownika i has" + l_pl + "a nast" + e_pl + "puje automatyczne logowanie. Pozwala to zachowa" + c_pl + " " + c_pl + "iaglosc grania. Przy wielu kontach musi by" + c_pl + "dozwolone wyskakiwanie okienek.";
  1457. texte["info_Update"] = "Automatycznie sprawdza czy jest nowsza wersja tego skryptu.";
  1458. texte["info_RackLow"] = "Produkt zostanie zaznaczony, gdy jego ilo" + s_pl + c_pl + " w regale spadnie poni" + z_pl + "ej tego poziomu";
  1459. texte["info_RackMax"] = "Poprzez automnatyczny zakup, produkt b" + e_pl + "dzie zape" + l_pl + "niany do tego limitu.";
  1460. texte["info_valGlobalClockInTitle"] = "Czas globalny jest wy" + s_pl + "wietlany w pasku tytu" + l_pl + "owym okna.";
  1461. texte["info_valStartQuestAutomatic"] = "Czy kolejny quest powinien si" + e_pl + " zacz" + a_pl + c_pl + " zaraz po tym, gdy sko" + n_pl + "czy" + l_pl + " si" + e_pl + " poprzedni?";
  1462. texte["confirmUpdate"] = "Jest nowa wersja skryptu Doradca Kapi Hospital. Czy chcesz j" + a_pl + " zainstalowa" + c_pl + "?";
  1463. texte["zeigePasswoerter"] = "Poka" + z_pl + " has" + l_pl + "o";
  1464. texte["autoLogin"] = "Automatyczne logowanie";
  1465. texte["accountAktiv"] = "Konto aktywne";
  1466. texte["server"] = "Serwer";
  1467. texte["ungueltigerServer"] = "B" + l_pl + e_pl + "dny serwer";
  1468. texte["name"] = "Login";
  1469. texte["passwort"] = "Has" + l_pl + "o";
  1470. texte["speichern"] = "Zapisz";
  1471. texte["loeschen"] = "Usu" + n_pl;
  1472. texte["buy"] = "Kup";
  1473. texte["cancel"] = "Anuluj";
  1474. texte["autoBuy"] = "Kup leki";
  1475. texte["autoClean"] = "Wyczy" + s_pl + c_pl + " pokoje";
  1476. texte["autoNurse"] = "Zadzwo" + n_pl + " po piel" + e_pl + "gniark" + e_pl + ".";
  1477. texte["autoDisposeMedi"] = "Rozprowad" + x_pl + " leki";
  1478. // patients panel
  1479. texte["zeigeGeheilteKrankheiten"] = "Poka" + z_pl + " wyleczone choroby";
  1480. texte["minipics"] = "Małe obrazki";
  1481. texte["Beschreibung"] = "untreated/overall";
  1482. texte["Beschreibung2"] = "helptext to understand this window: Number of untreated diseases without those currently treated/overall number";
  1483. texte["frei"] = "Wolni";
  1484. texte["inBehandlung"] = "Leczony";
  1485. texte["waitingroom"] = "Poczekalnia";
  1486. texte["Gesamt"] = "Og" + o_pl + l_pl + "em";
  1487. texte["Patients"] = "Pacjenci";
  1488. texte["Rooms"] = "Pomieszczenia";
  1489. // Buy medics view
  1490. texte["BuyMedics"] = "Kupowanie leków";
  1491. texte["Buying"] = "Kupowanie";
  1492. texte["Dsignation"] = "Nazwa";
  1493. texte["Price"] = "Cena";
  1494. // Exchange
  1495. texte["showUncurable"] = "Poka" + z_pl + " nieuleczalnych";
  1496. //Systemwords
  1497. texte["waehrung"] = "hT"; //Global._KH_CURRENCY
  1498. texte["coins"] = "Monety";
  1499. // Quicklinks
  1500. texte["shop1"] = "Apteka Sza" + l_pl + "pigu" + l_pl;
  1501. texte["quildhouse"] = "Zwi" + a_pl + "zek lekarzy i konkursy";
  1502. texte["townhall"] = "Ratusz";
  1503. texte["shop2"] = "Hurtownia G.Rypa";
  1504. texte["editoraloffice"] = "3";
  1505. texte["ambulancestore"] = "Autokomis";
  1506. texte["rcenter"] = "Instytut badawczy";
  1507. texte["shop3"] = "Kafejka internetowa";
  1508. texte["architect"] = "Biuro architektoniczne";
  1509. texte["shop4"] = "Sklepik pani Wandzi";
  1510. texte["busstop"] = "Przystanek autobusowy";
  1511. texte["speakers"] = "Mr. Gafon";
  1512. texte["garage"] = "Gara" + z_pl;
  1513. texte["bank"] = "Bank";
  1514. texte["exchange"] = "Gie" + l_pl + "da pacjent" + o_pl + "w";
  1515. texte["goodgirl"] = "Panienka z okienka";
  1516. texte["badboy"] = "Dr S. Raczek";
  1517. break;
  1518.  
  1519. case "cz":
  1520. texte["berater"] = "Poradce";
  1521. texte["autologin1"] = "Kontroluji aktivn" + i_cz + " relace. " + c_cz + "ekejte pros" + i_cz + "m 5 sekund<br>...";
  1522. texte["autologin2"] = "V" + s_cz + "echny " + u_cz + c_cz + "ty p" + r_cz + "ihl" + a_cz + s_cz + "eny.";
  1523. texte["options"] = "Mo" + z_cz + "nosti";
  1524. texte["fertig"] = "Hotovo";
  1525. texte["shopNotAvailable"] = "Obchod nen" + i_cz + " dostupn" + y_cz;
  1526. texte["noch"] = "Zb" + y_cz + "v" + a_cz;
  1527. texte["FloorTime"] = "Floor time";
  1528. texte["GlobalTime"] = "Global time";
  1529. // options panel
  1530. texte["set_ScriptHomepage"] = "Domovsk" + a_cz + " str" + a_cz + "nka Scriptu";
  1531. texte["set_AutoLogin"] = "Automatick" + e_cz + " p" + r_cz + "ihla" + s_cz + "ov" + a_cz + "n" + i_cz;
  1532. texte["set_Update"] = "Aktualizace";
  1533. texte["set_RackLow"] = "Minim" + a_cz + "ln" + i_cz + " z" + a_cz + "soba l" + e_cz + "k" + u2_cz;
  1534. texte["set_RackMax"] = "Automatic buying limit";
  1535. texte["set_valGlobalClockInTitle"] = c_cz + "as v n" + a_cz + "zvu karty.";
  1536. texte["set_valStartQuestAutomatic"] = "AutoQuest";
  1537. texte["info_AutoLogin"] = "Jakmile zad" + a_cz + "te sv" + e_cz + " u" + z_cz + "ivatelsk" + e_cz + " jm" + e_cz + "no a heslo, v" + s_cz + "echny " + u_cz + c_cz + "ty budou p" + r_cz + "ihl" + a_cz + s_cz + "eny.";
  1538. texte["info_Update"] = "Automaticky kontroluje, zda je k dispozici nov" + e2_cz + "j" + s_cz + i_cz + " verze tohoto Poradce.";
  1539. texte["info_RackLow"] = "Ozna" + c_cz + i_cz + " l" + e_cz + "ky, jejich" + z_cz + " mno" + z_cz + "stv" + i_cz + " klesne pod zadanou hodnotu.";
  1540. texte["info_RackMax"] = "By Automatic buying product will be purchased until reaching this number.";
  1541. texte["info_valGlobalClockInTitle"] = "Zobraz" + i_cz + " glob" + a_cz + "ln" + i_cz + " " + c_cz + "as v titulku okna.";
  1542. texte["info_valStartQuestAutomatic"] = "Soll sofort die n" + ae_de + "chste Quest gestartet werden, wenn eine beended wurde ( max. 8 )?";
  1543. texte["confirmUpdate"] = "Je kdispozici nov" + a_cz + " verze R" + a_cz + "dce Kapi Hospital. Chcete ji nainstalovat?";
  1544. texte["zeigePasswoerter"] = "Uk" + a_cz + "zat heslo";
  1545. texte["autoLogin"] = "Automatick" + e_cz + " p" + r_cz + "ihla" + s_cz + "ov" + a_cz + "n" + i_cz;
  1546. texte["accountAktiv"] = u3_cz + c_cz + "et je aktivn" + i_cz;
  1547. texte["server"] = "Server";
  1548. texte["ungueltigerServer"] = "Neplatn" + y_cz + " server";
  1549. texte["name"] = "Login";
  1550. texte["passwort"] = "Heslo";
  1551. texte["speichern"] = "Ulo" + z_cz + "it";
  1552. texte["loeschen"] = "Vymazat";
  1553. texte["buy"] = "kaufen";
  1554. texte["cancel"] = "Abbrechen";
  1555. texte["autoBuy"] = "automatische Lagerauff" + ue_de + "llung";
  1556. texte["autoClean"] = "R" + ae_de + "ume s" + ae_de + "ubern";
  1557. texte["autoNurse"] = "Krankenschwester rufen";
  1558. texte["autoDisposeMedi"] = "Medikamente verteilen";
  1559. // patients panel
  1560. texte["zeigeGeheilteKrankheiten"] = "Zobrazit vyl" + e_cz + c_cz + "iteln" + e_cz;
  1561. texte["minipics"] = "Miniobr" + a_cz + "zky";
  1562. texte["Beschreibung"] = "unbehandelt/Gesamt";
  1563. texte["Beschreibung2"] = "Hilfetext um dieses Fenster zu verstehen: Anzahl dieser Krankheit unbehandelt ohne gerade in Behandlung befindliche/Anzahl Gesamt";
  1564. texte["frei"] = "Voln" + e_cz;
  1565. texte["inBehandlung"] = "Vyl" + e_cz + c_cz + "eno";
  1566. texte["waitingroom"] = c_cz + "ek" + a_cz + "rna";
  1567. texte["Gesamt"] = "Gesamt";
  1568. texte["Rooms"] = "Rooms";
  1569. texte["Patients"] = "Patients";
  1570. // Buy medics view
  1571. texte["BuyingMedics"] = "Buying medics";
  1572. texte["Buying"] = "Buying";
  1573. texte["Dsignation"] = "Designation";
  1574. texte["Price"] = "Price";
  1575. // Exchange
  1576. texte["showUncurable"] = "Zobrazit nevyl" + e_cz + c_cz + "iteln" + e_cz;
  1577. //Systemwords
  1578. texte["waehrung"] = "hT"; //Global._KH_CURRENCY
  1579. texte["coins"] = "Mince";
  1580. // Quicklinks
  1581. texte["shop1"] = "";
  1582. texte["quildhouse"] = "";
  1583. texte["townhall"] = "";
  1584. texte["shop2"] = "";
  1585. texte["editoraloffice"] = "";
  1586. texte["ambulancestore"] = "";
  1587. texte["rcenter"] = "";
  1588. texte["shop3"] = "";
  1589. texte["architect"] = "";
  1590. texte["shop4"] = "";
  1591. texte["busstop"] = "";
  1592. texte["speakers"] = "";
  1593. texte[""] = "";
  1594. texte["garage"] = "";
  1595. texte["bank"] = "";
  1596. texte["exchange"] = "";
  1597. texte["goodgirl"] = "";
  1598. texte["badboy"] = "";
  1599. break;
  1600. }
  1601. }
  1602.  
  1603. function $(ID) {
  1604. return document.getElementById(ID)
  1605. }
  1606.  
  1607. function removeElement(node) {
  1608. node.parentNode.removeChild(node)
  1609. }
  1610.  
  1611. function createElement(type, attributes, append, inner) {
  1612. var node = document.createElement(type);
  1613.  
  1614. for (var attr in attributes) {
  1615. if (attr == "checked") {
  1616. node.checked = attributes[attr];
  1617. }
  1618. else if (attributes.hasOwnProperty(attr)) {
  1619. node.setAttribute(attr, attributes[attr]);
  1620. }
  1621. }
  1622.  
  1623. if (append) {
  1624. append.appendChild(node);
  1625. }
  1626.  
  1627. if (inner) {
  1628. node.innerHTML = inner;
  1629. }
  1630.  
  1631. return node;
  1632. }
  1633.  
  1634. function click(A) {
  1635. var B = document.createEvent("MouseEvents");
  1636.  
  1637. B.initEvent("click", true, true);
  1638. A.dispatchEvent(B);
  1639.  
  1640. if (A.href) {
  1641. document.location.href = A.href;
  1642. }
  1643. }
  1644.  
  1645. function mousedown(A) {
  1646. var B = document.createEvent("MouseEvents");
  1647.  
  1648. B.initEvent("mousedown", true, true);
  1649. A.dispatchEvent(B);
  1650. }
  1651.  
  1652. function mousemove(A) {
  1653. var B = document.createEvent("MouseEvents");
  1654.  
  1655. B.initEvent("mousemove", true, true);
  1656. A.dispatchEvent(B);
  1657. }
  1658.  
  1659. function number_format(number, decimals, dec_point, thousands_sep) {
  1660. // http://kevin.vanzonneveld.net
  1661. // + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
  1662. // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  1663. // + bugfix by: Michael White (http://getsprink.com)
  1664. // + bugfix by: Benjamin Lupton
  1665. // + bugfix by: Allan Jensen (http://www.winternet.no)
  1666. // + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
  1667. // + bugfix by: Howard Yeend
  1668. // + revised by: Luke Smith (http://lucassmith.name)
  1669. // + bugfix by: Diogo Resende
  1670. // + bugfix by: Rival
  1671. // % note 1: For 1000.55 result with precision 1 in FF/Opera is 1,000.5, but in IE is 1,000.6
  1672. // * example 1: number_format(1234.56);
  1673. // * returns 1: '1,235'
  1674. // * example 2: number_format(1234.56, 2, ',', ' ');
  1675. // * returns 2: '1 234,56'
  1676. // * example 3: number_format(1234.5678, 2, '.', '');
  1677. // * returns 3: '1234.57'
  1678. // * example 4: number_format(67, 2, ',', '.');
  1679. // * returns 4: '67,00'
  1680. // * example 5: number_format(1000);
  1681. // * returns 5: '1,000'
  1682. // * example 6: number_format(67.311, 2);
  1683. // * returns 6: '67.31'
  1684.  
  1685. var n = number, prec = decimals;
  1686. n = !isFinite(+n) ? 0 : +n;
  1687. prec = !isFinite(+prec) ? 0 : Math.abs(prec);
  1688. var sep = (typeof thousands_sep == "undefined") ? delimThou : thousands_sep; // changed!
  1689. var dec = (typeof dec_point == "undefined") ? delimDeci : dec_point; // changed!
  1690.  
  1691. var s = (prec > 0) ? n.toFixed(prec) : Math.round(n).toFixed(prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;
  1692.  
  1693. var abs = Math.abs(n).toFixed(prec);
  1694. var _, i;
  1695.  
  1696. if (abs >= 1000) {
  1697. _ = abs.split(/\D/);
  1698. i = _[0].length % 3 || 3;
  1699.  
  1700. _[0] = s.slice(0, i + (n < 0)) +
  1701. _[0].slice(i).replace(/(\d{3})/g, sep + '$1');
  1702.  
  1703. s = _.join(dec);
  1704. }
  1705. else {
  1706. s = s.replace('.', dec);
  1707. }
  1708.  
  1709. return s;
  1710. }
  1711.  
  1712. function hT_format(number) {
  1713. return number_format(number, 2) + "&nbsp;" + Global._KH_CURRENCY;
  1714. }
  1715.  
  1716. function hT_formatgr(number) {
  1717. return number_format(number, 0) + "&nbsp;" + Global._KH_CURRENCY;
  1718. }
  1719.  
  1720. function keepDigits(str) {
  1721. return str.replace(/[^0-9]/g, "");
  1722. }
  1723.  
  1724. function calc_overall() {
  1725. var checkboxes = $('buyquest2').querySelectorAll('input[type="checkbox"]');
  1726. var overall = 0.00;
  1727.  
  1728. for (var i = 0; i < checkboxes.length; i++) {
  1729. if (checkboxes[i].checked) {
  1730. var medid = checkboxes[i].id.split('#')[0];
  1731. var amount = $('am_' + medid).value;
  1732.  
  1733. var medprice = number_format((Global.availableMedics[0]["med" + medid]["price"] * amount), 2, ',', '.');
  1734. $('prc' + medid).innerHTML = medprice + " " + Global._KH_CURRENCY;
  1735.  
  1736. overall += parseFloat((Global.availableMedics[0]["med" + medid]["price"] * amount), 2);
  1737. }
  1738. }
  1739.  
  1740. if ($('prover')) {
  1741. $('prover').innerHTML = hT_format(overall);
  1742. }
  1743. }
  1744.  
  1745. function time2str(time, mode) {
  1746. str = "";
  1747. time = Math.max(0, time);
  1748. tmp = "";
  1749.  
  1750. //seconds
  1751. if (!mode || mode == 2) {
  1752. if (time % 60 >= 10) {
  1753. str += ":" + Math.floor(time % 60);
  1754. }
  1755. else {
  1756. str += ":0" + Math.floor(time % 60);
  1757. }
  1758. }
  1759.  
  1760. //minutes
  1761. time /= 60;
  1762. if (mode != 2) {
  1763. tmp = ":";
  1764. }
  1765.  
  1766. if (time >= 1) {
  1767. if (time % 60 >= 10) {
  1768. str = tmp + Math.floor(time % 60) + str;
  1769. }
  1770. else {
  1771. str = tmp + "0" + Math.floor(time % 60) + str;
  1772. }
  1773. }
  1774. else {
  1775. str = tmp + "00" + str;
  1776. }
  1777.  
  1778. if (mode != 2) {
  1779. //hours
  1780. time /= 60;
  1781. if (time >= 1) {
  1782. str = Math.floor(time % 24) + str;
  1783. }
  1784. else {
  1785. str = "0" + str;
  1786. }
  1787.  
  1788. //days
  1789. time /= 24;
  1790.  
  1791. if (time >= 1) {
  1792. str = Math.floor(time) + "d " + str;
  1793. }
  1794. }
  1795.  
  1796. return str;
  1797. }
  1798.  
  1799. function uhrzeit(time, mode) {
  1800. var help = new Date(time * 1000);
  1801.  
  1802. if (help.getHours() < 10) {
  1803. var str = "0" + help.getHours();
  1804. }
  1805. else {
  1806. var str = help.getHours();
  1807. }
  1808.  
  1809. if (help.getMinutes() < 10) {
  1810. str += ":0" + help.getMinutes();
  1811. }
  1812. else {
  1813. str += ":" + help.getMinutes();
  1814. }
  1815.  
  1816. if (!mode) {
  1817. if (help.getSeconds() < 10) {
  1818. str += ":0" + help.getSeconds();
  1819. }
  1820. else {
  1821. str += ":" + help.getSeconds();
  1822. }
  1823. }
  1824.  
  1825. return str;
  1826. }
  1827.  
  1828. function explode(str) {
  1829. //GM_log("Begin explode "+ str);
  1830. if (str == "") {
  1831. throw("Explode error Argument empty");
  1832. }
  1833.  
  1834. if (str == "undefined") {
  1835. throw ("Explode error Argument is undefined");
  1836. }
  1837.  
  1838. if (typeof str != "string") {
  1839. throw ("Explode error Argument not a String");
  1840. }
  1841.  
  1842. try {
  1843. return eval('(' + str + ')');
  1844. } catch (err) {
  1845. GM_log("Explode error : " + err);
  1846. throw ("Explode error : " + err);
  1847. }
  1848. }
  1849.  
  1850. console.log( info + "Start implode(arr)");
  1851.  
  1852. function implode(arr) {//--- function written by Jan-Hans
  1853. try {
  1854. var line = String();
  1855. var InternalCounter = -1;
  1856. var NoKey = Boolean(false);
  1857.  
  1858. if (typeof arr != "object") {
  1859. throw("Argument not a Object or Array" + typeof arr + "<br>");
  1860. }
  1861.  
  1862. var type = (arr instanceof Array); //true->array | false->object
  1863.  
  1864. line = (type) ? "[" : "{";
  1865. for (var i in arr) {
  1866. if (typeof arr[i] == "function")
  1867. continue;
  1868.  
  1869. InternalCounter++;
  1870. if (type) {
  1871. while (i > InternalCounter) {
  1872. line += ",";
  1873. InternalCounter++;
  1874. }
  1875. } else { //arr == object
  1876. line += "\"" + i + "\"";
  1877. line += ":";
  1878. }
  1879.  
  1880. if (typeof arr[i] == "number" || typeof arr[i] == "boolean") {
  1881. line += arr[i];
  1882. } else if (typeof arr[i] == "string") {
  1883. line += "\"" + arr[i] + "\"";
  1884. } else if (typeof arr[i] == "undefined") {
  1885. line += '';
  1886. } else {
  1887. line += implode(arr[i]);
  1888. }
  1889.  
  1890. line += ",";
  1891. }
  1892.  
  1893. var endChar = line.substring(line.length - 1, line.length);
  1894.  
  1895. return line.substring(0, line.length - 1) + (("{[".indexOf(endChar) != -1) ? endChar : "") + ((type) ? "]" : "}");
  1896. } catch (err) {
  1897. GM_log("Implode error : " + err);
  1898. throw ("Implode error : " + err);
  1899. }
  1900. }
  1901.  
  1902. function Log(obj, pre) {
  1903. if (developer) {
  1904. if (typeof(pre) == "undefined") {
  1905. pre = "";
  1906. }
  1907.  
  1908. if (typeof(obj) == "object") {
  1909. //GM_log("______________________________ object");
  1910. for (var v in obj) {
  1911. Log(obj[v], pre + v + " : ");
  1912. }
  1913. //GM_log("______________________________ object end");
  1914. } else {
  1915. GM_log(pre + obj);
  1916. }
  1917. }
  1918. }
  1919.  
  1920. function closeInfoPanel() {
  1921. $("infoPanel").setAttribute("name", "");
  1922. $("infoPanel").style.display = "none";
  1923. }
  1924.  
  1925. function buildInfoPanel(mode) {
  1926.  
  1927. if (mode == $("infoPanel").getAttribute("name")) {
  1928. closeInfoPanel();
  1929. }
  1930. else {
  1931. $("infoPanel").setAttribute("name", mode);
  1932. $("infoPanel").innerHTML = "";
  1933. $("infoPanel").style.display = "block";
  1934.  
  1935. divInfo = createElement("div", {style: "position:absolute;left:20px;top:80px;width:570px;height:400px;overflow:auto;"}, $("infoPanel"));
  1936. newdiv = createElement("img", {
  1937. class: "cursorclickable",
  1938. style: "font-size:10px;position:absolute;height:35px;width:35px;right:10px;top:2px;"
  1939. }, $("infoPanel"));
  1940. newdiv.addEventListener("click", closeInfoPanel, false);
  1941.  
  1942. if (mode == "options") {
  1943. createElement("div", {
  1944. align: "center",
  1945. style: "line-height:30px;font-weight:bold;"
  1946. }, divInfo, texte["options"]);
  1947. newtable = createElement("table", {style: "width:100%;", border: "1"}, divInfo);
  1948.  
  1949. newtr = createElement("tr", "", newtable);
  1950. newtd = createElement("td", {align: "center"}, newtr);
  1951. var valUpdate = GM_getValue("valUpdate", true);
  1952. inp = createElement("input", {
  1953. id: "inputvalUpdate",
  1954. type: "checkbox",
  1955. class: "link",
  1956. checked: valUpdate
  1957. }, newtd);
  1958. inp.addEventListener("click", function () {
  1959. valUpdate = this.checked;
  1960. GM_setValue("valUpdate", valUpdate);
  1961. }, false);
  1962. createElement("td", "", newtr, texte["set_Update"]);
  1963. createElement("td", "", newtr, texte["info_Update"]);
  1964.  
  1965. newtr = createElement("tr", "", newtable);
  1966. newtd = createElement("td", {align: "center"}, newtr);
  1967. inp = createElement("input", {
  1968. id: "inputvalGlobalClockInTitle",
  1969. type: "checkbox",
  1970. class: "link",
  1971. checked: valGlobalClockInTitle
  1972. }, newtd);
  1973. inp.addEventListener("click", function () {
  1974. valGlobalClockInTitle = this.checked;
  1975. GM_setValue(lng + "_" + server + "_" + username + "_valGlobalClockInTitle", valGlobalClockInTitle);
  1976. }, false);
  1977. createElement("td", "", newtr, texte["set_valGlobalClockInTitle"]);
  1978. createElement("td", "", newtr, texte["info_valGlobalClockInTitle"]);
  1979.  
  1980. newtr = createElement("tr", "", newtable);
  1981. newtd = createElement("td", {align: "center"}, newtr);
  1982. newinput = createElement("input", {
  1983. id: "inputvalRackLimit",
  1984. value: valRackLimit,
  1985. maxlength: "5",
  1986. size: "5px",
  1987. style: "background-color:transparent;"
  1988. }, newtd);
  1989. newinput.addEventListener("focus", function () {
  1990. this.style.backgroundColor = "lightblue";
  1991. }, false);
  1992. newinput.addEventListener("blur", function () {
  1993. this.style.backgroundColor = "transparent";
  1994. }, false);
  1995. newinput.addEventListener("keyup", function () {
  1996. valRackLimit = parseInt(this.value, 10);
  1997. if (!isNaN(valRackLimit)) {
  1998. GM_setValue(lng + "_" + server + "_" + username + "_valRackLimit", valRackLimit);
  1999. }
  2000. this.value = (isNaN(valRackLimit) ? "" : valRackLimit);
  2001. }, false);
  2002. createElement("td", "", newtr, texte["set_RackLow"]);
  2003. createElement("td", "", newtr, texte["info_RackLow"]);
  2004.  
  2005. newtr = createElement("tr", "", newtable);
  2006. newtd = createElement("td", {align: "center"}, newtr);
  2007. newinput = createElement("input", {
  2008. id: "inputvalMaxRackLimit",
  2009. value: valMaxRackLimit,
  2010. maxlength: "5",
  2011. size: "5px",
  2012. style: "background-color:transparent;"
  2013. }, newtd);
  2014. newinput.addEventListener("focus", function () {
  2015. this.style.backgroundColor = "lightblue";
  2016. }, false);
  2017. newinput.addEventListener("blur", function () {
  2018. this.style.backgroundColor = "transparent";
  2019. }, false);
  2020. newinput.addEventListener("keyup", function () {
  2021. valMaxRackLimit = parseInt(this.value, 10);
  2022. if (!isNaN(valMaxRackLimit)) {
  2023. GM_setValue(lng + "_" + server + "_" + username + "_valMaxRackLimit", valMaxRackLimit);
  2024. }
  2025. this.value = (isNaN(valMaxRackLimit) ? "" : valMaxRackLimit);
  2026. }, false);
  2027. createElement("td", "", newtr, texte["set_RackMax"]);
  2028. createElement("td", "", newtr, texte["info_RackMax"]);
  2029.  
  2030. newtr = createElement("tr", "", newtable);
  2031. newtd = createElement("td", {align: "center"}, newtr);
  2032. inp = createElement("input", {
  2033. id: "inputvalStartQuestAutomatic",
  2034. type: "checkbox",
  2035. class: "link",
  2036. checked: valStartQuestAutomatic
  2037. }, newtd);
  2038. inp.addEventListener("click", function () {
  2039. valStartQuestAutomatic = this.checked;
  2040. GM_setValue(lng + "_" + server + "_" + username + "_valStartQuestAutomatic", valStartQuestAutomatic);
  2041. }, false);
  2042. createElement("td", "", newtr, texte["set_valStartQuestAutomatic"]);
  2043. createElement("td", "", newtr, texte["info_valStartQuestAutomatic"]);
  2044.  
  2045. //AutoLogin
  2046. createElement("div", {
  2047. align: "center",
  2048. style: "line-height:30px;margin-top:20px;font-weight:bold;"
  2049. }, divInfo, texte["autoLogin"]);
  2050. newtable = createElement("table", {id: "tableAutologin", align: "center"}, divInfo);
  2051.  
  2052. buildLoginTable(false);
  2053.  
  2054. newdiv = createElement("div", {align: "center"}, divInfo);
  2055. newinput = createElement("input", {type: "checkbox", class: "cursorclickable", checked: false}, newdiv);
  2056. newinput.addEventListener("click", function () {
  2057. buildLoginTable(this.checked);
  2058. }, false);
  2059. newspan = createElement("span", "", newdiv, texte["zeigePasswoerter"]);
  2060.  
  2061.  
  2062. //CSS
  2063. var cssArr = {};
  2064. cssArr["css_racklow"] = [
  2065. [],
  2066. "background-color:orangered;"
  2067. ];
  2068. createElement("div", {
  2069. align: "center",
  2070. style: "line-height:30px;margin-top:20px;font-weight:bold;"
  2071. }, divInfo, "CSS");
  2072. newtable = createElement("table", {align: "center"}, divInfo);
  2073. for (var v in cssArr) {
  2074. newtr = createElement("tr", "", newtable);
  2075. createElement("td", "", newtr, v);
  2076. newtd = createElement("td", "", newtr);
  2077. var help = GM_getValue(lng + "_" + server + "_" + username + "_" + v, cssArr[v][1]);
  2078. newinput = createElement("input", {id: v, value: help, style: "width:300px;"}, newtd);
  2079. newinput.addEventListener("keyup", function () {
  2080. if (this.value == "") {
  2081. this.value = cssArr[this.id][1];
  2082. }
  2083. GM_setValue(lng + "_" + server + "_" + username + "_" + this.id, this.value);
  2084. cssArr[this.id][1] = this.value;
  2085. var help = cssArr[this.id][1];
  2086. for (var w = 0; w < cssArr[this.id][0].length; w++) {
  2087. help = cssArr[cssArr[this.id][0][w]][1] + help;
  2088. }
  2089. this.parentNode.nextSibling.firstChild.setAttribute("style", help);
  2090. }, false);
  2091. newtd = createElement("td", "", newtr);
  2092. for (var w = 0; w < cssArr[v][0].length; w++) {
  2093. help = cssArr[cssArr[v][0][w]][1] + help;
  2094. }
  2095. newdiv = createElement("div", {style: help}, newtd, "test");
  2096. }
  2097. }
  2098.  
  2099. if (mode == "patients") {
  2100. buildPatientsTable(1, true, false);
  2101. }
  2102. }
  2103. }
  2104.  
  2105. function saveLogin() {
  2106. GM_setValue("logindata", implode(logindata));
  2107. }
  2108.  
  2109. function buildLoginTable(showPW) {
  2110.  
  2111. try {
  2112. logindata = explode(GM_getValue("logindata", "[]"));
  2113. }
  2114. catch (err) {
  2115. logindata = [];
  2116. }
  2117.  
  2118. newtable = createElement("table", {align: "center"});
  2119. $("tableAutologin").parentNode.replaceChild(newtable, $("tableAutologin"));
  2120. newtable.id = "tableAutologin";
  2121. newtable.addEventListener("change", saveLogin, false);
  2122. newtr = createElement("tr", {}, newtable);
  2123. createElement("th", {}, newtr, texte["server"]);
  2124. createElement("th", {}, newtr, texte["name"]);
  2125. createElement("th", {}, newtr, texte["passwort"]);
  2126.  
  2127. for (var v = 0; v < logindata.length; v++) {
  2128. newtr = createElement("tr", "", newtable);
  2129. newtd = createElement("td", "", newtr);
  2130. newinp = createElement("input", {
  2131. id: "loginActive" + v,
  2132. type: "checkbox",
  2133. title: texte["accountAktiv"],
  2134. checked: logindata[v][4]
  2135. }, newtd);
  2136. newinp.addEventListener("change", function () {
  2137. logindata[this.id.replace("loginActive", "")][4] = this.checked;
  2138. }, false);
  2139. newinp = createElement("input", {id: "loginServer" + v, style: "width:20px", maxlength: "2"}, newtd);
  2140.  
  2141. if (isNaN(logindata[v][1])) {
  2142. logindata[v][1] = "0";
  2143. }
  2144.  
  2145. if (logindata[v][1] != "0") {
  2146. newinp.value = logindata[v][1];
  2147. }
  2148.  
  2149. newinp.addEventListener("change", function () {
  2150. var readin = parseInt(this.value, 10);
  2151. if (isNaN(readin) || (readin < 1)) {
  2152. alert(texte["ungueltigerServer"]);
  2153. this.value = "";
  2154. }
  2155. else {
  2156. this.value = readin;
  2157. logindata[this.id.replace("loginServer", "")][1] = readin;
  2158. }
  2159. }, false);
  2160.  
  2161. newselect = createElement("select", {id: "loginLng" + v}, newtd);
  2162. for (var w in gamepages) {
  2163. createElement("option", {value: w}, newselect, w);
  2164. }
  2165. newselect.value = logindata[v][0];
  2166. newselect.addEventListener("change", function () {
  2167. logindata[this.id.replace("loginLng", "")][0] = this.value;
  2168. }, false);
  2169.  
  2170. newtd = createElement("td", "", newtr);
  2171. newinput = createElement("input", {
  2172. id: "loginName" + v,
  2173. style: "width:150px",
  2174. value: logindata[v][2],
  2175. maxlength: "20"
  2176. }, newtd);
  2177. newinput.addEventListener("change", function () {
  2178. logindata[this.id.replace("loginName", "")][2] = this.value;
  2179. }, false);
  2180.  
  2181. newtd = createElement("td", {}, newtr);
  2182. newinput = createElement("input", {
  2183. id: "loginPW" + v,
  2184. style: "width:150px",
  2185. value: logindata[v][3],
  2186. maxlength: "20"
  2187. }, newtd);
  2188.  
  2189. if (!showPW) {
  2190. newinput.type = "password";
  2191. }
  2192.  
  2193. newinput.addEventListener("change", function () {
  2194. logindata[this.id.replace("loginPW", "")][3] = this.value;
  2195. }, false);
  2196.  
  2197. newtd = createElement("td", "", newtr);
  2198. if (v > 0) {
  2199. newdiv = createElement("div", {
  2200. id: "loginUp" + v,
  2201. class: "link2",
  2202. style: "width:14px;height:10px;"
  2203. }, newtd);
  2204. createElement("img", {
  2205. src: "http://dqt9wzym747n.cloudfront.net/pics/quest_up.gif",
  2206. style: "width:14px;height:10px;"
  2207. }, newdiv);
  2208. newdiv.addEventListener("mouseover", function () {
  2209. this.style.backgroundColor = "blue"
  2210. }, false);
  2211. newdiv.addEventListener("mouseout", function () {
  2212. this.style.backgroundColor = "transparent"
  2213. }, false);
  2214. newdiv.addEventListener("click", function () {
  2215. var currLine = parseInt(this.id.replace("loginUp", ""), 10);
  2216. logindata.splice(currLine - 1, 2, logindata[currLine], logindata[currLine - 1]);
  2217. saveLogin();
  2218. buildLoginTable(showPW);
  2219. }, false);
  2220. }
  2221.  
  2222. if (v < logindata.length - 1) {
  2223. newdiv = createElement("div", {
  2224. id: "loginDown" + v,
  2225. class: "link2",
  2226. style: "width:14px;height:10px;"
  2227. }, newtd);
  2228. createElement("img", {
  2229. src: "http://dqt9wzym747n.cloudfront.net/pics/quest_down.gif",
  2230. style: "width:14px;height:10px;"
  2231. }, newdiv);
  2232. newdiv.addEventListener("mouseover", function () {
  2233. this.style.backgroundColor = "blue"
  2234. }, false);
  2235. newdiv.addEventListener("mouseout", function () {
  2236. this.style.backgroundColor = "transparent"
  2237. }, false);
  2238. newdiv.addEventListener("click", function () {
  2239. var currLine = parseInt(this.id.replace("loginDown", ""), 10);
  2240. logindata.splice(currLine, 2, logindata[currLine + 1], logindata[currLine]);
  2241. saveLogin();
  2242. buildLoginTable(showPW);
  2243. }, false);
  2244. }
  2245.  
  2246. newtd = createElement("td", {
  2247. title: texte["loeschen"],
  2248. id: "loginDelete" + v
  2249. }, newtr);
  2250. createElement("img", {
  2251. src: "https://cdn2.iconfinder.com/data/icons/windows-8-metro-style/128/delete.png",
  2252. class: "link2",
  2253. style: "width: 16px; height: 16px;"
  2254. }, newtd);
  2255. newtd.addEventListener("mouseover", function () {
  2256. this.style.backgroundColor = "blue"
  2257. }, false);
  2258. newtd.addEventListener("mouseout", function () {
  2259. this.style.backgroundColor = "transparent"
  2260. }, false);
  2261. newtd.addEventListener("click", function () {
  2262. var currLine = this.id.replace("loginDelete", "");
  2263. logindata.splice(currLine, 1);
  2264. saveLogin();
  2265. buildLoginTable(showPW);
  2266. }, false);
  2267. }
  2268.  
  2269. newtr = createElement("tr", "", newtable);
  2270. newtd = createElement("td", {
  2271. colspan: "5",
  2272. class: "link",
  2273. style: "font-weight:bold;font-size:16px;text-align:right;"
  2274. }, newtr, "+");
  2275. newtd.addEventListener("mouseover", function () {
  2276. this.style.backgroundColor = "blue"
  2277. }, false);
  2278. newtd.addEventListener("mouseout", function () {
  2279. this.style.backgroundColor = "transparent"
  2280. }, false);
  2281. newtd.addEventListener("click", function () {
  2282. logindata.push([lng, "0", "", "", "true"]); // New empty line
  2283. saveLogin();
  2284. buildLoginTable(showPW);
  2285. }, false);
  2286. }
  2287.  
  2288. function buildPatientsTable(mode, showCured, minipic) {
  2289. divInfo.innerHTML = "";
  2290. patients = Global.refPatients.values();
  2291. newtable = createElement("table", {border: "1", width: "100%"}, divInfo);
  2292. newtablehead = createElement("thead", "", newtable);
  2293. newtablebody = createElement("tbody", {style: "overflow-y:auto;overflow-x:hidden;height:365px;"}, newtable);
  2294.  
  2295. newtr = createElement("tr", "", newtablehead);
  2296. newth = createElement("th", {colspan: "5"}, newtr);
  2297. newspan = createElement("span", {style: "margin-right:3px"}, newth);
  2298. newinput = createElement("input", {type: "checkbox", checked: showCured, class: "cursorclickable"}, newspan);
  2299. newinput.addEventListener("click", function () {
  2300. buildPatientsTable(mode, this.checked, minipic);
  2301. }, false);
  2302. createElement("span", "", newspan, texte["zeigeGeheilteKrankheiten"]);
  2303. newspan = createElement("span", {style: "margin-right:3px"}, newth);
  2304. newinput = createElement("input", {type: "checkbox", checked: minipic, class: "cursorclickable"}, newspan);
  2305. newinput.addEventListener("click", function () {
  2306. buildPatientsTable(mode, showCured, this.checked);
  2307. }, false);
  2308. createElement("span", "", newspan, texte["minipics"]);
  2309. newinput = createElement("input", {
  2310. type: "button",
  2311. style: "margin-right:3px",
  2312. value: texte["Patients"],
  2313. class: "cursorclickable"
  2314. }, newth);
  2315. newinput.addEventListener("click", function () {
  2316. buildPatientsTable(1, showCured, minipic);
  2317. }, false);
  2318. newinput = createElement("input", {
  2319. type: "button",
  2320. style: "margin-right:3px",
  2321. value: texte["Rooms"],
  2322. class: "cursorclickable"
  2323. }, newth);
  2324. newinput.addEventListener("click", function () {
  2325. buildPatientsTable(2, showCured, minipic);
  2326. }, false);
  2327.  
  2328. if (mode == 1) {
  2329. for (var posi = 0; posi < 3; posi++) {
  2330. for (var pat in patientDiseases) {
  2331. switch (patientDiseases[pat]["state"]) {
  2332. case 1:
  2333. case 2:
  2334. if (posi == 0) {
  2335. newtr = createElement("tr", {
  2336. "id": pat,
  2337. "class": "cursorclickable",
  2338. "onclick": 'show_page("medical",this)'
  2339. }, newtablebody);
  2340. newtr.addEventListener("click", closeInfoPanel, false);
  2341. createElement("td", "", newtr, pat);
  2342. createElement("td", {colspan: "2"}, newtr, Global.availableRooms[6]["name"]);
  2343. newtd = createElement("td", {style: "padding-right:30px"}, newtr);
  2344. plotPatient(newtd, pat, showCured, minipic);
  2345. }
  2346. break;
  2347. case 3:
  2348. case 4:
  2349. if (posi == 1) {
  2350. newtr = createElement("tr", {
  2351. "id": pat,
  2352. "class": "cursorclickable",
  2353. "onclick": 'show_page("medical",this)'
  2354. }, newtablebody);
  2355. newtr.addEventListener("click", closeInfoPanel, false);
  2356. createElement("td", "", newtr, pat);
  2357. createElement("td", "", newtr, patientDiseases[pat]["floor"]);
  2358. createElement("td", "", newtr, Global.availableRooms[patientDiseases[pat]["room"]]["name"]);
  2359. newtd = createElement("td", {style: "padding-right:30px"}, newtr);
  2360. plotPatient(newtd, pat, showCured, minipic);
  2361. }
  2362. break;
  2363. case 0:
  2364. if (posi == 2) {
  2365. newtr = createElement("tr", {
  2366. "id": pat,
  2367. "class": "cursorclickable",
  2368. "onclick": 'show_page("medical",this)'
  2369. }, newtablebody);
  2370. newtr.addEventListener("click", closeInfoPanel, false);
  2371. createElement("td", "", newtr, pat);
  2372. createElement("td", {colspan: "2"}, newtr, texte["waitingroom"]);
  2373. newtd = createElement("td", {style: "padding-right:30px"}, newtr);
  2374. plotPatient(newtd, pat, showCured, minipic);
  2375. }
  2376. break;
  2377. }
  2378. }
  2379. newtr = createElement("tr", "", newtablebody);
  2380. createElement("td", {colspan: "4"}, newtr, "");
  2381. }
  2382. } else if (mode == 2) {
  2383. var sumDiseases = {};
  2384. for (var pat in patientDiseases) {
  2385. for (var disease in patientDiseases[pat]) {
  2386. if (!isNaN(disease)) {
  2387. var currRoom = Global.availableDiseases[0][disease]["room"][0];
  2388.  
  2389. if (!sumDiseases[currRoom]) {
  2390. sumDiseases[currRoom] = {};
  2391. }
  2392.  
  2393. if (!sumDiseases[currRoom][disease]) {
  2394. sumDiseases[currRoom][disease] = [0, 0, 0, 0, 0, 0];
  2395. }
  2396.  
  2397. switch (patientDiseases[pat]["state"]) {
  2398. case 1:
  2399. case 2:
  2400. sumDiseases[currRoom][disease][0]++;
  2401. if ((patientDiseases[pat][disease] != "cured") && (patientDiseases[pat][disease] != "heartbeat")) {
  2402. sumDiseases[currRoom][disease][1]++;
  2403. }
  2404. break;
  2405. case 3:
  2406. case 4:
  2407. sumDiseases[currRoom][disease][2]++;
  2408. if ((patientDiseases[pat][disease] != "cured") && (patientDiseases[pat][disease] != "heartbeat")) {
  2409. sumDiseases[currRoom][disease][3]++;
  2410. }
  2411. break;
  2412. case 0:
  2413. sumDiseases[currRoom][disease][4]++;
  2414. if ((patientDiseases[pat][disease] != "cured") && (patientDiseases[pat][disease] != "heartbeat")) {
  2415. sumDiseases[currRoom][disease][5]++;
  2416. }
  2417. break;
  2418. }
  2419. }
  2420. }
  2421. }
  2422.  
  2423. newtr = createElement("tr", "", newtablebody);
  2424. newtd = createElement("td", {title: texte["Beschreibung2"]}, newtr, texte["Beschreibung"]);
  2425. newtd = createElement("td", "", newtr, texte["frei"]);
  2426. newtd = createElement("td", "", newtr, texte["inBehandlung"]);
  2427. newtd = createElement("td", "", newtr, texte["waitingroom"]);
  2428. newtd = createElement("td", "", newtr, texte["Gesamt"]);
  2429.  
  2430. for (var r in sumDiseases) {
  2431. newtr = createElement("tr", "", newtablebody);
  2432. newtd = createElement("td", "", newtr, Global.availableRooms[r].name);
  2433. var totalTotalTime = 0;
  2434.  
  2435. for (var v = 0; v < 4; v++) {
  2436. var totalTime = 0;
  2437. newtd = createElement("td", {style: (v == 3 ? "padding-right:30px;" : "")}, newtr);
  2438.  
  2439. for (var disease in sumDiseases[r]) {
  2440. if (sumDiseases[r][disease][2 * v + ( 1 - showCured )] > 0) {
  2441. newdiv = createElement("div", {style: "float:left;margin-right:2px;"}, newtd);
  2442. createElement("div", {class: "d_a_30 d_" + disease + "_30"}, newdiv);
  2443. createElement("div", "", newdiv, time2str(Global.availableDiseases[0][disease]["basetime"], 1));
  2444. createElement("div", "", newdiv, sumDiseases[r][disease][2 * v + 1] + "/" + sumDiseases[r][disease][2 * v]);
  2445. totalTime += sumDiseases[r][disease][2 * v + 1] * Global.availableDiseases[0][disease]["basetime"];
  2446. }
  2447. }
  2448.  
  2449. totalTotalTime += totalTime;
  2450. if (v == 3) {
  2451. newdiv = createElement("div", {style: "margin-right:2px;font-weight:bold;padding-top:20px;"}, newtd, time2str(totalTotalTime, 1));
  2452. }
  2453. else {
  2454. newdiv = createElement("div", {style: "margin-right:2px;font-weight:bold;padding-top:20px;"}, newtd, time2str(totalTime, 1));
  2455. }
  2456. }
  2457. }
  2458. }
  2459. }
  2460.  
  2461. // Cleaner Function
  2462. function cleaningfunc() {
  2463. var cleaner = $("cleaner");
  2464. var cur_floor = Global.selectedFloor;
  2465. var floor = 1;
  2466.  
  2467. for (var max_floor = 1; $("floor_jump_" + max_floor); max_floor++);
  2468. max_floor--;
  2469.  
  2470. function initfloor(nfloor) {
  2471. $('floor_jump_' + nfloor).click();
  2472.  
  2473. setTimeout(
  2474. function () {
  2475. rooms = Global.rooms;
  2476.  
  2477. for (var v = 0; v < rooms.length; v++) {
  2478. if (( rooms[v].cleanup ) && ( rooms[v].ends == 0 ) && ( rooms[v].roomid != 6 )) {
  2479. var croom = Global.refRooms.get("r" + rooms[v].topleft);
  2480. console.log( info + "Cleaning room: " + rooms[v].topleft);
  2481. croom._onDrop(cleaner, "", "");
  2482. }
  2483. }
  2484.  
  2485. if (floor < max_floor) {
  2486. floor++;
  2487. initfloor(floor);
  2488. }
  2489. else {
  2490. if (floor != cur_floor) {
  2491. $('floor_jump_' + cur_floor).click();
  2492. }
  2493. }
  2494. }, 1000);
  2495. }
  2496.  
  2497. initfloor(floor);
  2498. }
  2499.  
  2500. function medifunc() {
  2501. var cur_floor = Global.selectedFloor;
  2502. var floor = 1;
  2503.  
  2504. for (var max_floor = 1; $("floor_jump_" + max_floor); max_floor++);
  2505. max_floor--;
  2506.  
  2507. function initmedi(nfloor) {
  2508. $('floor_jump_' + nfloor).click();
  2509.  
  2510. setTimeout(
  2511. function () {
  2512. rooms = Global.rooms;
  2513.  
  2514. for (var v = 0; v < rooms.length; v++) {
  2515. if (( currRoom = Global.refRooms.get("r" + rooms[v].topleft) )) {
  2516. if (currRoom["roomid"] != 6) {
  2517. if ((Global.availableRooms[currRoom["roomid"]] ) && (Global.availableRooms[currRoom["roomid"]]["diseases"].length > 0 )) { // Behandlungsraum
  2518.  
  2519. if (currRoom["state"] == 3) {
  2520. if ($("gradient_r" + currRoom["topleft"]) && $("alert" + currRoom.topleft)) {
  2521. // Medis
  2522.  
  2523. var currDisease = null;
  2524. currDisease = calcCurrDisease(currRoom["patient"]);
  2525. //console.log(currDisease);
  2526.  
  2527. if (currDisease) {
  2528. if ($("mediinfo_" + currRoom.topleft)) {
  2529. //console.log( $('rackItem'+medi[currDisease]["id"] ) );
  2530.  
  2531. for (var i = 0; i < unsafeWindow.Rack["_elements"]; i++) {
  2532. if (unsafeWindow.Rack["_elements"][i]["product"] == medi[currDisease]["id"])
  2533. break;
  2534. }
  2535.  
  2536. var med = createElement("div", {
  2537. id: "rackItem" + medi[currDisease]["id"],
  2538. class: "med ri_a",
  2539. medid: medi[currDisease]["id"],
  2540. amount: unsafeWindow.Rack["_elements"][i]["amount"],
  2541. rlevel: unsafeWindow.Rack["_elements"][i]["rlevel"]
  2542. }, null);
  2543.  
  2544. //console.log(med);
  2545. currRoom._onDrop(med, "", "");
  2546. }
  2547. }
  2548. }
  2549. }
  2550. }
  2551. }
  2552. }
  2553. }
  2554.  
  2555. if (floor < max_floor) {
  2556. floor++;
  2557. initmedi(floor);
  2558. }
  2559. else {
  2560. /*
  2561. * error window is shown, close it and start again
  2562. * (its when disease array is not complete)
  2563. */
  2564. if ($("dlg_message").style.display != "none" && $("btn_info")) {
  2565. click($("btn_info"));
  2566. floor = 1;
  2567. initmedi(floor);
  2568. }
  2569.  
  2570. if (floor != cur_floor) {
  2571. $('floor_jump_' + cur_floor).click();
  2572. }
  2573. }
  2574. }
  2575. , 1500);
  2576. }
  2577.  
  2578. initmedi(floor);
  2579. }
  2580.  
  2581. function initPatient(patientId) {
  2582. if (!patientDiseases[patientId]) {
  2583. //console.log("initPatient "+patientId);
  2584. patientDiseases[patientId] = {};
  2585. patientDiseases[patientId]["m"] = 0;
  2586. patientDiseases[patientId]["floor"] = 1;
  2587. //patientDiseases[patientId]["xml"] = 0;
  2588.  
  2589. var help = Global.refPatients.get("p" + patientId);
  2590. if (help) {
  2591. patientDiseases[patientId]["floor"] = help["floor"];
  2592. }
  2593.  
  2594. for (var v = 0; v < help["diseases"].length; v++) {
  2595. patientDiseases[patientId][help["diseases"][v]] = "";
  2596. patientDiseases[patientId]["room" + Global.availableDiseases[0][help["diseases"][v]]["room"][0]] = 1;
  2597. }
  2598. }
  2599.  
  2600. calcPatientState(patientId);
  2601. }
  2602.  
  2603. function refreshPatient(patientId, with_nurse) {
  2604. if (!patientDiseases[patientId]) {
  2605. initPatient(patientId);
  2606. }
  2607.  
  2608. getPatientInfos(patientId, with_nurse);
  2609. }
  2610.  
  2611. function updPatientState(patientId, infos, with_nurse) {
  2612. var cured = true;
  2613. var obj = infos.find('div#medi_diseases');
  2614.  
  2615. // is not set with special diseases
  2616. if (obj[0]) {
  2617. for (var w = 0; w < obj[0].childNodes.length - 3; w++) {
  2618. var disease = (/d_(\d+)_50/).exec(obj[0].childNodes[w].childNodes[1].getAttribute("class"))[1];
  2619.  
  2620. if (obj[0].childNodes[w].childNodes[1].firstChild) {
  2621.  
  2622. patientDiseases[patientId][disease] = (/(.+) (.+)/).exec(obj[0].childNodes[w].childNodes[1].firstChild.getAttribute("class"))[2];
  2623.  
  2624. if (patientDiseases[patientId][disease] == "notreatment") {
  2625. patientDiseases[patientId]["unhealable"] = 1;
  2626. }
  2627.  
  2628.  
  2629. if (patientDiseases[patientId][disease] != "cured") {
  2630. cured = false;
  2631. }
  2632. else {
  2633. patientDiseases[patientId]["room" + Global.availableDiseases[0][disease]["room"][0]] = 0;
  2634. }
  2635. }
  2636. else {
  2637. patientDiseases[patientId][disease] = "";
  2638. patientDiseases[patientId]["room" + Global.availableDiseases[0][disease]["room"][0]] = 1;
  2639.  
  2640. cured = false;
  2641. }
  2642. }
  2643. }
  2644. else {
  2645. //special disease
  2646. for (var disease in patientDiseases[patientId]) {
  2647. if (!isNaN(disease)) {
  2648. patientDiseases[patientId][disease] = "cured";
  2649. break;
  2650. }
  2651. }
  2652. }
  2653.  
  2654.  
  2655. // nurse
  2656. var canddiv = infos.find('.minitreatment');
  2657. patientDiseases[patientId]["m"] = 4;
  2658.  
  2659. for (var v = 0; v < canddiv.length; v++) {
  2660. if (canddiv[v].style.backgroundImage == "") {
  2661. patientDiseases[patientId]["m"]--;
  2662. cured = false;
  2663. }
  2664. }
  2665.  
  2666.  
  2667. if (with_nurse) {
  2668. for (var v = 0; v < canddiv.length; v++) {
  2669. if (canddiv[v].style.backgroundImage == "") {
  2670. var help = Global.refPatients.get("p" + patientId);
  2671. if (!( $("treatment" + help["room"]) )) {
  2672. unsafeWindow.MedicalRecord._onclick(canddiv[v], patientId);
  2673. break;
  2674. }
  2675. }
  2676. }
  2677. }
  2678.  
  2679. if (cured) {
  2680. patientDiseases[patientId]["state"] = 5;
  2681. }
  2682. else {
  2683. calcComesNext(patientId);
  2684. }
  2685.  
  2686. calcPatientState(patientId);
  2687. }
  2688.  
  2689. function calcPatientState(patientId) {
  2690. var help = Global.refPatients.get("p" + patientId);
  2691. var help2 = null;
  2692.  
  2693. if (help) {
  2694. help2 = Global.refRooms.get(help["room"]);
  2695. }
  2696.  
  2697. if (patientDiseases[patientId]["state"] != 5) {
  2698.  
  2699. if ($("p" + patientId)) {
  2700. if ($("p" + patientId).getAttribute("class").search("waitingpatient") != -1) {
  2701. patientDiseases[patientId]["state"] = 0;
  2702. patientDiseases[patientId]["room"] = 0;
  2703. }
  2704. else {
  2705. if (help2) {
  2706. patientDiseases[patientId]["state"] = ( help2["roomid"] == 6 ) ? 1 : 3;
  2707. patientDiseases[patientId]["room"] = help2["roomid"];
  2708. }
  2709. else {
  2710. patientDiseases[patientId]["state"] = 1;
  2711. patientDiseases[patientId]["room"] = 6;
  2712. }
  2713. }
  2714. }
  2715. else {
  2716. if (help2) {
  2717. patientDiseases[patientId]["state"] = (help2["roomid"] == 6) ? 2 : 4;
  2718. patientDiseases[patientId]["room"] = help2["roomid"];
  2719. }
  2720. else {
  2721. patientDiseases[patientId]["state"] = 2;
  2722. patientDiseases[patientId]["room"] = 6;
  2723. }
  2724. }
  2725. }
  2726. }
  2727.  
  2728. function plotPatient(target, currPatientId, showCured, minipic) { //(target) , (target,showCured)
  2729. if (!isNaN(currPatientId)) {
  2730. if (typeof(showCured) != "boolean") {
  2731. showCured = true;
  2732. }
  2733. } else {
  2734. if (typeof(currPatientId) == "boolean") {
  2735. showCured = currPatientId;
  2736. }
  2737. else {
  2738. showCured = true;
  2739. }
  2740.  
  2741. currPatientId = parseInt(target.getAttribute("name"), 10);
  2742. }
  2743.  
  2744. if (typeof(minipic) != "boolean") {
  2745. minipic = false;
  2746. }
  2747.  
  2748. Log("plotPatient " + currPatientId + " " + showCured + " " + minipic);
  2749. target.innerHTML = "";
  2750.  
  2751. initPatient(currPatientId);
  2752.  
  2753. // diseases
  2754. var usedRooms = {};
  2755. var newdiv;
  2756. var restlicheZeit = 0;
  2757.  
  2758. for (var disease in patientDiseases[currPatientId]) {
  2759. if (!isNaN(disease)) {
  2760. if (showCured || patientDiseases[currPatientId][disease] != "cured") {
  2761. newdiv = createElement("div", {style: "float:left;"}, target);
  2762. if (minipic) {
  2763. if (patientDiseases[currPatientId][disease] == "cured") {
  2764. newdiv1 = createElement("div", {
  2765. class: "d_a_15 d_" + disease + "_15",
  2766. style: "opacity:0.5;"
  2767. }, newdiv);
  2768. createElement("div", {class: "treatment_icon_15 treatment_icon_15_1"}, newdiv1);
  2769. }
  2770. else {
  2771. newdiv1 = createElement("div", {class: "d_a_15 d_" + disease + "_15"}, newdiv);
  2772. }
  2773. }
  2774. else {
  2775. if (patientDiseases[currPatientId][disease] == "cured") {
  2776. newdiv1 = createElement("div", {
  2777. class: "d_a_30 d_" + disease + "_30",
  2778. style: "opacity:0.3;"
  2779. }, newdiv);
  2780. createElement("div", {class: "treatmenticons " + patientDiseases[currPatientId][disease] + "s"}, newdiv1);
  2781. }
  2782. else if (patientDiseases[currPatientId][disease]) {
  2783. newdiv1 = createElement("div", {class: "d_a_30 d_" + disease + "_30"}, newdiv);
  2784. createElement("div", {class: "treatmenticons " + patientDiseases[currPatientId][disease] + "s"}, newdiv1);
  2785. }
  2786. else {
  2787. newdiv1 = createElement("div", {class: "d_a_30 d_" + disease + "_30"}, newdiv);
  2788. }
  2789.  
  2790. if (patientDiseases[currPatientId][disease] != "cured") {
  2791. newdiv2 = createElement("div", "", newdiv, time2str(Global.availableDiseases[0][disease]["basetime"], 1));
  2792. restlicheZeit += Global.availableDiseases[0][disease]["basetime"];
  2793.  
  2794. if (!usedRooms[Global.availableDiseases[0][disease]["room"][0]]) {
  2795. usedRooms[Global.availableDiseases[0][disease]["room"][0]] = 1;
  2796. newdiv2.style.fontWeight = "bold";
  2797. }
  2798. }
  2799. }
  2800. }
  2801. }
  2802. }
  2803. // nurse
  2804. if (patientDiseases[currPatientId]["m"] == 4) {
  2805. if (minipic) {
  2806. newdiv = createElement("div", {style: "position:relative;float:left;"}, target);
  2807. createElement("div", {class: "treatment_icon_15 treatment_icon_15_1"}, newdiv);
  2808. } else {
  2809. newdiv = createElement("div", {style: "position:relative;float:left;margin-left:30px;"}, target);
  2810. createElement("div", {class: "pat_dis1 treatmenticonpa"}, newdiv);
  2811. createElement("div", {class: "treatmenticons cureds"}, newdiv);
  2812. newdiv2 = createElement("div", "", newdiv, time2str(restlicheZeit, 1));
  2813. newdiv2.style.fontWeight = "bold";
  2814. }
  2815. }
  2816. else {
  2817. if (!minipic) {
  2818. newdiv = createElement("div", {style: "position:relative;float:left;margin-left:30px;"}, target);
  2819. createElement("div", {class: "pat_dis1 treatmenticonpa"}, newdiv);
  2820. newdiv2 = createElement("div", "", newdiv, time2str(restlicheZeit, 1));
  2821. newdiv2.style.fontWeight = "bold";
  2822. }
  2823. }
  2824. newdiv = null;
  2825. }
  2826.  
  2827. function getPatientInfos(id, with_nurse) {
  2828. var answ = GM_xmlhttpRequest({
  2829. method: "GET",
  2830. url: "medicalrecord.php?patient=" + id,
  2831. // synchronous: true,
  2832. onload: function (response) {
  2833. var text = JSON.parse(response.responseText);
  2834. updPatientState(id, jQuery(text["message"]), with_nurse);
  2835. },
  2836. object: onerror = function (response) {
  2837. return "";
  2838. }
  2839. });
  2840. }
  2841.  
  2842. function highlightPatients(roomid) {
  2843. // Patients
  2844. var canddiv = $("garten_komplett").getElementsByClassName("patient");
  2845.  
  2846. for (var v = 0; v < canddiv.length; v++) {
  2847. canddiv[v].style.border = "";
  2848.  
  2849. var currPatientId = parseInt(canddiv[v].id.replace("p", ""), 10);
  2850.  
  2851. if (patientDiseases[currPatientId]) {
  2852. //TODO: Emty "if" statement
  2853. if (patientDiseases[currPatientId]["room" + roomid]) {
  2854. canddiv[v].style.border = "3px solid blue";
  2855. }
  2856. }
  2857. else
  2858. initPatient(currPatientId);
  2859. }
  2860.  
  2861. // in Rooms
  2862. var canddiv = $("garten_komplett").getElementsByClassName("room");
  2863. for (var v = 0; v < canddiv.length; v++) {
  2864. canddiv[v].style.backgroundColor = "";
  2865. var currPatientId = Global.refRooms.get(canddiv[v].id)["patient"];
  2866. if (currPatientId) {
  2867. if (!$("p" + currPatientId)) {
  2868. if (patientDiseases[currPatientId]) {
  2869. if (patientDiseases[currPatientId]["room" + roomid]) {
  2870. canddiv[v].style.backgroundColor = "blue";
  2871. }
  2872. } else {
  2873. initPatient(currPatientId);
  2874. }
  2875. }
  2876. }
  2877. }
  2878. canddiv = null;
  2879. }
  2880.  
  2881. function unhighlightPatients() {
  2882. Log("unhighlightPatients");
  2883. var canddiv = $("garten_komplett").getElementsByClassName("patient");
  2884.  
  2885. for (var v = 0; v < canddiv.length; v++) {
  2886. canddiv[v].style.border = "";
  2887. }
  2888. var canddiv = $("garten_komplett").getElementsByClassName("room");
  2889.  
  2890. for (var v = 0; v < canddiv.length; v++) {
  2891. canddiv[v].style.backgroundColor = "";
  2892. }
  2893. canddiv = null;
  2894. }
  2895.  
  2896. function calcCurrDisease(patientId) { // returns current treatment
  2897. var result = null;
  2898. if (patientDiseases[patientId]) {
  2899. for (var v in patientDiseases[patientId]) {
  2900. if ((!isNaN(v)) && (patientDiseases[patientId][v] == "heartbeat")) {
  2901. result = v;
  2902. break;
  2903. }
  2904. }
  2905. if (!result) { // no treatment found, set one
  2906. var currPatient = Global.refPatients.get("p" + patientId);
  2907. var currRoom = Global.refRooms.get(currPatient["room"]);
  2908. if (currRoom) {
  2909. if (patientDiseases[patientId]["room" + currRoom.roomid]) {
  2910. delete patientDiseases[patientId]["room" + currRoom.roomid];
  2911. }
  2912. for (var disease in patientDiseases[patientId]) {
  2913. if ((!isNaN(disease)) && (patientDiseases[patientId][disease] != "cured")) {
  2914. for (var roomDiseaseNr = 0; roomDiseaseNr < Global.availableRooms[currRoom.roomid]["diseases"][roomDiseaseNr]; roomDiseaseNr++) {
  2915. if (disease == Global.availableRooms[currRoom.roomid]["diseases"][roomDiseaseNr]) {
  2916. if (result) {
  2917. patientDiseases[patientId]["room" + currRoom.roomid] = 1;
  2918. } else {
  2919. patientDiseases[patientId][disease] = "heartbeat";
  2920. result = disease;
  2921. }
  2922. }
  2923. }
  2924. }
  2925. }
  2926. }
  2927. }
  2928. } else {
  2929. initPatient(patientId);
  2930. result = calcCurrDisease(patientId);
  2931. }
  2932.  
  2933. calcComesNext(patientId);
  2934. return result;
  2935. }
  2936.  
  2937. function calcComesNext(patientId) {
  2938. Log("calcComesNext " + patientId);
  2939. if (patientDiseases[patientId]) {
  2940. var currRoomId = null;
  2941. for (var disease in patientDiseases[patientId]) {
  2942. if (!isNaN(disease) && (patientDiseases[patientId][disease] == "heartbeat")) {
  2943. currRoomId = Global.availableDiseases[0][disease]["room"][0];
  2944. break;
  2945. }
  2946. }
  2947. if (currRoomId) {
  2948. for (var disease in patientDiseases[patientId]) {
  2949. if (!isNaN(disease) && (patientDiseases[patientId][disease] == "") && (currRoomId == Global.availableDiseases[0][disease]["room"])) {
  2950. patientDiseases[patientId][disease] = "comesnext";
  2951. }
  2952. }
  2953. }
  2954. } else {
  2955. initPatient(patientId);
  2956. }
  2957. }
  2958.  
  2959. function calcEndTreatment(patientId) {
  2960. Log("calcEndTreatment " + patientId);
  2961.  
  2962. if (patientDiseases[patientId]) {
  2963. var cured = true;
  2964.  
  2965. for (var v in patientDiseases[patientId]) {
  2966. if (!isNaN(v)) {
  2967. var currDiseaseRoom = Global.availableDiseases[0][v]["room"][0];
  2968.  
  2969. if (patientDiseases[patientId][v] == "heartbeat") {
  2970. patientDiseases[patientId][v] = "cured";
  2971. if (patientDiseases[patientId]["room" + currDiseaseRoom]) {
  2972. delete patientDiseases[patientId]["room" + currDiseaseRoom];
  2973. }
  2974. } else {
  2975. if (patientDiseases[patientId][v] == "comesnext") {
  2976. patientDiseases[patientId][v] = "";
  2977. }
  2978.  
  2979. if (patientDiseases[patientId][v] != "cured") {
  2980. cured = false;
  2981. patientDiseases[patientId]["room" + currDiseaseRoom] = 1;
  2982. }
  2983. }
  2984. }
  2985. }
  2986.  
  2987. if (cured && (patientDiseases[patientId]["m"] > 3)) {
  2988. patientDiseases[patientId]["state"] = 5;
  2989. }
  2990.  
  2991. } else {
  2992. initPatient(patientId);
  2993. }
  2994. }
  2995.  
  2996. function do_Patientenblatt() {
  2997. var currPatientId = parseInt((/MedicalRecord\.\_onclick\(this, (\d+)/).exec($("msgwindow").innerHTML)[1], 10);
  2998. var currPatient = Global.refPatients.get("p" + currPatientId);
  2999.  
  3000. // diseases
  3001. var canddiv = $("msgwindow").getElementsByTagName("div");
  3002.  
  3003. for (var v = 0; v < canddiv.length - 1; v++) {
  3004. if (canddiv[v].id == "medi_diseases") {
  3005. break;
  3006. }
  3007. }
  3008.  
  3009. patientDiseases[currPatientId] = {};
  3010. var cured = true;
  3011.  
  3012. for (var w = 0; w < canddiv[v].childNodes.length - 3; w++) {
  3013.  
  3014. var disease = (/d_(\d+)_50/).exec(canddiv[v].childNodes[w].childNodes[1].getAttribute("class"))[1];
  3015.  
  3016. if (canddiv[v].childNodes[w].childNodes[1].firstChild) {
  3017. patientDiseases[currPatientId][disease] = (/(.+) (.+)/).exec(canddiv[v].childNodes[w].childNodes[1].firstChild.getAttribute("class"))[2];
  3018. if (patientDiseases[currPatientId][disease] == "notreatment") {
  3019. patientDiseases[currPatientId]["unhealable"] = 1;
  3020. }
  3021.  
  3022. if (patientDiseases[currPatientId][disease] != "cured") {
  3023. cured = false;
  3024. }
  3025. } else {
  3026. patientDiseases[currPatientId][disease] = "";
  3027. patientDiseases[currPatientId]["room" + Global.availableDiseases[0][disease]["room"][0]] = 1;
  3028. cured = false;
  3029. }
  3030. }
  3031. // nurse
  3032. var canddiv = $("msgwindow").getElementsByClassName("minitreatment");
  3033. patientDiseases[currPatientId]["m"] = 4;
  3034.  
  3035. for (var v = 0; v < canddiv.length; v++) {
  3036. if (canddiv[v].style.backgroundImage == "") {
  3037. patientDiseases[currPatientId]["m"]--;
  3038. cured = false;
  3039. }
  3040. }
  3041.  
  3042. if (cured) {
  3043. patientDiseases[currPatientId]["state"] = 5;
  3044. }
  3045. else {
  3046. calcComesNext(currPatientId);
  3047. calcPatientState(currPatientId);
  3048. }
  3049.  
  3050. var maxprice = parseFloat($("med_price").getElementsByTagName("span")[0].innerHTML.split("-")[1].replace(Global._KH_THOUSANDSEPERATOR, "").replace(Global._KH_DECIMALSEPERATOR, "."), 10);
  3051. createElement("div", {"style": "position:absolute;top:380px;right:130px;color:red;"}, $("ref_divdetailsbig"), "85%: " + hT_formatgr(0.85 * maxprice) + ", 90%: " + hT_formatgr(0.9 * maxprice) + ", 95%: " + hT_formatgr(0.95 * maxprice));
  3052.  
  3053. var newimg = createElement("img", {
  3054. "style": "position:absolute;top:440px;left:219px;width:16px;height:16px;",
  3055. "src": "http://pics.kapihospital.de/addressbook.gif",
  3056. "class": "cursorclickable",
  3057. "title": "Adressbuch"
  3058. }, $("ref_divdetailsbig"));
  3059. newimg.addEventListener("click", function () {
  3060. var newdiv = createElement("div", {
  3061. "id": "refAdressBook",
  3062. "style": "top:70px;width:265px;height:350px;position:absolute;z-index:30;right:0px;background:url('http://pics.kapihospital.de/addressbook_newmsg.gif') no-repeat scroll left top transparent;overflow:visible;"
  3063. }, $("ref_divdetails"));
  3064. var newdiv1 = createElement("div", {
  3065. "style": "position:absolute;left:12px;top:5px;z-index:2;width:15px;height:10px;",
  3066. "class": "cursorclickable",
  3067. "title": "schlie" + sz_de + "en"
  3068. }, newdiv);
  3069. newdiv1.addEventListener("click", function () {
  3070. removeElement($("refAdressBook"));
  3071. }, false);
  3072. createElement("div", {"style": "z-index:1;position:absolute;width:165px;top:15px;left:45px;right:15px;text-align:center;font-weight:bold;font-size:medium;"}, newdiv, "Adressbuch");
  3073. newdiv1 = createElement("div", {"style": "position:absolute;width:180px;height:225px;top:50px;left:45px;right:0px;overflow-y:auto;overflow-x:hidden;"}, newdiv);
  3074. var newtable = createElement("table", {"cellspacing": "0"}, newdiv1);
  3075. contacts = explode(GM_getValue(lng + "_" + server + "_" + username + "_contacts", "[]"));
  3076. for (var v = 0; v < contacts.length; v++) {
  3077. newdiv1 = createElement("div", {"class": "cursorclickable"}, createElement("td", {}, createElement("tr", {}, newtable)), contacts[v]);
  3078. newdiv1.addEventListener("click", function () {
  3079. $("ref_recipient").value = this.innerHTML;
  3080. removeElement($("refAdressBook"));
  3081. }, false);
  3082. }
  3083. newdiv = null;
  3084. newdiv1 = null;
  3085. newtable = null;
  3086. newdiv1 = null;
  3087. }, false);
  3088. canddiv = null;
  3089. newimg = null;
  3090. }
  3091.  
  3092. function do_Quest() {
  3093. Log("do_Quest");
  3094. if ($("ga_running")) {
  3095. if ($("ga_running").style.display != "none") {
  3096. questTime = now + unsafeWindow.Garage["ends"];
  3097. GM_setValue(lng + "_" + server + "_" + username + "_questTime", questTime);
  3098. }
  3099. else {
  3100. window.setTimeout(do_Quest, 200);
  3101. }
  3102. }
  3103. }
  3104.  
  3105. function start_Quest() {
  3106. console.log( info + "StartQuest");
  3107. unsafeWindow.show_page("garage");
  3108.  
  3109. window.setTimeout(function () {
  3110. if ($("newswindow_badge")) {
  3111. //Success message
  3112. console.log( info + "Finished!");
  3113. unsafeWindow.close_badge();
  3114. }
  3115.  
  3116. window.setTimeout(function () {
  3117. console.log( info + "Search window");
  3118. if ($("ga_new") && $("ga_new").style.display != "none") {
  3119. console.log( info + "Creating new");
  3120. questcnt = $('ga_done').innerHTML[0];
  3121. console.log( info + "Quest number: " + questcnt);
  3122.  
  3123. if (questcnt < 8) {
  3124. unsafeWindow.Garage.doJob();
  3125. }
  3126. else {
  3127. console.log( info +"Eight quests done, job's done. ;)");
  3128. }
  3129. }
  3130.  
  3131.  
  3132. if ($("ga_running") && $("ga_running").style.display != "none") {
  3133. console.log( info + "Still working..");
  3134. }
  3135.  
  3136. window.setTimeout(unsafeWindow.close_page, 500);
  3137.  
  3138. }, 400);
  3139.  
  3140. }, 500);
  3141. }
  3142.  
  3143. console.log( info + "Start do_mail()");
  3144. function do_Mail() {
  3145. var keyMsgShow = /showMessage\(['|\s]*(\d+)['|\s]*,'(.*?)'\)/;
  3146. var keyMsgDelete = /deleteMessage\(['|\s]*(\d+)['|\s]*,\s*this,\s*'(.*?)'\)/;
  3147. var candtable = $("msgwindow").getElementsByTagName("table");
  3148. var cand = null;
  3149. var help = null;
  3150. if (candtable[0]) {
  3151. cand = candtable[0].getElementsByTagName("a");
  3152. if (cand[0] && (help = keyMsgShow.exec(cand[0].href))) {
  3153. if (help[2] == "inbox") {
  3154. console.log( info * "inbox");
  3155. var msgIdIn = [];
  3156. for (var v = 0; v < cand.length; v++) {
  3157. help = keyMsgShow.exec(cand[v].href);
  3158. if (help) {
  3159. msgIdIn.push(help[1]);
  3160. }
  3161. }
  3162. GM_setValue(lng + "_" + server + "_" + username + "msgIdIn", implode(msgIdIn));
  3163. cand = candtable[0].getElementsByTagName("input");
  3164. for (var v = 0; v < cand.length; v++) {
  3165. cand[v].setAttribute("title", "Alt+Klick um alle Gleichen zu markieren");
  3166. cand[v].addEventListener("click", function (event) {
  3167. if (event.altKey) {
  3168. var cand = this.parentNode.parentNode.getElementsByTagName("a");
  3169. var cand2 = null;
  3170. var help = [this.checked, cand[0].innerHTML, cand[1].innerHTML];
  3171. cand = this.parentNode.parentNode.parentNode.getElementsByTagName("tr");
  3172. for (var v = 0; v < cand.length; v++) {
  3173. cand2 = cand[v].getElementsByTagName("a");
  3174. if ((help[1] == cand2[0].innerHTML) && (help[2] == cand2[1].innerHTML)) {
  3175. cand[v].getElementsByTagName("input")[0].checked = help[0];
  3176. }
  3177. }
  3178. cand = null;
  3179. cand2 = null;
  3180. help = null;
  3181. }
  3182. }, false);
  3183. }
  3184. }
  3185. } else {
  3186. cand = $("msgNavigation").getElementsByTagName("input");
  3187. if (cand.length > 1) {
  3188. // InMessage
  3189. help = keyMsgDelete.exec(cand[cand.length - 2].getAttribute("onclick"));
  3190. if (help) {
  3191. if (help[2] == "inbox") {
  3192. var msgIdIn = explode(GM_getValue(lng + "_" + server + "_" + username + "msgIdIn", "[]"));
  3193. for (var c = 0; c < msgIdIn.length; c++) {
  3194. if (msgIdIn[c] == help[1]) {
  3195. break
  3196. }
  3197. }
  3198. if (c > 0) {
  3199. createElement("input", {
  3200. "type": "button",
  3201. "value": "Previous message",
  3202. "onclick": "javascript:Messages.showMessage(" + msgIdIn[c - 1] + ",'inbox');",
  3203. "class": "cursorclickable msg_input"
  3204. }, $("msgNavigation"));
  3205. }
  3206. if (c < msgIdIn.length - 1) {
  3207. createElement("input", {
  3208. "type": "button",
  3209. "value": "Next message",
  3210. "onclick": "javascript:Messages.showMessage(" + msgIdIn[c + 1] + ",'inbox');",
  3211. "class": "cursorclickable msg_input"
  3212. }, $("msgNavigation"));
  3213. }
  3214. }
  3215. }
  3216. }
  3217. if ($("deleteContact")) {
  3218. console.log( info + "Contacts");
  3219. var contacts = [];
  3220. cand = candtable[0].getElementsByTagName("tr");
  3221. for (var tr = 1; tr < cand.length - 3; tr++) {
  3222. contacts.push(/(.*?)&nbsp;/.exec(cand[tr].getElementsByTagName("td")[0].innerHTML)[1]);
  3223. }
  3224. GM_setValue(lng + "_" + server + "_" + username + "_contacts", implode(contacts));
  3225. }
  3226. }
  3227. }
  3228. candtable = null;
  3229. cand = null;
  3230. }
  3231.  
  3232. function laden(elemente, i) {
  3233.  
  3234. /* Initialize Object-loader */
  3235.  
  3236. loader.onload = function () {
  3237. if (i < (elemente.length - 1)) {
  3238. laden(elemente, i + 1);
  3239. }
  3240. else {
  3241. /* All elements loaded */
  3242. }
  3243. }
  3244. }
  3245.  
  3246. function do_Notepad() {
  3247. removeElement($("premiumicon"));
  3248. $("msg_body").disabled = "";
  3249. $("msg_body").value = GM_getValue(lng + "_" + server + "_" + username + "_notepad", "");
  3250. $("msg_body").addEventListener("keyup", function () {
  3251. GM_setValue(lng + "_" + server + "_" + username + "_notepad", this.value);
  3252. }, false);
  3253. }
  3254.  
  3255. function do_Patientenboerse() {
  3256. Log("do_Patientenboerse");
  3257.  
  3258. createElement("div", {style: "z-index:0;position:absolute;top:0px;right:0px;height:500px;width:250px;background-image: url('http://pics.kapihospital.de/bg_exchange2.jpg');background-position:250px 0px;"}, $("msgwindow"));
  3259. $("msgwindow").style.width = "750px";
  3260. $("ex_bubble").style.width = "";
  3261. $("ex_bubble").style.zIndex = "1";
  3262.  
  3263. /*var newdiv = createElement("div",{style:"position:absolute;bottom:-70px;left:20px;background-color: white;"},$("msgwindow"));*/
  3264. var newtab = createElement("table", {
  3265. border: "1px",
  3266. cellspacing: "0px",
  3267. cellpadding: "0px",
  3268. style: "text-align:center;position:absolute;bottom:-120px;left:-100px;width:750px;background-color: white;"
  3269. }, $("msgwindow"));
  3270.  
  3271. var valShowUncurable = GM_getValue(lng + "_" + server + "_" + username + "_valShowUncurable", false);
  3272. var highlightBoerse = {};
  3273. var highlightBoerse1 = {};
  3274. try {
  3275. highlightBoerse = explode(GM_getValue(lng + "_" + server + "_" + username + "_highlightBoerse", "{}"));
  3276. } catch (err) {
  3277. }
  3278. try {
  3279. highlightBoerse1 = explode(GM_getValue(lng + "_" + server + "_" + username + "_highlightBoerse1", "{}"));
  3280. } catch (err) {
  3281. }
  3282.  
  3283. var blockBoerse = explode(GM_getValue(lng + "_" + server + "_" + username + "_blockBoerse", "{}"));
  3284. //var newdiv1 = createElement("div",{style:"display:block;"},newdiv);
  3285. var tabrow = createElement("tr", "", newtab);
  3286. var tabcell = createElement("td", {colspan: "20"}, tabrow);
  3287.  
  3288. var newinput = createElement("input", {
  3289. "id": "valShowUncurable",
  3290. "type": "checkbox",
  3291. "checked": valShowUncurable
  3292. }, tabcell);
  3293. newinput.addEventListener("click", function () {
  3294. GM_setValue(lng + "_" + server + "_" + username + "_valShowUncurable", this.checked);
  3295. click($("ex_navi").getElementsByTagName("div")[1]);
  3296. }, false);
  3297.  
  3298. createElement("span", {}, tabcell, texte["showUncurable"]);
  3299.  
  3300. tabrow = createElement("tr", "", newtab);
  3301. tabcell = createElement("td", "", tabrow);
  3302.  
  3303. for (var r in Global.availableRooms) {
  3304. if (Global.availableRooms[r].diseases.length > 0) {
  3305. tabcell = createElement("td", "", tabrow, Global.availableRooms[r].name);
  3306. }
  3307. }
  3308.  
  3309. /*var newdiv1 = createElement("div",{style:"display:block;background-color:green;"},newdiv);
  3310. var newdiv2 = createElement("div",{style:"display:block;background-color:yellow;"},newdiv);
  3311. var newdiv3 = createElement("div",{style:"display:block;background-color:#900;"},newdiv);
  3312. */
  3313. var newrow1 = createElement("tr", {style: "background-color:green;"}, newtab);
  3314. var newrow2 = createElement("tr", {style: "background-color:yellow;"}, newtab);
  3315. var newrow3 = createElement("tr", {style: "background-color:#900;"}, newtab);
  3316.  
  3317. tabcell = createElement("td", "", newrow1, "Hervorheben 1");
  3318. tabcell = createElement("td", "", newrow2, "Hervorheben 2");
  3319. tabcell = createElement("td", "", newrow3, "Verberge");
  3320.  
  3321. for (var r in Global.availableRooms) {
  3322. if (Global.availableRooms[r].diseases.length > 0) {
  3323. tabcell = createElement("td", "", newrow1);
  3324. newinput = createElement("input", {
  3325. "id": "hl" + r,
  3326. "type": "checkbox",
  3327. "checked": highlightBoerse[r],
  3328. "title": Global.availableRooms[r].name,
  3329. "style": "margin-right:0px;margin-left:1px;"
  3330. }, tabcell);
  3331. newinput.addEventListener("click", function () {
  3332. highlightBoerse[this.id.replace("hl", "")] = this.checked;
  3333. GM_setValue(lng + "_" + server + "_" + username + "_highlightBoerse", implode(highlightBoerse));
  3334. click($("ex_navi").getElementsByTagName("div")[1]);
  3335. }, false);
  3336.  
  3337. tabcell = createElement("td", "", newrow2);
  3338. newinput = createElement("input", {
  3339. "id": "hl1" + r,
  3340. "type": "checkbox",
  3341. "checked": highlightBoerse1[r],
  3342. "title": Global.availableRooms[r].name,
  3343. "style": "margin-right:0px;margin-left:1px;"
  3344. }, tabcell);
  3345. newinput.addEventListener("click", function () {
  3346. highlightBoerse1[this.id.replace("hl1", "")] = this.checked;
  3347. GM_setValue(lng + "_" + server + "_" + username + "_highlightBoerse1", implode(highlightBoerse1));
  3348. click($("ex_navi").getElementsByTagName("div")[1]);
  3349. }, false);
  3350.  
  3351. tabcell = createElement("td", "", newrow3);
  3352. newinput = createElement("input", {
  3353. "id": "bl" + r,
  3354. "type": "checkbox",
  3355. "checked": blockBoerse[r],
  3356. "title": Global.availableRooms[r].name,
  3357. "style": "margin-right:0px;margin-left:1px;"
  3358. }, tabcell);
  3359. newinput.addEventListener("click", function () {
  3360. blockBoerse[this.id.replace("bl", "")] = this.checked;
  3361. GM_setValue(lng + "_" + server + "_" + username + "_blockBoerse", implode(blockBoerse));
  3362. click($("ex_navi").getElementsByTagName("div")[1]);
  3363. }, false);
  3364. }
  3365. }
  3366. var candtable = $("msgwindow").getElementsByTagName("table");
  3367. candtable[0].style.width = "650px";
  3368. candtable[0].setAttribute("class", "hoveryellow");
  3369. var candtr = candtable[0].getElementsByTagName("tr");
  3370. var candtd = candtr[0].getElementsByTagName("td");
  3371. candtd[5].innerHTML = "Kaufen";
  3372. createElement("td", {style: "text-align:right;"}, candtr[0], "Differenz");
  3373. createElement("td", {style: "text-align:right;"}, candtr[0], "Restzeit");
  3374. createElement("td", "", candtr[0], "");
  3375. for (var tr = 1; tr < candtr.length; tr++) {
  3376. candtr[tr].setAttribute("onmouseover", "");
  3377. candtr[tr].setAttribute("onmouseout", "");
  3378. candtd = candtr[tr].getElementsByTagName("td");
  3379. var restlicheZeit = 0;
  3380. var help = null;
  3381. var uncurable = false;
  3382. var buyable = false;
  3383. var unwanted = false;
  3384. var mark1 = false;
  3385. for (var c = 0; c < candtd[2].childNodes.length; c++) {
  3386. var disease = Global.availableDiseases[(/d_(\d+?)_15/).exec(candtd[2].childNodes[c].getAttribute("class"))[1]];
  3387. help = candtd[2].childNodes[c].firstChild.getAttribute("class").slice(-1);
  3388. if (help != "1") {
  3389. restlicheZeit += disease["basetime"];
  3390. if (help == "2") {
  3391. uncurable = true;
  3392. }
  3393. else if (help == "0") {
  3394. buyable = true;
  3395. if (highlightBoerse[disease["room"][0]]) {
  3396. candtd[2].style.backgroundColor = "green";
  3397. }
  3398. if (highlightBoerse1[disease["room"][0]]) {
  3399. mark1 = true;
  3400. }
  3401. if (blockBoerse[disease["room"][0]]) {
  3402. unwanted = true;
  3403. }
  3404. }
  3405. }
  3406. }
  3407. if (uncurable) {
  3408. candtd[2].style.backgroundColor = "red";
  3409. if (unwanted || !buyable || !valShowUncurable) {
  3410. candtr[tr].style.display = "none";
  3411. }
  3412. } else {
  3413. if (unwanted || !buyable) {
  3414. candtr[tr].style.display = "none";
  3415. }
  3416. else if (mark1) {
  3417. candtd[2].style.backgroundColor = "yellow";
  3418. }
  3419. }
  3420. var priceMax = parseFloat(candtd[3].innerHTML.replace(regDelimThou, "").replace(regDelimDeci, "."), 10);
  3421. candtd[3].innerHTML = "&nbsp;" + number_format(priceMax, 2);
  3422. candtd[3].style.textAlign = "right";
  3423. candtd[4].style.textAlign = "right";
  3424. candtd[5].style.textAlign = "right";
  3425. var price = parseFloat(candtd[4].innerHTML.replace(regDelimThou, "").replace(regDelimDeci, "."), 10);
  3426. candtd[4].innerHTML = "&nbsp;" + number_format(price, 2);
  3427. candtd[5].getElementsByTagName("a")[0].innerHTML = "&nbsp;" + number_format(100 * price / priceMax) + "%";
  3428. candtd[5].getElementsByTagName("a")[0].addEventListener("click", function () {
  3429. clickYes = window.setInterval(function () {
  3430. if (($("dlg_message").style.display != "none") && ($("btn_yes"))) {
  3431. click($("btn_yes"));
  3432. clearInterval(clickYes);
  3433. }
  3434. }, 50);
  3435. }, false);
  3436. createElement("td", {style: "text-align:right;"}, candtr[tr], "&nbsp;" + (price > priceMax ? "+" : "") + number_format(price - priceMax, 2));
  3437. createElement("td", {style: "text-align:right;"}, candtr[tr], "&nbsp;" + time2str(restlicheZeit, 1) + "h");
  3438. createElement("td", {style: "text-align:right;"}, candtr[tr], "&nbsp;" + (price > priceMax ? "---" : number_format((priceMax - price) * 3600 / restlicheZeit)));
  3439. }
  3440.  
  3441. var canddiv = $("ex_navi").getElementsByTagName("div");
  3442. canddiv[1].addEventListener("mouseover", function () {
  3443. this.style.backgroundColor = "blue";
  3444. click(this);
  3445. }, false);
  3446. newdiv = null;
  3447. newselect = null;
  3448. newselect1 = null;
  3449. candtable = null;
  3450. candtr = null;
  3451. candtd = null;
  3452. canddiv = null;
  3453. }
  3454.  
  3455. function do_Shop() {
  3456. var cand = $("dropzonesource").getElementsByTagName("div");
  3457. for (var v in cand) {
  3458. if (cand[v].addEventListener) {
  3459. cand[v].addEventListener("mousedown", function () {
  3460. $("dropzonetarget").style.border = "2px solid red";
  3461. }, false);
  3462.  
  3463. cand[v].addEventListener("mouseup", function () {
  3464. $("dropzonetarget").style.border = "";
  3465. }, false);
  3466. }
  3467. }
  3468.  
  3469. cand = null;
  3470. }
  3471.  
  3472. //***********************************************************************************************************
  3473. console.log( info + "do_login");
  3474. function do_login() {
  3475. var loc = reg2.exec(document.location.href);
  3476.  
  3477. //Auto backing to login page
  3478. if (document.location.href.search("logout") != -1) {
  3479. window.setTimeout(function () {
  3480. document.location.href = "http://www." + lng + ".kapihospital.com";
  3481. }, 100);
  3482. }
  3483. else {
  3484. //login
  3485. try {
  3486. var logindata = explode(GM_getValue("logindata", "[]"));
  3487. }
  3488. catch (err) {
  3489. var logindata = [];
  3490. }
  3491.  
  3492. unsafeWindow.showDiv("login_div");
  3493. $("login_div").style.zIndex = "20";
  3494. $("login_div").getElementsByClassName("kh_btn")[0].addEventListener("click", function () {
  3495. var currServer = $("l_server").value;
  3496. var currUser = $("l_loginname").value.toLowerCase();
  3497. GM_setValue(lng + "_" + currServer + "_username", currUser);
  3498. }, false);
  3499.  
  3500. function submit_login(currUserNr) {
  3501. $("l_server").value = logindata[currUserNr][1];
  3502. $("l_loginname").value = logindata[currUserNr][2];
  3503. $("l_password").value = logindata[currUserNr][3];
  3504. $("login_div").getElementsByClassName("kh_btn")[0].click();
  3505. }
  3506.  
  3507. var newdiv = createElement("div", {style: "position:absolute;top:0px;left:0px;width:412px;padding:10px;background-color:#999;-moz-border-radius:10px;"}, $("login_div"));
  3508. var newbutton;
  3509. for (var v = 0; v < logindata.length; v++) {
  3510. if (logindata[v][1] != "0") {
  3511. newbutton = createElement("button", {
  3512. type: "button",
  3513. class: "cursorclickable",
  3514. id: "autologin" + v,
  3515. style: "width:200px;height:20px;margin:3px;"
  3516. }, newdiv, texte["server"] + " " + logindata[v][1] + "." + logindata[v][0] + ": " + logindata[v][2]);
  3517. newbutton.addEventListener("click", function () {
  3518. submit_login(this.id.replace("autologin", ""));
  3519. }, false);
  3520. }
  3521. }
  3522. newdiv = null;
  3523. newbutton = null;
  3524. }
  3525. }
  3526.  
  3527. /*************************** end function declarations **************************/
  3528.  
  3529. console.log( info + "Removing ads");
  3530. removeElement($("sky"));
  3531.  
  3532. }, false);