PageSourceSearch

https://www.laparola.net/app/js/texts/textprovider-local.js

js laparola.net collected 2026-09-24 08:55:12 UTC 4,220 bytes, 186 lines download raw bytes

1
2sofia.textproviders['local'] = (function() {
3
4	var providerName = 'local',
5		fullName = '',
6		textData = {};
7
8	function getTextManifest(callback) {
9		var textsUrl = 'content/texts/' + sofia.config.textsIndexPath;
10
11		sofia.ajax({
12			url: textsUrl,
13			dataType: 'json',
14			cache: false,
15			success: function(data) {
16
17				var textInfoData = data.textInfoData;
18
19				//text_data = TextLoader.processTexts(textInfoData, providerName);
20
21				callback(textInfoData);
22			},
23			error: function(jqXHR, textStatus, errorThrown) {
24				//console.log('error loading texts.json', jqXHR, textStatus, errorThrown);
25				//console.log(textStatus);
26
27				var modal = new MovableWindow(600,250, 'Texts Error');
28				//modal.size(500, 200).center();
29
30				modal.body.css({background: '#000', color: '#fff' }).html(
31					'<div style="padding: 20px;">' +
32						'<p>Problem loading <code>' + sofia.config.baseContentUrl + textsUrl + '</code></p>' +
33						'<p>Status: ' + textStatus + '</p>'+
34						'<p>Error: ' + errorThrown + '</p>'+
35					'</div>'
36				);
37				modal.show().center();
38
39			}
40		});
41	}
42
43	function getTextInfo(textid, callback, errorCallback) {
44
45		if (typeof textData[textid] != 'undefined') {
46			callback(textData[textid]);
47			return;
48		}
49
50		// load it!
51		var infoUrl = 'content/texts/' + textid + '/info.json';
52
53		sofia.ajax({
54			url: infoUrl,
55			dataType: 'json',
56			success: function(data) {
57				textData[textid] = data;
58				callback(data);
59			},
60			error: function(error) {
61
62				console.log("ERROR TextInfoLoader.getText", infoUrl);
63
64				if (errorCallback) {
65					errorCallback(error);
66				}
67			}
68		});
69	}
70
71	function loadSection(textid, sectionid, callback, errorCallback) {
72
73		getTextInfo(textid, function(textInfo) {
74
75			var url = 'content/texts/' + textid + '/' + sectionid + '.html';
76
77			sofia.ajax({
78				dataType: 'text',
79				url: url,
80				success: function(data) {
81
82					// text to treat this like JSON or text/html
83					var text = data,
84						// split at the closing head tag to prevent problems with loading head material
85						main = $( text.indexOf('</head>') > -1 ? text.split('</head>')[1] : text ),
86						content = main.filter('.section'),
87						footnotes = main.filter('.footnotes'),
88						notes = footnotes.find('.footnote');
89
90					// move notes into place
91					if (notes.length > 0) {
92						notes.each(function() {
93							var footnote = $(this),
94								noteid = footnote.find('a').attr('href'),
95								footnotetext = footnote.find('.text'),
96								noteintext = content.find(noteid);
97
98							//console.log(noteid, noteintext);
99
100							noteintext.append(footnotetext);
101
102						});
103					}
104
105					content.attr('data-textid', textid);
106					content.attr('data-lang3', textInfo.lang);
107
108					// FIX title after chapter number
109					var c = content.find('.c'),
110						afterc = c.next();
111					if (afterc.hasClass('s')) {
112						c.before(afterc);
113					}
114
115					// FIX verse numbers inside verse
116					content.find('.v-num').each(function() {
117						var vnum = $(this),
118							v = vnum.closest('.v');
119
120						if (v.length > 0) {
121							v.before(vnum);
122						}
123
124					});
125
126					var html = content.wrapAll('<div></div>').parent().html();
127
128					callback(html);
129
130				}, error: function(jqXHR, textStatus, errorThrown) {
131					if (errorCallback) {
132						errorCallback(textid, sectionid);
133					}
134
135					//console.log('error', textStatus, errorThrown, jqXHR );
136				}
137			});
138		});
139
140	}
141
142	function startSearch(textid, divisions, text, onSearchLoad, onSearchIndexComplete, onSearchComplete) {
143
144		var textSearch = new TextSearch();
145
146		textSearch.on('load', onSearchLoad);
147		textSearch.on('indexcomplete', onSearchIndexComplete);
148		textSearch.on('complete', onSearchComplete);
149
150		textSearch.start(textid, divisions, text);
151
152	}
153
154	return {
155		getTextManifest: getTextManifest,
156		getTextInfo: getTextInfo,
157		loadSection: loadSection,
158		startSearch: startSearch,
159		fullName: fullName
160	}
161
162})();
163
164/*
165sofia.textproviders['example'] = (function() {
166
167	function getTextManifest (callback) {
168		callback({});
169	}
170
171	function getTextInfo(textid, callback) {
172		callback({});
173	}
174
175	function loadSection(textid, sectionid, callback) {
176		callback(null);
177	}
178
179	return {
180		getTextManifest: getTextManifest,
181		getTextInfo: getTextInfo,
182		loadSection: loadSection
183	}
184
185})();
186*/

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.