guide.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. /* if ($(this).offset().left < $(document.body).width() / 2) {
  43. $(".guide_contence:after").css("left", "0");
  44. }
  45. else {
  46. $(".guide_contence:after").css("right", "0");
  47. }*/
  48. });
  49. }
  50. function guide_get(guide_id) {
  51. $.get(
  52. "../guide/get.php",
  53. {
  54. id: guide_id,
  55. },
  56. function (data, status) {
  57. try {
  58. let jsonGuide = JSON.parse(data);
  59. $("#guide_" + jsonGuide.id).html(marked(jsonGuide.data));
  60. } catch (e) {
  61. console.error(e);
  62. }
  63. }
  64. );
  65. }