mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 08:34:08 +00:00
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
//document ready ,
|
|
$(function() {
|
|
$("a").click(function(event) {
|
|
var link = $(this).attr("href");
|
|
if(link.indexOf(":")>=0){
|
|
return;
|
|
}
|
|
|
|
var newLink;
|
|
var href = window.location.href;
|
|
|
|
if (link.startsWith("#")) {
|
|
//the href may contain # fragment already.remove them before append the new #fragment
|
|
var index = href.indexOf("#");
|
|
if(index>-1)
|
|
{
|
|
newLink = href.substring(0, index) + link;
|
|
}
|
|
else{
|
|
newLink= href+link;
|
|
}
|
|
} else {
|
|
var 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();
|
|
}
|