guide.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. function guide_init() {
  2. $("guide").each(function () {
  3. if ($(this).attr("init") != "1") {
  4. if ($(this).text().length > 0) {
  5. $(this).css("background", "unset");
  6. }
  7. if ($(this).offset().left < $(document.body).width() / 2) {
  8. $(this).append(
  9. '<div class="guide_contence" style="left: -5px;"></div>'
  10. );
  11. $(".guide_contence:after").css("left", "0");
  12. } else {
  13. $(this).append(
  14. '<div class="guide_contence" style="right: -5px;"></div>'
  15. );
  16. $(".guide_contence:after").css("right", "0");
  17. }
  18. $(this).attr("init", "1");
  19. }
  20. });
  21. $("guide").mouseenter(function () {
  22. if ($(this).children(".guide_contence").first().html().length > 0) {
  23. return;
  24. }
  25. let gid = $(this).attr("gid");
  26. $.get(
  27. "../guide/get.php",
  28. {
  29. id: gid,
  30. },
  31. function (data, status) {
  32. try {
  33. let jsonGuide = JSON.parse(data);
  34. $("guide[gid='" + jsonGuide.id + "']")
  35. .find(".guide_contence")
  36. .html(marked(jsonGuide.data));
  37. } catch (e) {
  38. console.error(e);
  39. }
  40. }
  41. );
  42. });
  43. }
  44. function guide_get(guide_id) {
  45. $.get(
  46. "../guide/get.php",
  47. {
  48. id: guide_id,
  49. },
  50. function (data, status) {
  51. try {
  52. let jsonGuide = JSON.parse(data);
  53. $("#guide_" + jsonGuide.id).html(marked(jsonGuide.data));
  54. } catch (e) {
  55. console.error(e);
  56. }
  57. }
  58. );
  59. }