1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

Fixed error with links in lists

This commit is contained in:
Zack Scholl 2016-03-31 11:03:00 -04:00
parent dc6279a018
commit a1fdd16073
2 changed files with 11 additions and 6 deletions

View File

@ -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,

View File

@ -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){