guide.js 1.4 KB

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