guide.js 1.3 KB

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