File size: 1,851 Bytes
b6bd94d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//document ready
(function ($) {
  $(function () {
    $(document).on("click", "a", function (event) {
      var link = $(this).attr("href");
      if ("string" != typeof link) {
        return;
      }

      if (link.indexOf("javascript:") >= 0 || link === "#") {
        return;
      }

      //return if the link is like gdlookup:// or other valid url.bword:xxx is also valid url.
      if (link.indexOf(":") >= 0) {
        emitClickedEvent(link);
        return false;
      }
      emitClickedEvent("");

      var newLink;
      var href = window.location.href;
      var index = -1;
      if (link.startsWith("#")) {
        //the href may contain # fragment already.remove them before append the new #fragment
        index = href.indexOf("#");
        if (index > -1) {
          newLink = href.substring(0, index) + link;
        } else {
          newLink = href + link;
        }
      }
      //if hashtag # is not in the start position,it must greater than 0
      else if (link.indexOf("#") > 0) {
        index = link.indexOf("#");
        newLink =
          "gdlookup://localhost/" +
          link.substring(0, index) +
          "?gdanchor=" +
          link.substring(index + 1);
      } else {
        index = href.indexOf("?");

        if (link.indexOf("?gdanchor") > -1) {
          newLink = "gdlookup://localhost/" + link;
        } else {
          if (index > -1) {
            newLink = href.substring(0, index) + "?word=" + link;
          } else {
            newLink = href + "?word=" + link;
          }
        }
      }
      $(this).attr("href", newLink);
    });

    //monitor iframe height.
    $("iframe").iFrameResize({
      checkOrigin: false,
      maxHeight: 800,
      scrolling: true,
      warningTimeout: 0,
      minHeight: 550,
      log: true,
      autoResize: false,
    });
  });
})(jQuery);