mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Fixed error with links in lists
Former-commit-id: b67711dfe796fe21944c8546766f300de8f676b2 [formerly a4d179052e2e1a41e8386a25d4e3271212764ff9] [formerly bbaafc6a325179acb67f13a8b586c1c1857aae2e [formerly a1fdd16073
]]
Former-commit-id: 5a4f9291ae8d63e95ca5b53daf7f3892308311a3 [formerly 38f184d06b0b4d49fbf27977b247bfa98c92bd1c]
Former-commit-id: 678df5edc9528504cab10aaee24a1a309af2ff4d
This commit is contained in:
parent
4e1655c7f7
commit
a35e601dcc
@ -459,6 +459,15 @@ func renderList(c *gin.Context, title string) {
|
||||
pClean.AllowDataURIImages()
|
||||
text := pClean.SanitizeBytes([]byte(p.CurrentText))
|
||||
listItems, _ := reorderList(string(text))
|
||||
for i := range listItems {
|
||||
newHTML := strings.Replace(string(listItems[i]), "</a>", "</a>"+`<span id="`+strconv.Itoa(i)+`" class="deletable">`, -1)
|
||||
newHTML = strings.Replace(newHTML, "<a href=", "</span><a href=", -1)
|
||||
newHTML = strings.Replace(newHTML, "<li>", "<li>"+`<span id="`+strconv.Itoa(i)+`" class="deletable">`, -1)
|
||||
newHTML = strings.Replace(newHTML, "</li>", "</span></li>", -1)
|
||||
newHTML = strings.Replace(newHTML, "<li>"+`<span id="`+strconv.Itoa(i)+`" class="deletable"><del>`, "<li><del>"+`<span id="`+strconv.Itoa(i)+`" class="deletable">`, -1)
|
||||
newHTML = strings.Replace(newHTML, "</del></span></li>", "</span></del></li>", -1)
|
||||
listItems[i] = template.HTML([]byte(newHTML))
|
||||
}
|
||||
c.HTML(http.StatusOK, "list.tmpl", gin.H{
|
||||
"Title": title,
|
||||
"WikiName": RuntimeArgs.WikiName,
|
||||
|
@ -11,6 +11,7 @@
|
||||
padding: 0;
|
||||
list-style-type: none;
|
||||
}
|
||||
span { cursor: pointer; }
|
||||
</style>
|
||||
|
||||
|
||||
@ -45,7 +46,7 @@
|
||||
<div class="yue">
|
||||
<ul>
|
||||
{{ range $index, $element := .ListItems }}
|
||||
<a href="#" id="{{ $index }}" class="deletable">{{ $element }}</a>
|
||||
{{ $element }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
@ -54,9 +55,6 @@
|
||||
$('.deletable').click(function(event) {
|
||||
event.preventDefault();
|
||||
var lineNum = $(this).attr('id')
|
||||
var href = $(this).attr('href')
|
||||
if (href == "#") {
|
||||
console.log(lineNum)
|
||||
$.ajax({
|
||||
url: "/listitem" + '?' + $.param({
|
||||
"lineNum": lineNum,
|
||||
@ -67,8 +65,6 @@
|
||||
window.location.reload(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$(document).keydown(function(e){
|
||||
|
Loading…
Reference in New Issue
Block a user