function loadShepherd(f) { if (typeof Shepherd === 'undefined' || Shepherd.activeTour === null) { var theme = 'shepherd-theme-' + ($('body').hasClass('dark') ? 'dark' : 'default'); lichess.loadCss('vendor/' + theme + '.css'); lichess.loadScript('vendor/shepherd/dist/js/tether.js', { noVersion: true }).then(function () { lichess.loadScript('vendor/shepherd/dist/js/shepherd.min.js', { noVersion: true }).then(function () { f(theme); }); }); } } lichess.studyTour = function (study) { loadShepherd(function (theme) { var onTab = function (tab) { return { 'before-show': function () { study.setTab(tab); }, }; }; var tour = new Shepherd.Tour({ defaults: { classes: theme, scrollTo: false, showCancelLink: true, }, }); [ { title: 'Welcome to Lichess Study!', text: 'This is a shared analysis board.

' + 'Use it to analyse and annotate games,
' + 'discuss positions with friends,
' + 'and of course for chess lessons!

' + "It's a powerful tool, let's take some time to see how it works.", attachTo: 'main.analyse .study__buttons .help top', }, { title: 'Shared and saved', text: 'Other members can see your moves in real time!
' + 'Plus, everything is saved forever.', attachTo: 'main.analyse .areplay left', }, { title: 'Study members', text: " Spectators can view the study and talk in the chat.
" + "
Contributors can make moves and update the study.", attachTo: '.study__members right', when: onTab('members'), }, study.isOwner ? { title: 'Invite members', text: "By clicking the button.
" + 'Then decide who can contribute or not.', attachTo: '.study__members .add right', when: onTab('members'), } : null, { title: 'Study chapters', text: 'A study can contain several chapters.
' + 'Each chapter has a distinct initial position and move tree.', attachTo: '.study__chapters right', when: onTab('chapters'), }, study.isContrib ? { title: 'Create new chapters', text: "By clicking the button.", attachTo: '.study__chapters .add right', when: onTab('chapters'), } : null, study.isContrib ? { title: 'Comment on a position', text: "With the button, or a right click on the move list on the right.
" + 'Comments are shared and persisted.', attachTo: '.study__buttons .left-buttons .comments top', } : null, study.isContrib ? { title: 'Annotate a position', text: 'With the !? button, or a right click on the move list on the right.
' + 'Annotation glyphs are shared and persisted.', attachTo: '.study__buttons .left-buttons .glyphs top', } : null, { title: 'Thanks for your time', text: "You can find your previous studies from your profile page.
" + "There is also a blog post about studies.
" + 'Power users might want to press "?" to see keyboard shortcuts.
' + 'Have fun!', buttons: [ { text: 'Done', action: tour.next, }, ], attachTo: 'main.analyse .study__buttons .help top', }, ] .filter(function (v) { return v; }) .forEach(function (s) { tour.addStep(s.title, s); }); tour.start(); }); };