-
-
Save Etana/6a037b1821899f1a884c01bf09bd17c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
var forums = [20, 101]; | |
var f = +location.pathname.replace(/^\/f(\d+).*/, '$1'); | |
if ($.inArray(f, forums) === -1) return; | |
var b = +location.pathname.replace(/^\/f(\d+).*/, '$1'); | |
var t = $('.posts-description a[href^="/t"]:last,a.topictitle:last').last(), | |
k = t.closest('table,.forumbg,.posts'), d = $.when(), l = parseInt(t.attr('href').slice(2)), | |
$container = $('<div class="letter-list-container"/>').insertBefore(k), | |
r = /\/f\d+p(\d+).*/, p = +location.pathname.replace(r, '$1') || 0, | |
n = (window.do_pagination_start||'* 50').toString().replace(/[\s\S]*\* (\d+)[\s\S]*/, '$1'), | |
letterList = JSON.parse(localStorage['letter_list.f'+f] || 0), | |
v = JSON.parse(localStorage['letter_list.p.f'+f] || '{}'); | |
if (!v[p]) { | |
v[p] = l; | |
localStorage['letter_list.p.f'+f] = JSON.stringify(v); | |
} else if (v[p] !== l) { | |
letterList = 0; | |
localStorage['letter_list.p.f'+f] = '{"'+p+'":'+l+'}'; | |
} | |
if (!letterList) { | |
d = $.get('/sitemap'+f+'.xml').then(function(content) { | |
var num_post_it = 0; | |
var groups = {}; | |
$('url', content).each(function() { | |
var l = $('loc', this).text(); | |
if (r.test(l)) return; | |
var p = $('priority', this).text(); | |
if (p) { | |
if (p === "0.75") num_post_it++; | |
return; | |
} | |
l = l.replace(/.*\/t\d+-(.+)/, '$1'); | |
if (l === 'topic') l = '&'; | |
groups[l[0]] = (groups[l[0]] || 0) + 1; | |
}); | |
var letters = Object.keys(groups); | |
letters.sort(); | |
var current = num_post_it; | |
letterList = []; | |
$.each(letters, function (_, l) { | |
letterList.push([l.toUpperCase(), current]); | |
current += groups[l]; | |
}); | |
localStorage['letter_list.f'+f] = JSON.stringify(letterList); | |
}); | |
}; | |
d.then(function() { | |
$.each(letterList, function(_, v) { | |
var w = v[1] - v[1] % n; | |
if (p !== w) { | |
$container.append('<a href="/f'+f+'p'+w+'-">'+v[0]+'</a> '); | |
} else { | |
$container.append('<strong>'+v[0]+'</strong> '); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment