Vor Kurzem aufgerufene Suchen
Keine vor kurzem aufgerufene Suchen

Ziv Bass Specktor
Beigetreten 16. Apr. 2021
·
Letzte Aktivität 27. Okt. 2021
Folge ich
0
Follower
0
Gesamtaktivitäten
8
Stimmen
0
Abonnements
3
AKTIVITÄTSÜBERSICHT
BADGES
BEITRÄGE
POSTS
COMMUNITY-KOMMENTARE
BEITRAGSKOMMENTARE
AKTIVITÄTSÜBERSICHT
Neueste Aktivität von Ziv Bass Specktor
Ziv Bass Specktor hat einen Kommentar hinterlassen
This is a very important feature.
Just as an example - our system sends messages to our clients servers, which have to whitelist our IPs so the messages get through.
Once in a while we update the IPs and unless we notify clients manually about the changes their messages get lost.
We strongly support the feature request that allows sending emails to all followers when the article admin decides, and not with every update that may be small and insignificant.
Kommentar anzeigen · Gepostet 12. Dez. 2017 · Ziv Bass Specktor
0
Follower
1
Stimme
0
Kommentare
Ziv Bass Specktor hat einen Kommentar hinterlassen
Sure, Ashwini. Here it goes:
/*** Table of contents code ***/
var $headers = $('.article-body h2');
if ($headers.length > 0) {
var $toc = $('
var $firstUl = $('
- ');
var $currentUl = $firstUl;
var previous_level = 2;
$firstUl.appendTo($toc);
$toc.prependTo('section.article-info');
// start with first H1
insertHeading($headers[0]);
}
function insertHeading(heading) {
var $heading = $(heading);
// what level heading are we on?
var current_level = headingLevel(heading);
// if it's an H2, add it to the original list
if (current_level === 2) {
newLi($heading, $firstUl);
$currentUl = $firstUl;
}
// if it's the same as the one before it, add it to the current list
else if (current_level === previous_level) {
newLi($heading, $currentUl);
}
// if it's one level higher than the one before it... time to make a new nested list
else if (current_level > previous_level) {
nestUl();
newLi($heading, $currentUl);
}
previous_level = current_level;
var $nextHeading = $heading.nextAll("h1, h2, h3, h4, h5, h6").first()[0];
// if there's any headings left... run this again
if ($nextHeading) insertHeading($nextHeading);
}
// adds a new UL to the current UL
function nestUl() {
var $newUl = $('
- ');
$newUl.appendTo($currentUl);
$currentUl = $newUl;
}
// returns a numerical value for each heading
function headingLevel(heading) {
switch (heading.nodeName) {
case 'H1':
return 1;
break;
case 'H2':
return 2;
break;
case 'H3':
return 3;
break;
case 'H4':
return 4;
break;
case 'H5':
return 1;
break;
case 'H6':
return 6;
break;
default:
return 0;
}
}
// inserts a new line to the current list
function newLi(heading, $list) {
var $heading = $(heading);
var $wrapper = $('
//var $link = $('').prop('href', '#' + $heading.prop('id'));
var $anchorname = $heading[0].outerText.replace (/\s/g,'')
var $link = $('').prop('href', '#' + $anchorname);
$link.html(' ' + $heading.text());
$link.appendTo($wrapper);
$wrapper.appendTo($list);
var place_in_parent = $list.children('li').length;
if ($list.parent()[0].nodeName === 'DIV') {
$link.find('.index').text(place_in_parent)
} else {
$link.find('.index').text($wrapper.parent().prev('li').find('.index').text() + '.' + place_in_parent)
}
$heading.html("" + $link.find('.index').text() + ' ' + $heading.text());
}
/*** End of Table of contents code ***/
Kommentar anzeigen · Gepostet 13. Aug. 2017 · Ziv Bass Specktor
0
Follower
0
Stimmen
0
Kommentare
Ziv Bass Specktor hat einen Kommentar hinterlassen
Nicolas, thanks again for this code.
I made a few small changes and now it works great.
If you have anymore such cool snippets to share don't be shy :-)
Kommentar anzeigen · Gepostet 03. Aug. 2017 · Ziv Bass Specktor
0
Follower
0
Stimmen
0
Kommentare
Ziv Bass Specktor hat einen Kommentar hinterlassen
Nicolas, thanks a lot for your swift answer. I really appreciate it.
Yes, I was referring to line 81. The addition of $link makes sense.
You run on the headers which you get by:
var $headers = $('.article-body h1');
The problems:
1. '.article-body h1' doesn't exist in the article template.
When I changed the code to 'h1' at least it found the main header.
2. It doesn't find any other h2, h3 etc. in the html so that's the reason why it doesn't do much.
Any idea how to fix this?
Kommentar anzeigen · Gepostet 19. Juli 2017 · Ziv Bass Specktor
0
Follower
0
Stimmen
0
Kommentare
Ziv Bass Specktor hat einen Kommentar hinterlassen
That's a great tip, but it doesn't work :-(
First, the ".appendTo($wrapper);" line gives a syntax error. What should be here before the '.appendTo'?
Second, the code doesn't seem to be called at all. How should it be activated?
Third, isn't ZenDesk responsible for checking and publishing these kind of tips? TOC is a basic feature in most platforms, so at least ZenDesk should guide users on how to do this as the ZD Guide doesn't provide it.
Kommentar anzeigen · Gepostet 18. Juli 2017 · Ziv Bass Specktor
0
Follower
0
Stimmen
0
Kommentare