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

Former-commit-id: b67711dfe796fe21944c8546766f300de8f676b2 [formerly a4d179052e2e1a41e8386a25d4e3271212764ff9] [formerly bbaafc6a325179acb67f13a8b586c1c1857aae2e [formerly a0e99753fa97bbd924a126d18ef94251a5714914 [formerly a1fdd16073]]]
Former-commit-id: 5a4f9291ae8d63e95ca5b53daf7f3892308311a3 [formerly 38f184d06b0b4d49fbf27977b247bfa98c92bd1c]
Former-commit-id: 678df5edc9528504cab10aaee24a1a309af2ff4d
Former-commit-id: a35e601dcc
This commit is contained in:
Zack Scholl 2016-03-31 11:03:00 -04:00
parent d511eb5371
commit f61590de70
2 changed files with 11 additions and 6 deletions

View File

@ -459,6 +459,15 @@ func renderList(c *gin.Context, title string) {
pClean.AllowDataURIImages() pClean.AllowDataURIImages()
text := pClean.SanitizeBytes([]byte(p.CurrentText)) text := pClean.SanitizeBytes([]byte(p.CurrentText))
listItems, _ := reorderList(string(text)) 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{ c.HTML(http.StatusOK, "list.tmpl", gin.H{
"Title": title, "Title": title,
"WikiName": RuntimeArgs.WikiName, "WikiName": RuntimeArgs.WikiName,

View File

@ -11,6 +11,7 @@
padding: 0; padding: 0;
list-style-type: none; list-style-type: none;
} }
span { cursor: pointer; }
</style> </style>
@ -45,7 +46,7 @@
<div class="yue"> <div class="yue">
<ul> <ul>
{{ range $index, $element := .ListItems }} {{ range $index, $element := .ListItems }}
<a href="#" id="{{ $index }}" class="deletable">{{ $element }}</a> {{ $element }}
{{ end }} {{ end }}
</ul> </ul>
</div> </div>
@ -54,9 +55,6 @@
$('.deletable').click(function(event) { $('.deletable').click(function(event) {
event.preventDefault(); event.preventDefault();
var lineNum = $(this).attr('id') var lineNum = $(this).attr('id')
var href = $(this).attr('href')
if (href == "#") {
console.log(lineNum)
$.ajax({ $.ajax({
url: "/listitem" + '?' + $.param({ url: "/listitem" + '?' + $.param({
"lineNum": lineNum, "lineNum": lineNum,
@ -67,8 +65,6 @@
window.location.reload(true); window.location.reload(true);
} }
}); });
}
}); });
$(document).keydown(function(e){ $(document).keydown(function(e){