mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-06-04 20:00:11 +00:00
fix: when location.url is a sub section url, 'edit' button get wrong link
This commit is contained in:
parent
ec830dec9e
commit
4fb1dcbf62
33
js/ditto.js
33
js/ditto.js
@ -152,23 +152,24 @@ function goSection(sectionId){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init_edit_button() {
|
function init_edit_button() {
|
||||||
if (ditto.base_url === null) {
|
if (ditto.base_url === null) {
|
||||||
alert("Error! You didn't set 'base_url' when calling ditto.run()!");
|
alert("Error! You didn't set 'base_url' when calling ditto.run()!");
|
||||||
|
} else {
|
||||||
|
$(ditto.edit_id).show();
|
||||||
|
$(ditto.edit_id).on("click", function() {
|
||||||
|
var hash = location.hash.replace("#", "/");
|
||||||
|
if (/#.*$/.test(hash)) {
|
||||||
|
hash = hash.replace(/#.*$/, '');
|
||||||
|
}
|
||||||
|
if (hash === "") {
|
||||||
|
hash = "/" + ditto.index.replace(".md", "");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
window.open(ditto.base_url + hash + ".md");
|
||||||
$(ditto.edit_id).show();
|
// open is better than redirecting, as the previous page history
|
||||||
$(ditto.edit_id).on("click", function() {
|
// with redirect is a bit messed up
|
||||||
var hash = location.hash.replace("#", "/");
|
});
|
||||||
|
}
|
||||||
if (hash === "") {
|
|
||||||
hash = "/" + ditto.index.replace(".md", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
window.open(ditto.base_url + hash + ".md");
|
|
||||||
// open is better than redirecting, as the previous page history
|
|
||||||
// with redirect is a bit messed up
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function replace_symbols(text) {
|
function replace_symbols(text) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user