Preview of the new site search. The current form is still at Advanced Search.
Search
Everything on the Bodhicitta website
Try tonglen, Santideva (accents optional), 9.1 (a verse), "bodhicitta of aspiration" (exact phrase) or བྱང་ཆུབ་སེམས.
Search tips
- "exact phrase" in quotes finds the words together: "wish-fulfilling jewel"
- -word leaves a word out: compassion -dalai
- OR finds either word: tonglen OR lojong
- word* matches any ending: meditat*
- intitle: searches titles only: intitle:bodhisattva
- incategory: searches by tag. Topics, decades, people and publishers are all tags: incategory:"Topic: Tonglen", incategory:"Decade: 1990s", incategory:"Padmakara Translation Group". Combine with words: patience incategory:"Topic: Six Perfections"
- Accents are optional (santideva finds Śāntideva); Tibetan script and Wylie work too.
- A verse number such as 8.120 offers that Bodhicaryāvatāra verse page.
' + link(h.title, esc(title)) + '
' +
(cit ? '' + link(h.title, cit) + '
' : '') +
'' +
(h.snippet ? '…' + h.snippet + '…
' : '') + '' + (href ? '' : '') + esc(String(work).replace(/^(Books|Articles|Dissertations)\//, '')) + (href ? '' : '') + '
' +
'' +
(h.snippet ? '…' + h.snippet + '…
' : '') + '' + link(h.title, esc(name)) + '
' +
(h.snippet ? '…' + h.snippet + '…
' : '') + 'Looking for Bodhicaryāvatāra verse ' + esc(v) + '? ' +
link('Texts/Bodhicaryāvatāra/Verses/' + v, 'Open the verse page') + ' (sources, translations, commentaries) or the ' +
link('Topics/BCA ' + v, 'topic page for BCA ' + v) + ' (works on this verse).
');
}
function writeUrl() {
var u = new URL(location.href);
['q', 'tab', 'class'].forEach(function (k) { u.searchParams.delete(k); });
if (state.q) u.searchParams.set('q', state.q);
if (state.q && state.tab !== 'library') u.searchParams.set('tab', state.tab);
if (state.cls) u.searchParams.set('class', state.cls);
history.replaceState(null, '', u.toString());
}
function loadList(append) {
var my = ++token;
var g = GROUPS.filter(function (x) { return x.id === state.tab; })[0];
if (!append) { state.offset = 0; $('#bcas-list').empty(); }
$('#bcas-more').prop('hidden', true);
$('#bcas-status').text('Searching…');
var key = state.q + '|' + state.cls;
var cached = (g.id === 'library' && state.cls && state.offset === 0 && firstPages[key]);
return (cached ? $.Deferred().resolve(cached).promise() : search(g, g.id === 'library' ? state.cls : '', state.offset, PAGE)).then(function (r) {
if (my !== token) return;
var hits = r.search || [];
if (g.id === 'passages') hits = hits.filter(function (h) { return h.title.indexOf('/') > -1; });
var total = r.searchinfo ? r.searchinfo.totalhits : hits.length;
var titles = hits.map(function (h) { return h.title; });
var p;
if (g.id === 'library') {
// Covers load lazily from Special:Redirect, so the rows do not wait on an
// image lookup (the files live on Commons, which can be slow).
p = ask(titles, '|?Citation|?Class|?Pubdate|?Title|?FrontCoverImg').then(function (data) {
var th = {};
titles.forEach(function (t) { var f = first(((data[t] || {}).printouts) || {}, 'FrontCoverImg'); if (f) th[f] = mw.util.getUrl('Special:Redirect/file/' + f.replace(/^File:/, ''), { width: 120 }); });
return renderLibrary(hits, data, th);
});
} else if (g.id === 'passages') {
p = ask(titles, '|?TranslationWikiPage|?TranslationChapter|?SegmentOrder|?SourceSegmentOrder|?TransMemID|?SourceWikiPage').then(function (data) { return renderPassages(hits, data); });
} else {
p = $.Deferred().resolve(renderPlain(hits)).promise();
}
return p.then(function (html) {
if (my !== token) return;
if (!total) { $('#bcas-list').html('Nothing found in ' + esc(g.label.toLowerCase()) + '. Try another group above, fewer words, or a different spelling.
'); $('#bcas-status').text(''); return; }
$('#bcas-list').append(html);
state.offset += PAGE;
window.setTimeout(refine, 0);
var shown = Math.min(state.offset, total);
$('#bcas-status').text('Showing ' + fmt(shown) + ' of ' + fmt(total) + ' in ' + g.label.toLowerCase() + (state.cls ? ' · ' + state.cls : '') + '.');
$('#bcas-more').prop('hidden', state.offset >= total);
});
}).fail(function () {
if (my !== token) return;
$('#bcas-status').text('The search could not run just now. Please try again in a moment.');
});
}
// Narrow the rows already shown, without a new search (accents ignored).
function fold(s) { return String(s).normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase(); }
function refine() {
var v = fold($('#bcas-filter').val().trim()), shown = 0, all = 0;
$('#bcas-list').children('.topic-biblio-row, .bcas__hit').each(function () {
var ok = !v || fold($(this).text()).indexOf(v) > -1;
$(this).toggle(ok); all++; if (ok) shown++;
});
$('#bcas-filtered').remove();
if (v) $('#bcas-status').append(' ' + fmt(shown) + ' of the ' + fmt(all) + ' shown match the filter.');
}
function run() {
state.q = $('#bcas-q').val().trim();
writeUrl();
shortcut();
if (!state.q) { $('#bcas-tabs,#bcas-pills,#bcas-more,#bcas-refine').prop('hidden', true); $('#bcas-list,#bcas-status').empty(); $('#bcas-hint, #bcas-start').show(); return; }
$('#bcas-hint, #bcas-start').hide();
$('#bcas-refine').prop('hidden', false); $('#bcas-filter').val('');
counts = {};
renderTabs();
// The results come first; the counts follow once they are on screen, so the
// first page is not queued behind eleven count searches (and a class button
// clicked early does not wait behind them either).
var listDone = loadList(false) || $.Deferred().resolve().promise();
listDone.always(function () { $.when.apply($, GROUPS.map(function (g) {
return search(g, '', 0, 1).then(function (r) { counts[g.id] = r.searchinfo.totalhits; }, function () { counts[g.id] = 0; });
})).always(function () {
renderTabs();
if (state.tab === 'library') {
var cc = {};
$.when.apply($, CLASSES.map(function (c) {
return search(GROUPS[0], c, 0, PAGE).then(function (r) { cc[c] = r.searchinfo.totalhits; firstPages[state.q + '|' + c] = r; }, function () {});
})).always(function () { renderPills(cc); });
}
}); });
}
$(function () {
var params = new URL(location.href).searchParams;
state.tab = params.get('tab') || 'library';
state.cls = params.get('class') || '';
$('#bcas-q').val(params.get('q') || '');
$('#bcas-form').on('submit', function (e) { e.preventDefault(); state.cls = ''; run(); });
// Clearing the box (its x, or deleting the text) returns to the browse panels.
$('#bcas-q').on('input search', function () { if (!this.value.trim() && state.q) { state.cls = ''; state.tab = 'library'; run(); } });
$('.bcas__tips').on('click', 'a[data-q]', function () { $('#bcas-q').val($(this).attr('data-q')); state.cls = ''; run(); });
$('#bcas-hint').on('click', 'a[data-q]', function () { $('#bcas-q').val($(this).attr('data-q')); state.cls = ''; run(); });
$('#bcas-tabs').on('click', '.bcas__tab', function () { state.tab = $(this).data('tab'); state.cls = ''; writeUrl(); renderTabs(); $('#bcas-pills').prop('hidden', true); if (state.tab === 'library') run(); else loadList(false); });
$('#bcas-pills').on('click', '.topic-biblio-pill', function () { state.cls = $(this).attr('data-cls') || ''; $('#bcas-pills .topic-biblio-pill').removeClass('is-active'); $(this).addClass('is-active'); writeUrl(); loadList(false); });
$('#bcas-more').on('click', function () { loadList(true); });
$('#bcas-filter').on('input', refine);
// Whole row opens its first link, unless a link inside it was clicked or text selected.
$('#bcas-list').on('click', '.topic-biblio-row, .bcas__hit', function (e) {
if ($(e.target).closest('a').length || String(window.getSelection())) return;
var a = $(this).find('a').get(0); if (!a) return;
if (e.metaKey || e.ctrlKey) window.open(a.href, '_blank'); else location.href = a.href;
});
// The start panel (in the page) can launch searches too.
$(document).on('click', '#bcas-start [data-q]', function (e) { e.preventDefault(); $('#bcas-q').val($(this).attr('data-q')); state.cls = $(this).attr('data-class') || ''; state.tab = $(this).attr('data-tab') || 'library'; run(); window.scrollTo({ top: $('#bcas').offset().top - 90, behavior: 'smooth' }); });
if ($('#bcas-q').val()) run(); else { $('#bcas-start').show(); $('#bcas-q').trigger('focus'); }
});
}]);