mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
cc4e2915ec
there are cases when the <a link was generated by js after document ready . all these links have escaped the intercetor. use this new document.on(event,selector ,function) to monitor any new added link
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
//document ready
|
|
(function($){
|
|
$(function() {
|
|
$(document).on("click","a",function(event) {
|
|
var link = $(this).attr("href");
|
|
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;
|
|
}
|
|
} else {
|
|
index = href.indexOf("?");
|
|
if(index>-1)
|
|
{
|
|
newLink = href.substring(0, index) + "?word=" + link;
|
|
}
|
|
else{
|
|
newLink=href+"?word=" + link;
|
|
}
|
|
}
|
|
$(this).attr("href", newLink);
|
|
|
|
});
|
|
|
|
});
|
|
})($_$);
|
|
|
|
function playSound(sound) {
|
|
var a = new Audio(sound);
|
|
a.play();
|
|
}
|
|
|
|
function resizeIframe(obj) {
|
|
obj.style.height = obj.contentWindow.document.documentElement.scrollHeight + 'px';
|
|
}
|