Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1.  
  2. (function (w, d) {
  3. var cont = d.getElementById(toc_config.containerId),
  4. head = d.getElementsByTagName('head')[0],
  5. category = [];
  6. w[toc_config.jsonCallback] = function (json) {
  7. var entry = json.feed.entry,
  8. cat = json.feed.category,
  9. title, link, label, skeleton = "";
  10. for (var h = 0, hen = cat.length; h < hen; ++h) {
  11. category.push(cat[h].term)
  12. }
  13. for (var f = 0, fen = entry.length; f < fen; ++f) {
  14. if (toc_config.showNew || toc_config.showNew > 0) {
  15. if (f < toc_config.showNew + 1) {
  16. entry[f].title.$t += ' %new%'
  17. }
  18. }
  19. }
  20. entry = (toc_config.sortAlphabetically.theList) ? entry.sort(function (a, b) {
  21. return (a.title.$t.localeCompare(b.title.$t))
  22. }) : entry;
  23. if (toc_config.sortAlphabetically.thePanel) category.sort();
  24. for (var g = 0, gen = category.length; g < gen; ++g) {
  25. skeleton += '<h3 class="toc-header">' + category[g] + '</h3>';
  26. skeleton += '<div class="toc-content"><ol>';
  27. for (var i = 0, ien = entry.length; i < ien; ++i) {
  28. title = entry[i].title.$t;
  29. for (var j = 0, jen = entry[i].link.length; j < jen; ++j) {
  30. if (entry[i].link[j].rel == "alternate") {
  31. link = entry[i].link[j].href;
  32. break
  33. }
  34. }
  35. for (var k = 0, ken = entry[i].category.length; k < ken; ++k) {
  36. if (category[g] == entry[i].category[k].term) {
  37. skeleton += '<li><a href="' + link + '" title="' + title.replace(/ \%new\%$/, "") + '">' + title.replace(/ \%new\%$/, "") + '</a>' + (title.match(/\%new\%/) ? ' ' + toc_config.newText : '') + '</li>'
  38. }
  39. }
  40. }
  41. skeleton += '</ol></div>'
  42. }
  43. cont.innerHTML = skeleton;
  44. if (typeof jQuery != 'undefined') {
  45. $('#' + toc_config.containerId + ' .toc-content').hide();
  46. $('#' + toc_config.containerId + ' .toc-header').click(function () {
  47. if ($(this).hasClass('active')) return;
  48. toc_config.clickCallback(this);
  49. $('#' + toc_config.containerId + ' .toc-header').removeClass('active').next().slideUp(toc_config.slideSpeed.up, toc_config.slideEasing.up, toc_config.slideCallback.up);
  50. $(this).addClass('active').next().slideDown(toc_config.slideSpeed.down, toc_config.slideEasing.down, toc_config.slideCallback.down)
  51. }).eq(toc_config.activePanel - 1).addClass('active').next().slideDown(toc_config.slideSpeed.down, toc_config.slideEasing.down, toc_config.slideCallback.down)
  52. }
  53. };
  54. var s = d.createElement('script');
  55. s.src = toc_config.url.replace(/\/$/, "") + '/feeds/posts/summary?alt=json-in-script&max-results=' + toc_config.maxResults + '&callback=' + toc_config.jsonCallback;
  56. if (toc_config.delayLoading == "onload") {
  57. w.onload = function () {
  58. head.appendChild(s)
  59. }
  60. } else {
  61. w.setTimeout(function () {
  62. head.appendChild(s)
  63. }, toc_config.delayLoading)
  64. }
  65. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement