2
0

guide.js 1.4 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('<div class="guide_contence left" style="left: -5px;"></div>');
  9. //$(".guide_contence:after").css("left", "0");
  10. } else {
  11. $(this).append('<div class="guide_contence right" 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. let url = $(this).attr("url");
  23. if (typeof url == "undefined" || url == "") {
  24. url = "../guide/get.php";
  25. }
  26. $.get(
  27. url,
  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. }