Home Reference Source

cables_dev/cables/src/core/uierrors.js

  1. let simpleLogDiv = null;
  2. const data = {};
  3. let lastHtml = "";
  4. /**
  5. * @param {Op<any>} op
  6. * @param {string} id
  7. * @param {string} txt
  8. * @param {number} level
  9. * @param {{}} [options]
  10. */
  11. export function showUiErrors(op, id, txt, level, options)
  12. {
  13. console.log(txt);
  14. /* minimalcore:start */
  15. data[op.id + id] = { "op": op, "txt": txt, "id": id, "options": options };
  16. let html = "";
  17. let found = false;
  18. for (const i in data)
  19. {
  20. if (data[i] && data[i].txt)
  21. {
  22. html += data[i].op.name + ": " + data[i].txt + " " + (data[i].options?.info || "") + "<br/>";
  23. found = true;
  24. }
  25. }
  26. if (simpleLogDiv && !found)
  27. {
  28. simpleLogDiv.remove();
  29. simpleLogDiv = null;
  30. return;
  31. }
  32. if (!found) return;
  33. if (!simpleLogDiv)
  34. {
  35. simpleLogDiv = document.createElement("div");
  36. simpleLogDiv.style.position = "absolute";
  37. simpleLogDiv.style.border = "1px solid red";
  38. simpleLogDiv.style.backgroundColor = "#222";
  39. simpleLogDiv.style.zIndex = "100000";
  40. simpleLogDiv.style.padding = "10px";
  41. simpleLogDiv.style.top = "0px";
  42. simpleLogDiv.classList.add("cablesErrorLog");
  43. document.body.appendChild(simpleLogDiv);
  44. }
  45. if (lastHtml != html)
  46. {
  47. simpleLogDiv.innerHTML = html;
  48. lastHtml = html;
  49. }
  50. /* minimalcore:end */
  51. }