inline_dict.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. function inlinedict_init(title = "Dict") {
  2. $("pali")
  3. .contents()
  4. .filter(function () {
  5. return this.nodeType != 1;
  6. })
  7. .wrap("<ps/>");
  8. $("ps").each(function () {
  9. let newText = "<pw>" + $(this).html().replace(/ /g, "</pw><pw>") + "</pw>";
  10. $(this).html(newText);
  11. });
  12. /**
  13. $('div').mouseup(function() {
  14. var text=getSelectedText();
  15. if (text!='') alert(text);
  16. });
  17. function getSelectedText() {
  18. if (window.getSelection) {
  19. return window.getSelection().toString();
  20. } else if (document.selection) {
  21. return document.selection.createRange().text;
  22. }
  23. return '';
  24. }​
  25. <div>Here is some text</div>
  26. */
  27. $("body").append(
  28. '<div id="inlinedict_dlg" title="' +
  29. title +
  30. '"><div id="inlinedict_dlg_content">' +
  31. "<iframe name='inline_dict' height='100%' width='100%' src='../dict/index.php'></iframe>" +
  32. "</div></div>"
  33. );
  34. $("#inlinedict_dlg").dialog({
  35. autoOpen: false,
  36. width: 550,
  37. buttons: [
  38. {
  39. text: "Close",
  40. click: function () {
  41. $(this).dialog("close");
  42. },
  43. },
  44. ],
  45. });
  46. }
  47. function inlinedict_open(book, para) {
  48. $("#inlinedict_dlg").dialog("open");
  49. $.get(
  50. "../term/related_para.php",
  51. {
  52. book: book,
  53. para: para,
  54. },
  55. function (data) {
  56. let para = JSON.parse(data);
  57. let html = related_para_dlg_render(para);
  58. $("#related_para_dlg_content").html(html);
  59. }
  60. );
  61. }