home.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861
  1. <?php
  2. /**
  3. * Copyright 2021, 2024 5 Mode
  4. *
  5. * This file is part of 5 Cube.
  6. *
  7. * 5 Cube is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * 5 Cube is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with 5 Cube. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. * home.php
  21. *
  22. * 5 Cube home page.
  23. *
  24. * @author Daniele Bonini <my25mb@aol.com>
  25. * @copyrights (c) 2021, 2024, 5 Mode
  26. */
  27. $curLocale = APP_LOCALE;
  28. $password = filter_input(INPUT_POST, "Password")??"";
  29. $password = strip_tags($password);
  30. if ($password==PHP_STR) {
  31. $password = filter_input(INPUT_POST, "Password2")??"";
  32. $password = strip_tags($password);
  33. }
  34. if ($password !== PHP_STR) {
  35. $hash = hash("sha256", $password . APP_SALT, false);
  36. if ($hash !== APP_HASH) {
  37. $password=PHP_STR;
  38. }
  39. }
  40. ?>
  41. <script>
  42. <?PHP if ($password != PHP_STR): ?>
  43. password = 1;
  44. <?PHP else: ?>
  45. password = 0;
  46. <?PHP endif ?>
  47. businessType = "<?PHP echo(BUSINESS_TYPE)?>";
  48. </script>
  49. <!DOCTYPE html>
  50. <head>
  51. <meta charset="UTF-8"/>
  52. <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  53. <!--
  54. Copyright 2021, 2024 5 Mode
  55. This file is part of 5 Cube.
  56. 5 Cube is free software: you can redistribute it and/or modify
  57. it under the terms of the GNU General Public License as published by
  58. the Free Software Foundation, either version 3 of the License, or
  59. (at your option) any later version.
  60. 5 Cube is distributed in the hope that it will be useful,
  61. but WITHOUT ANY WARRANTY; without even the implied warranty of
  62. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  63. GNU General Public License for more details.
  64. You should have received a copy of the GNU General Public License
  65. along with 5 Cube. If not, see <https://www.gnu.org/licenses/>.
  66. -->
  67. <title>5 Cube: Every person its prospects.</title>
  68. <link rel="shortcut icon" href="/favicon.ico?v=<?php echo(time()); ?>" />
  69. <meta name="description" content="Welcome to <?php echo(APP_NAME); ?>"/>
  70. <meta name="author" content="5 Mode"/>
  71. <meta name="robots" content="index,follow"/>
  72. <script src="/js/jquery-3.6.0.min.js" type="text/javascript"></script>
  73. <script src="/js/common.js" type="text/javascript"></script>
  74. <script src="/js/bootstrap.min.js" type="text/javascript"></script>
  75. <script src="/js/sha.js" type="text/javascript"></script>
  76. <script src="/js/serialize-javascript.js" type="text/javascript"></script>
  77. <script src="/js/cube-code.js" type="text/javascript"></script>
  78. <script src="/js/dragndrop-code.js" type="text/javascript"></script>
  79. <script src="/js/home.js?v=<?php echo(time()); ?>" type="text/javascript" defer></script>
  80. <link href="/css/bootstrap.min.css" type="text/css" rel="stylesheet">
  81. <link href="/css/style.css?v=<?php echo(time()); ?>" type="text/css" rel="stylesheet">
  82. <script>
  83. /*
  84. * Interaction code
  85. */
  86. timeoutId=0;
  87. var oldtthis; // Old cube
  88. var lineOldVal = ""; // Old value for a detail line
  89. var lineNewVal = ""; // New value for a detail line
  90. var dataChanged = false;
  91. /*
  92. function zoominCube_old(tthis) {
  93. $(tthis).css("width","396px");
  94. $(tthis).css("height","477px");
  95. $(tthis).css("margin","0px");
  96. }
  97. function zoomoffCube_old(tthis) {
  98. $(tthis).css("width","130px");
  99. $(tthis).css("height","159px");
  100. $(tthis).css("margin","50px");
  101. }
  102. /*
  103. /*
  104. * Select the given cube
  105. *
  106. * @param <interfaceEl> selected cube
  107. * @returns void
  108. */
  109. function selCube(tthis) {
  110. <?PHP if ($password != PHP_STR): ?>
  111. _selCube(tthis);
  112. // Clean the old selected..
  113. $(oldtthis).css("color","#d4b0dc");
  114. $(oldtthis).css("text-decoration","none");
  115. oldtthis = tthis;
  116. // Decore the selected one..
  117. $(tthis).css("color","#bd006e");
  118. $(tthis).css("text-decoration","underline");
  119. $("#cubezvname").html(curcube.getname());
  120. // Reset the detail view
  121. $("#detailtitle").html("");
  122. $("#detaildata").html("");
  123. $("#datadetail").hide();
  124. // Update ZOOMED VIEW interface..
  125. $("#face1").html("<span id='facelet1'>" + curcube.getFace('h0') + "</span> &horbar;&horbar;&horbar;&horbar;&horbar;&xodot; ");
  126. $("#face2").html("<span id='facelet2'>" + curcube.getFace('v1') + "</span>");
  127. $("#face3").html("&xodot;&horbar;&horbar;&horbar;&horbar; <span id='facelet3'>" + curcube.getFace('h1') + "</span>");
  128. $("#face1").attr("target", curcube.getFace('h0'));
  129. $("#face2").attr("target", curcube.getFace('v1'));
  130. $("#face3").attr("target", curcube.getFace('h1'));
  131. clearTimeout(timeoutId);
  132. // Update body background..
  133. $(document.body).css("background","url('../res/bg.jpg')");
  134. $(document.body).css("background-size","cover");
  135. // Display ZOOMED VIEW interface and controls
  136. $("#cubeList").css("width", "700px");
  137. $("#cubectrls").show();
  138. $("#zoomedview").show();
  139. $("#cubelinks").show();
  140. <?PHP endif; ?>
  141. }
  142. /*
  143. * Turn the current cube to the left
  144. *
  145. * @returns void
  146. */
  147. function turnLeft() {
  148. curcube.turnLeft();
  149. // Update ZOOMED VIEW interface..
  150. $("#face1").html("<span id='facelet1'>" + curcube.getFace('h0') + "</span> &horbar;&horbar;&horbar;&horbar;&horbar;&xodot; ");
  151. $("#face2").html("<span id='facelet2'>" + curcube.getFace('v1') + "</span>");
  152. $("#face3").html("&xodot;&horbar;&horbar;&horbar;&horbar; <span id='facelet3'>" + curcube.getFace('h1') + "</span>");
  153. $("#face1").attr("target", curcube.getFace('h0'));
  154. $("#face2").attr("target", curcube.getFace('v1'));
  155. $("#face3").attr("target", curcube.getFace('h1'));
  156. // Display the debug info..
  157. visInfo();
  158. }
  159. /*
  160. * Turn the current cube to the right
  161. *
  162. * @returns void
  163. */
  164. function turnRight() {
  165. curcube.turnRight();
  166. // Update ZOOMED VIEW interface..
  167. $("#face1").html("<span id='facelet1'>" + curcube.getFace('h0') + "</span> &horbar;&horbar;&horbar;&horbar;&horbar;&xodot; ");
  168. $("#face2").html("<span id='facelet2'>" + curcube.getFace('v1') + "</span>");
  169. $("#face3").html("&xodot;&horbar;&horbar;&horbar;&horbar; <span id='facelet3'>" + curcube.getFace('h1') + "</span>");
  170. $("#face1").attr("target", curcube.getFace('h0'));
  171. $("#face2").attr("target", curcube.getFace('v1'));
  172. $("#face3").attr("target", curcube.getFace('h1'));
  173. // Display the debug info..
  174. visInfo();
  175. }
  176. /*
  177. * Turn the current cube to upward
  178. *
  179. * @returns void
  180. */
  181. function turnUp() {
  182. curcube.turnUp();
  183. // Update ZOOMED VIEW interface..
  184. $("#face1").html("<span id='facelet1'>" + curcube.getFace('h0') + "</span> &horbar;&horbar;&horbar;&horbar;&horbar;&xodot; ");
  185. $("#face2").html("<span id='facelet2'>" + curcube.getFace('v1') + "</span>");
  186. $("#face3").html("&xodot;&horbar;&horbar;&horbar;&horbar; <span id='facelet3'>" + curcube.getFace('h1') + "</span>");
  187. $("#face1").attr("target", curcube.getFace('h0'));
  188. $("#face2").attr("target", curcube.getFace('v1'));
  189. $("#face3").attr("target", curcube.getFace('h1'));
  190. // Display the debug info..
  191. visInfo();
  192. }
  193. /*
  194. * Turn the current cube to downward
  195. *
  196. * @returns void
  197. */
  198. function turnDown() {
  199. curcube.turnDown();
  200. // Update ZOOMED VIEW interface..
  201. $("#face1").html("<span id='facelet1'>" + curcube.getFace('h0') + "</span> &horbar;&horbar;&horbar;&horbar;&horbar;&xodot; ");
  202. $("#face2").html("<span id='facelet2'>" + curcube.getFace('v1') + "</span>");
  203. $("#face3").html("&xodot;&horbar;&horbar;&horbar;&horbar; <span id='facelet3'>" + curcube.getFace('h1') + "</span>");
  204. $("#face1").attr("target", curcube.getFace('h0'));
  205. $("#face2").attr("target", curcube.getFace('v1'));
  206. $("#face3").attr("target", curcube.getFace('h1'));
  207. // Display the debug info..
  208. visInfo();
  209. }
  210. /*
  211. * Hide the ZOOMED VIEW
  212. *
  213. * @returns void
  214. */
  215. function hideZoomedview() {
  216. // Clean the old selected..
  217. $(oldtthis).css("color","#d4b0dc");
  218. $(oldtthis).css("text-decoration","none");
  219. oldtthis = null;
  220. // Reset the detail view
  221. $("#detailtitle").html("");
  222. $("#detaildata").html("");
  223. $("#datadetail").hide();
  224. // Hide ZOOMED VIEW interface and controls
  225. $("#cubeList").css("width", "100%");
  226. $("#cubelinks").hide();
  227. $("#zoomedview").hide();
  228. $("#cubectrls").hide();
  229. // Reset body background..
  230. $(document.body).css("background","#0d0d0d");
  231. }
  232. /*
  233. * Mouse over handle for ZOOMED VIEW
  234. *
  235. * @returns void
  236. */
  237. function zoomviewOver() {
  238. clearTimeout(timeoutId);
  239. }
  240. /*
  241. * Mouse out handle for ZOOMED VIEW
  242. *
  243. * @returns void
  244. */
  245. function zoomviewOut() {
  246. timeoutId = setTimeout(hideZoomedview,1500);
  247. }
  248. /*
  249. * Display the debug info
  250. *
  251. * @returns void
  252. */
  253. function visInfo() {
  254. $("#hcube").val(curcube.gethcube());
  255. $("#vcube").val(curcube.getvcube());
  256. $("#hcur").val(curcube.gethcur());
  257. $("#vcur").val(curcube.getvcur());
  258. $("#curcube").val(curcube.getname());
  259. }
  260. /*
  261. function eachNode(rootNode, callback) {
  262. if (!callback) {
  263. const nodes = []
  264. eachNode(rootNode, function(node) {
  265. nodes.push(node.nodeName)
  266. //nodes.push(node)
  267. })
  268. return nodes
  269. }
  270. if (false === callback(rootNode)) {
  271. return false
  272. }
  273. if (rootNode.hasChildNodes()) {
  274. const nodes = rootNode.childNodes
  275. for (let i = 0, l = nodes.length; i < l; ++i) {
  276. if (false === eachNode(nodes[i], callback)) {
  277. return
  278. }
  279. }
  280. }
  281. }
  282. */
  283. /*
  284. * Get the data for the given detail / face
  285. *
  286. * @param string xmlStr, the current cube xml data
  287. * @param string detail, the requested detail
  288. * @returns string, the detail data
  289. */
  290. function getDetailData(xmlStr, detail) {
  291. var ret = "";
  292. var re;
  293. detail = detail.toLowerCase();
  294. xmlStr = xmlStr.replace('<?xml version="1.0" encoding="UTF-8"?>',"");
  295. xmlStr = xmlStr.replace('<details>',"");
  296. xmlStr = xmlStr.replace('</details>',"");
  297. xmlStr = xmlStr.replaceAll('\n',"");
  298. xmlStr = xmlStr.replaceAll(String.fromCharCode(9), "");
  299. xmlStr = xmlStr.replaceAll(String.fromCharCode(10), "");
  300. xmlStr = xmlStr.replaceAll(String.fromCharCode(13), "");
  301. xmlStr = xmlStr.replaceAll(" ", "");
  302. xmlStr = xmlStr.replaceAll(" ", "");
  303. xmlStr = escape(xmlStr);
  304. xmlStr = xmlStr.replaceAll("%0A", "");
  305. xmlStr = xmlStr.replaceAll("%20%20%20%20%20", "");
  306. xmlStr = xmlStr.replaceAll("%20%20%20%20%", "");
  307. xmlStr = xmlStr.replaceAll("%20%20%", "");
  308. //xmlStr = unescape(xmlStr);
  309. //alert(xmlStr);
  310. switch (detail) {
  311. case "address":
  312. re = new RegExp("detail%20face%3D%22address%22.+/country", "igsu");
  313. break;
  314. case "contacts":
  315. re = new RegExp("detail%20face%3D%22contacts%22.+/cell", "igsu");
  316. break;
  317. case "other info":
  318. re = new RegExp("detail%20face%3D%22other%20info%22.+/description", "igsu");
  319. break;
  320. case "menu":
  321. re = new RegExp("detail%20face%3D%22menu%22.+/menu3", "igsu");
  322. break;
  323. case "pictures":
  324. re = new RegExp("detail%20face%3D%22pictures%22.+/pic5", "igsu");
  325. break;
  326. case "password":
  327. re = new RegExp("detail%20face%3D%22password%22.+/password", "igsu");
  328. break;
  329. }
  330. s = re.exec(xmlStr);
  331. if (!s || s.length===0) {
  332. ret = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Error! #1";
  333. return ret;
  334. }
  335. xmlStr = s[0];
  336. xmlStr = "<"+xmlStr+"></detail>";
  337. xmlStr = unescape(xmlStr);
  338. //alert(xmlStr);
  339. const parser = new DOMParser();
  340. const doc = parser.parseFromString(xmlStr, "text/xml");
  341. x = doc.getElementsByTagName("detail");
  342. if (x.length===0) {
  343. ret = "Error! #2";
  344. return ret;
  345. }
  346. ret += "<div style='padding:10px'>";
  347. for (i = 0; i < x[0].childNodes.length; i++) {
  348. if (x[0].childNodes[i].nodeType === 1) {
  349. if (x[0].childNodes[i].getAttributeNode("type")) {
  350. mytype = x[0].childNodes[i].getAttributeNode("type");
  351. if (mytype.value==="pic") {
  352. ret += "<div style='float:left;width:35%;text-align:right;height:32px;vertical-align:middle;padding-top:3px;font-weight:900;white-space:nowrap;'>" + x[0].childNodes[i].nodeName + "&nbsp;&nbsp;</div><div style='float:right;width:65%;height:32px;'>" + "<input type='text' id='cube-detail-" + x[0].childNodes[i].nodeName + "' value='" + x[0].childNodes[i].textContent + "' placeholder='https://' onkeyup='storePicData(this)'></div>";
  353. } else {
  354. ret += "<div style='float:left;width:35%;text-align:right;height:32px;vertical-align:middle;padding-top:3px;font-weight:900;white-space:nowrap;'>" + x[0].childNodes[i].nodeName + "&nbsp;&nbsp;</div><div style='float:right;width:65%;height:32px;'>" + "<input type='text' id='cube-detail-" + x[0].childNodes[i].nodeName + "' value='" + x[0].childNodes[i].textContent + "' onkeyup='storeData(this)'></div>";
  355. }
  356. } else {
  357. if (x[0].childNodes[i].nodeName === "business-type") {
  358. ret += "<div style='float:left;width:35%;text-align:right;height:32px;vertical-align:middle;padding-top:3px;font-weight:900;white-space:nowrap;'>" + x[0].childNodes[i].nodeName + "&nbsp;&nbsp;</div><div style='float:right;width:65%;height:32px;'>" + "<input type='text' id='cube-detail-" + x[0].childNodes[i].nodeName + "' value='" + x[0].childNodes[i].textContent + "' onkeyup='storeData(this)' style='color:green' readonly></div>";
  359. } else if (x[0].childNodes[i].nodeName === "guid") {
  360. ret += "<div style='float:left;width:35%;text-align:right;height:32px;vertical-align:middle;padding-top:3px;font-weight:900;white-space:nowrap;'>" + x[0].childNodes[i].nodeName + "&nbsp;&nbsp;</div><div style='float:right;width:65%;height:32px;'>" + "<input type='text' id='cube-detail-" + x[0].childNodes[i].nodeName + "' value='" + x[0].childNodes[i].textContent + "' onkeyup='storeData(this)' style='color:green' readonly></div>";
  361. } else if (x[0].childNodes[i].nodeName === "password") {
  362. <?PHP if ($password != PHP_STR): ?>
  363. ret += "<div style='float:left;width:35%;text-align:right;height:32px;vertical-align:middle;padding-top:3px;font-weight:900;white-space:nowrap;'>" + x[0].childNodes[i].nodeName + "&nbsp;&nbsp;</div><div style='float:right;width:65%;height:32px;'>" + "<input type='text' id='cube-detail-" + x[0].childNodes[i].nodeName + "' value='" + x[0].childNodes[i].textContent + "' onkeyup='storeData(this)' style='color:green' readonly></div>";
  364. <?PHP endif; ?>
  365. } else if (x[0].childNodes[i].nodeName === "city-zip-prov") {
  366. ret += "<div style='float:left;width:35%;text-align:right;height:32px;vertical-align:middle;padding-top:3px;font-weight:900;white-space:nowrap;'>" + x[0].childNodes[i].nodeName + "&nbsp;&nbsp;</div><div style='float:right;width:65%;height:32px;'>" + "<input type='text' id='cube-detail-" + x[0].childNodes[i].nodeName + "' value='" + x[0].childNodes[i].textContent + "' onkeyup='storeData(this)' style='color:green' readonly></div>";
  367. } else if (x[0].childNodes[i].nodeName === "country") {
  368. ret += "<div style='float:left;width:35%;text-align:right;height:32px;vertical-align:middle;padding-top:3px;font-weight:900;white-space:nowrap;'>" + x[0].childNodes[i].nodeName + "&nbsp;&nbsp;</div><div style='float:right;width:65%;height:32px;'>" + "<input type='text' id='cube-detail-" + x[0].childNodes[i].nodeName + "' value='" + x[0].childNodes[i].textContent + "' onkeyup='storeData(this)' style='color:green' readonly></div>";
  369. } else {
  370. ret += "<div style='float:left;width:35%;text-align:right;height:32px;vertical-align:middle;padding-top:3px;font-weight:900;white-space:nowrap;'>" + x[0].childNodes[i].nodeName + "&nbsp;&nbsp;</div><div style='float:right;width:65%;height:32px;'>" + "<input type='text' id='cube-detail-" + x[0].childNodes[i].nodeName + "' value='" + x[0].childNodes[i].textContent + "' onkeyup='storeData(this)'></div>";
  371. }
  372. }
  373. }
  374. }
  375. if ((detail==="pictures") || (detail==="menu")) {
  376. ret += "<div style='padding-left:80px;clear:both;'><br>you can use eg. Goolge Drive or Microsoft OneDrive to host your pictures.</div>"
  377. }
  378. ret += "</div>";
  379. return ret;
  380. }
  381. /*
  382. * Store the old data of the text control
  383. *
  384. * @param {InterfaceEl} tthis, the text control under editing
  385. * @returns void
  386. */
  387. /*function storeOldData(tthis) {
  388. //alert("keypress");
  389. lineOldVal = $(tthis).val();
  390. }*/
  391. /*
  392. * Store in the cube object the new data of the text control
  393. *
  394. * @param {InterfaceEl} tthis, the text control under editing
  395. * @returns void
  396. */
  397. function storeData(tthis) {
  398. //alert("keyup");
  399. lineNewVal = $(tthis).val();
  400. //alert(lineNewVal);
  401. nodeName = tthis.id;
  402. nodeName = nodeName.replace("cube-detail-","");
  403. //alert(nodeName);
  404. xmlStr = curcube.getxml();
  405. //$("#log").html($("#log").html() + "old=" + "/(\<" + nodeName + "\>).*(\<\/" + nodeName + "\>)/gs" + "\n");
  406. //$("#log").html($("#log").html() + "new=" + lineNewVal + "\n");
  407. //alert("<" + nodeName + ">" + lineNewVal + "</" + nodeName + ">");
  408. //re = "/(\<" + nodeName + "\>).*(\<\/" + nodeName + "\>)/gs";
  409. switch (nodeName) {
  410. case "name":
  411. re = /(\<name>).*(\<\/name>)/gs;
  412. break;
  413. case "address-line1":
  414. re = /(\<address-line1>).*(\<\/address-line1>)/gs;
  415. break;
  416. case "address-line2":
  417. re = /(\<address-line2>).*(\<\/address-line2>)/gs;
  418. break;
  419. case "address-line3":
  420. re = /(\<address-line3>).*(\<\/address-line3>)/gs;
  421. break;
  422. case "city-zip-prov":
  423. re = /(\<city-zip-prov>).*(\<\/city-zip-prov>)/gs;
  424. break;
  425. case "country":
  426. re = /(\<country>).*(\<\/country>)/gs;
  427. break;
  428. case "tel":
  429. re = /(\<tel>).*(\<\/tel>)/gs;
  430. break;
  431. case "fax":
  432. re = /(\<fax>).*(\<\/fax>)/gs;
  433. break;
  434. case "cell":
  435. re = /(\<cell>).*(\<\/cell>)/gs;
  436. break;
  437. case "description":
  438. re = /(\<description>).*(\<\/description>)/gs;
  439. break;
  440. }
  441. xmlStr = xmlStr.replace(re, "$1" + lineNewVal + "$2");
  442. //xmlStr = xmlStr.replace("<" + nodeName + ">" + lineOldVal + "</" + nodeName + ">", "<" + nodeName + ">" + lineNewVal + "</" + nodeName + ">");
  443. //alert(xmlStr);
  444. curcube.xml = xmlStr;
  445. dataChanged = true;
  446. }
  447. /*
  448. * Store in the cube object the new pic data
  449. *
  450. * @param {InterfaceEl} tthis, the text control under editing
  451. * @returns void
  452. */
  453. function storePicData(tthis) {
  454. //alert("keyup");
  455. lineNewVal = $(tthis).val();
  456. nodeName = tthis.id;
  457. nodeName = nodeName.replace("cube-detail-","");
  458. //alert(nodeName);
  459. xmlStr = curcube.getxml();
  460. switch (nodeName) {
  461. case "menu1":
  462. re = /(\<menu1\stype\=\"pic\">).*(\<\/menu1>)/gs;
  463. break;
  464. case "menu2":
  465. re = /(\<menu2\stype\=\"pic\">).*(\<\/menu2>)/gs;
  466. break;
  467. case "menu3":
  468. re = /(\<menu3\stype\=\"pic\">).*(\<\/menu3>)/gs;
  469. break;
  470. case "pic1":
  471. re = /(\<pic1\stype\=\"pic\">).*(\<\/pic1>)/gs;
  472. break;
  473. case "pic2":
  474. re = /(\<pic2\stype\=\"pic\">).*(\<\/pic2>)/gs;
  475. break;
  476. case "pic3":
  477. re = /(\<pic3\stype\=\"pic\">).*(\<\/pic3>)/gs;
  478. break;
  479. case "pic4":
  480. re = /(\<pic4\stype\=\"pic\">).*(\<\/pic4>)/gs;
  481. break;
  482. case "pic5":
  483. re = /(\<pic5\stype\=\"pic\">).*(\<\/pic5>)/gs;
  484. break;
  485. }
  486. xmlStr = xmlStr.replace(re, "$1" + lineNewVal + "$2")
  487. //xmlStr = xmlStr.replace("<" + nodeName + " type=\"pic\">" + lineOldVal + "</" + nodeName + ">", "<" + nodeName + " type=\"pic\">" + lineNewVal + "</" + nodeName + ">");
  488. //alert(xmlStr);
  489. curcube.xml = xmlStr;
  490. dataChanged = true;
  491. }
  492. function _saveData() {
  493. if (dataChanged) {
  494. curcube.savedata();
  495. //saveData();
  496. dataChanged = false;
  497. }
  498. }
  499. setInterval("_saveData()", 1500);
  500. /*
  501. * Display the given data detail
  502. *
  503. * @param <interfaceEl> selected cube
  504. * @returns void
  505. */
  506. function openDetail(tthis) {
  507. myhtml = getDetailData(curcube.getxml(), $(tthis).attr("target"));
  508. $("#detailtitle").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + $(tthis).attr("target") + ":");
  509. $("#detaildata").html(myhtml);
  510. $("#datadetail").show();
  511. //alert(curcube.getxml());
  512. }
  513. </script>
  514. <script>
  515. /*
  516. * Boot up code
  517. */
  518. //var fetchDataIntervalId;
  519. /*
  520. * App starting proc
  521. *
  522. * @returns void
  523. */
  524. function startApp() {
  525. <?php
  526. if ($password!=PHP_STR) {
  527. $cubedisplay="inline";
  528. } else {
  529. $cubedisplay="none";
  530. }
  531. chdir(APP_DATA_PATH);
  532. foreach (glob("*.xml") as $filename) { ?>
  533. i = parseInt("<?php echo(substr(substr($filename, 0, strlen($filename)-4),4));?>");
  534. $("#cubeList").html($("#cubeList").html()+"<div id='cube" + i + "' class='cube' style='display:<?PHP echo($cubedisplay); ?>' order='" + i + "' onclick='selCube(this)' draggable='true' ondragstart='onDragStart(this, event);' onmouseover='onMouseOver();'><div id='cube" + i + "name' class='cubename'>cube#" + i + "</div></div>");
  535. $("#cube" + i + "name").html(businessType + "#" + i);
  536. if (i<10) {
  537. newFormalName = "cube" + "00" + i;
  538. } else if (i<100) {
  539. newFormalName = "cube" + "0" + i;
  540. } else {
  541. newFormalName = "cube" + i;
  542. }
  543. cubes[i-1] = new myCube(businessType + "#" + i, newFormalName, "<?php echo(APP_HOST)?>");
  544. cubes[i-1].start();
  545. totcubes = i;
  546. <?php
  547. }
  548. ?>
  549. $("#cubeList").show();
  550. $("#vplayer").get(0).pause();
  551. $("#HCsplash").css("display","none");
  552. $(".header").show();
  553. //fetchDataIntervalId = setInterval("_fetchData()", 2000);
  554. }
  555. /*
  556. * call to startApp
  557. *
  558. * @returns void
  559. */
  560. function _startApp() {
  561. setTimeout("startApp()", 1000);
  562. }
  563. /*
  564. * Set the elements position
  565. */
  566. function setContentPos() {
  567. $("#cubeList").css("height", parseInt(window.innerHeight-20) + "px");
  568. mytop = parseInt((window.innerHeight - $("#cubectrls").height()) / 2);
  569. mytop = mytop + parseInt($("#cubectrls").height() / 4);
  570. myleft = parseInt((window.innerWidth - $("#cubectrls").width()) / 2);
  571. myleft = myleft + parseInt($("#cubectrls").width() / 5);
  572. $("#cubectrls").css("top", mytop+"px");
  573. $("#cubectrls").css("left", (myleft+40)+"px");
  574. mytop = parseInt((window.innerHeight - $("#zoomedview").height()) / 2);
  575. myleft = parseInt((window.innerWidth - $("#zoomedview").width()) / 2);
  576. $("#zoomedview").css("top", mytop+"px");
  577. $("#zoomedview").css("left", (myleft+40)+"px");
  578. mytop = parseInt((window.innerHeight - $("#cubelinks").height()) / 2);
  579. myleft = parseInt((window.innerWidth - $("#cubelinks").width()) / 2);
  580. $("#cubelinks").css("top", (mytop-170)+"px");
  581. $("#cubelinks").css("left", (myleft+240)+"px");
  582. mytop = parseInt(window.innerHeight - ($("#passworddisplay").height() + 60));
  583. $("#passworddisplay").css("top", mytop+"px");
  584. }
  585. function setFooterPos() {
  586. if (document.getElementById("footerCont")) {
  587. //if ($("#Password").val() === "") {
  588. // tollerance = 48;
  589. // } else {
  590. // tollerance = 15;
  591. //}
  592. tollerance = 22;
  593. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance ) + "px");
  594. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance + 6) + "px");
  595. }
  596. }
  597. window.addEventListener("load", function() {
  598. setContentPos();
  599. if ($("#cubeList").css("display")==="none") {
  600. setTimeout("setFooterPos()", 9000);
  601. } else {
  602. setTimeout("setFooterPos()", 2000);
  603. }
  604. //Resetting secrets..
  605. //$("#_read_xml_cube1").val("");
  606. //$("#_read_xml_cube2").val("");
  607. //$("#_read_xml_cube3").val("");
  608. //$("#_read_xml_cube4").val("");
  609. //$("#_read_xml_cube5").val("");
  610. //Debug
  611. $("#hcube").val("");
  612. $("#vcube").val("");
  613. $("#hcur").val("");
  614. $("#vcur").val("");
  615. $("#curcube").val("");
  616. //Splash
  617. $("#HCsplash").show();
  618. $("#vplayer").get(0).play();
  619. }, true);
  620. window.addEventListener("load", function() {
  621. // Fisnished the Intro load the app..
  622. document.getElementById("vplayer").onended=_startApp;
  623. // A bit of preload..
  624. bgimg = new Image();
  625. bgimg.src = "../res/bg.jpg";
  626. });
  627. window.addEventListener("resize", function() {
  628. setTimeout("setContentPos()", 2000);
  629. if ($("#cubeList").css("display")==="none") {
  630. setTimeout("setFooterPos()", 9000);
  631. } else {
  632. setTimeout("setFooterPos()", 2000);
  633. }
  634. });
  635. // -- End Boot up code
  636. </script>
  637. </head>
  638. <body>
  639. <div id="HCsplash" style="padding-top: 40px; text-align:center;color:#d4b0dc;font-family:'Rampart One';display:none;">
  640. <div id="myh1" style="position:relative; top:80px;"><H1>5 CUBE</H1></div><br><br>
  641. <video id="vplayer">
  642. <source src="../res/cube.mp4" type="video/mp4">
  643. </video>
  644. </div>
  645. <form id="frmHC" method="POST" action="/" target="_self" enctype="multipart/form-data">
  646. <div class="header" style="margin-top:18px; display:none;">
  647. &nbsp;&nbsp;<a href="http://5cube.5mode-foss.eu" target="_self" style="color:#d4b0dc; text-decoration: none;"><img src="/res/1cube.png" style="width:25px;">&nbsp;5 Cube</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://github.com/par7133/5cube" style="color:#d4b0dc;"><span style="color:#d4b0dc;">on</span> github</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailto:posta@elettronica.lol" style="color:#d4b0dc;"><span style="color:#d4b0dc;">for</span> feedback</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="tel:+39-331-4029415" style="font-size:13px;background-color:#15c60b;border:2px solid #15c60b;color:#000000;height:27px;text-decoration:none;">&nbsp;&nbsp;get support&nbsp;&nbsp;</a>
  648. </div>
  649. <div id="debugdisplay" style="float:left;position:absolute;top:680px;left:50px;width:255px;display:none;">
  650. <input id="hcube" type="text"><br>
  651. <input id="vcube" type="text"><br>
  652. <input id="hcur" type="text"><br>
  653. <input id="vcur" type="text">
  654. <input id="curcube" type="text">
  655. </div>
  656. <div id="passworddisplay" style="float:left;position:fixed;top:680px;left:50px;width:255px;height:120px;background:black;text-align:left;white-space:nowrap; font-family:'Bungee Hairline'; color:#d4b0dc; font-weight:900;z-index:99999;">
  657. <br>
  658. &nbsp;&nbsp;<input type="password" id="Password" name="Password" placeholder="password" style="font-size:18px; background:transparent; width: 60%; border-radius:3px; font-weight:900;" value="<?php echo($password);?>" autocomplete="off">&nbsp;<input type="submit" value="<?php echo(getResource("Go", $curLocale));?>" style="text-align:left;width:25%;"><br>
  659. &nbsp;&nbsp;<input type="text" id="Salt" placeholder="salt" style="position:relative; top:+5px; font-size:18px; background:transparent; width: 90%; border-radius:3px; font-weight:900;" autocomplete="off"><br>
  660. <div style="text-align:center;">
  661. <a href="#" onclick="showEncodedPassword();" style="position:relative; left:-2px; top:+5px; font-size:18px; font-weight:900; color:#d4b0dc;"><?php echo(getResource("Hash Me", $curLocale));?>!</a>
  662. </div>
  663. <!--<textarea id="log"></textarea>-->
  664. </div>
  665. <div id="cubeList" style="position:absolute; width:100%; min-height: 500px; display:none; color:#d4b0dc; border: 0px solid red;" ondragover="onDragOver(event);" ondrop="onDrop(event);">
  666. &nbsp;
  667. </div>
  668. <map name="ctrls-map">
  669. <area target="" alt="" title="" href="#" onclick="turnLeft();" onmouseover="zoomviewOver()" coords="408,122,120,3" shape="rect">
  670. <area target="" alt="" title="" href="#" onclick="turnUp();" onmouseover="zoomviewOver()" coords="411,272,525,3" shape="rect">
  671. <area target="" alt="" title="" href="#" onclick="turnRight();" onmouseover="zoomviewOver()" coords="407,497,115,383,407,495" shape="rect">
  672. <area target="" alt="" title="" href="#" onclick="turnDown();" onmouseover="zoomviewOver()" coords="176,347,66,411,2,295,0,144,62,142,106,238,105,243,63,144,109,237" shape="poly">
  673. </map>
  674. <div id="cubectrls" style="position:absolute;width:527px;height:497px;display:none;border:0px solid green; z-index:99998; transform: rotate(-63deg);" onmouseover="zoomviewOver()" onmouseout="zoomviewOut()">
  675. <img src="../res/ctrlbg.png" style="width:527px;height:497px;" usemap="#ctrls-map">
  676. </div>
  677. <div id="zoomedview" style="position:absolute;width:396px;height:477px;display:none;border:0px solid red; z-index:99997">
  678. <div id="cubezvname" style="position:relative; top:+30px;font-size:54px;color:#bd006e;width:400px;margin:auto;text-align:center;font-family:'Bungee Hairline';font-weight:900;"></div>
  679. <div id="cubezv" style="float:left;background:url(../res/1cube.png);background-size:cover;width:396px;height:477px;margin:50px;vertical-align:middle;text-align:center;">
  680. </div>
  681. </div>
  682. <div id="cubelinks" style="position:absolute;width:496px;height:7px;display:none;border:0px solid red; z-index:99999">
  683. <span id="face2" target="" onclick="openDetail(this)" onmouseover="zoomviewOver()" style="position:relative;top:160px;left:10px;background:transparent;border:0px;font-size:24px;color:#44ff00;width:450px;height:120px;margin:auto;text-align:center;font-family:'Bungee Hairline';font-weight:900;white-space:nowrap;cursor:pointer; transform: rotate(+63deg);"></span><br>
  684. <span id="face1" target="" onclick="openDetail(this)" onmouseover="zoomviewOver()" style="position:relative;top:+280px;left:-270px;background:transparent;border:0px solid red;font-size:24px;color:#44ff00;width:450px;height:120px;margin:auto;text-align:left;font-family:'Bungee Hairline';font-weight:900;white-space:nowrap;cursor:pointer; transform: rotate(+63deg);"></span><br>
  685. <span id="face3" target="" onclick="openDetail(this)" onmouseover="zoomviewOver()" style="position:relative;top:+160px;left:+240px;background:transparent;border:0px;font-size:24px;color:#44ff00;width:450px;height:80px;margin:auto;text-align:left;font-family:'Bungee Hairline';font-weight:900;transform: rotate(0deg); white-space:nowrap;cursor:pointer; transform: rotate(+63deg);"></span><br>
  686. </div>
  687. <div id="datadetail" style="float:right;background:#0d0d0d;border-left:1px solid white;width:380px;height:900px;display:none;color:#44ff00;" onmouseover="zoomviewOver()">
  688. <span id="detailtitle" style="color:#bd006e;font-size:20px;font-weight:900;"></span><br><br>
  689. <span id="detaildata"></span>
  690. </div>
  691. <!--
  692. <input type="hidden" id="_read_xml_cube1">
  693. <input type="hidden" id="_read_xml_cube2">
  694. <input type="hidden" id="_read_xml_cube3">
  695. <input type="hidden" id="_read_xml_cube4">
  696. <input type="hidden" id="_read_xml_cube5">
  697. -->
  698. </form>
  699. <div class="footer">
  700. <div id="footerCont">&nbsp;</div>
  701. <div id="footer"><span style="background:#0d0d0d;color:#d4b0dc;opacity:1.0;margin-right:10px;">&nbsp;&nbsp;A <a href="http://5mode.com" style="color:#d4b0dc; text-decoration:underline;">5 Mode</a> project and <a href="http://demo.5mode.com" style="color:#d4b0dc; text-decoration:underline;">WYSIWYG</a> system. Some rights reserved.</span></div>
  702. </div>
  703. <?php if (file_exists(APP_PATH . DIRECTORY_SEPARATOR . "metrics.html")): ?>
  704. <?php include(APP_PATH . DIRECTORY_SEPARATOR . "metrics.html"); ?>
  705. <?php endif; ?>
  706. </body>
  707. </html>