guide.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. }
  11. else {
  12. $(this).append('<div class="guide_contence" style="right: -5px;"></div>');
  13. $(".guide_contence:after").css("right", "0");
  14. }
  15. $(this).attr("init", "1");
  16. }
  17. });
  18. $("guide").mouseenter(function () {
  19. if ($(this).children(".guide_contence").first().html().length > 0) {
  20. return;
  21. }
  22. let gid = $(this).attr("gid");
  23. let guideObj = $(this);
  24. $.get("../guide/get.php",
  25. {
  26. id: gid
  27. },
  28. function (data, status) {
  29. try {
  30. let jsonGuide = JSON.parse(data);
  31. $("guide[gid='" + jsonGuide.id + "']").find(".guide_contence").html(marked(jsonGuide.data));
  32. }
  33. catch (e) {
  34. console.error(e);
  35. }
  36. });
  37. /* if ($(this).offset().left < $(document.body).width() / 2) {
  38. $(".guide_contence:after").css("left", "0");
  39. }
  40. else {
  41. $(".guide_contence:after").css("right", "0");
  42. }*/
  43. });
  44. }