PageSourceSearch

https://bohr.io/_old/index.js?0.290163867458764

js bohr.io collected 2026-09-24 19:42:59 UTC 7,352 bytes, 238 lines download raw bytes

1(function () {
2	//const bohr = {
3	window.bohr = {
4		isInIframe: (parent != window),
5		bohrURL: _BOHR_ENV_URL || 'https://bohr.io',
6		previousOverflow: '',
7		previousScrollBehaviorHtml: '',
8		previousScrollBehaviorBody: '',
9		isNiceScrollEnabled: false,
10		isNiceScrollInitialEnabled: false,
11		isNiceScrollLoaded: false,
12		isCkeditorLoaded: false,
13		isCkeditorIniating: false,
14		isSaving: false,
15		isEditEnabled: false,
16		isEditInitialEnabled: false,
17		isPluginsLoaded: false,
18		init: function () {
19			bohr.bindMessage();
20			if (bohr.isInIframe) {
21				bohr.postMessage('bohrInit');
22			}
23		},
24		bindMessage: function () {
25			window.addEventListener('message', function (e) {
26				const commandName = e.data;
27				const availableCommands = ['start', 'enableMobileScroll', 'disableMobileScrol', 'enableEdit', 'disableEdit', 'saveContent', 'showMessageSuccess', 'showMessageError'];
28				const isValidCommand = availableCommands.includes(commandName);
29				if (isValidCommand) bohr[commandName]();
30			});
31		},
32		postMessage: function (message) {
33			try {
34				parent.postMessage(message, 'http://localhost');
35			} catch (error) {
36			}
37			try {
38				parent.postMessage(message, 'https://localhost:444');
39			} catch (error) {
40			}
41			try {
42				parent.postMessage(message, 'https://bohr.rocks');
43			} catch (error) {
44			}
45			try {
46				parent.postMessage(message, 'https://cl2hz21040083qsvdzokaxsko.bohr.live');
47			} catch (error) {
48			}
49			try {
50				parent.postMessage(message, 'https://bohr.io');
51			} catch (error) {
52			}
53		},
54		start: function () {
55			bohr.loadPlugins();
56		},
57		loadPlugins: function () {
58			if (bohr.isPluginsLoaded) return;
59			bohr.isPluginsLoaded = true;
60			if (_BOHR_DEV_MODE) bohr.bohrURL = 'http://localhost';
61			if (window.location.hostname  == 'bohr.rocks') bohr.bohrURL = 'https://bohr.rocks';
62			let cssURL = bohr.bohrURL + '/_old/index.css';
63			let jqueryURL = bohr.bohrURL + '/_old/js/jquery-3.6.0.min.js';
64			let nicescrollURL = bohr.bohrURL + '/_old/js/jquery.nicescroll.min.js';
65			let ckeditorURL = bohr.bohrURL + '/_old/js/ckeditor/ckeditor.js';
66			bohr.loadCSS(cssURL);
67			bohr.loadScript(jqueryURL, function () {
68				bohr.$ = jqb;
69				bohr.loadScript(nicescrollURL, function () {
70					bohr.isNiceScrollLoaded = true;
71					if (bohr.isNiceScrollInitialEnabled) bohr.enableMobileScroll();
72				});
73				bohr.loadScript(ckeditorURL, function () {
74					bohr.isCkeditorLoaded = true;
75					if (bohr.isEditInitialEnabled) bohr.enableEdit();
76				});
77				bohr.checkForEditors();
78				window.addEventListener('pointermove', bohr.postCursorPosition);
79				window.addEventListener('keydown', bohr.postEscPress);
80			});
81		},
82		enableMobileScroll: function () {
83			if (!bohr.isNiceScrollLoaded) {
84				bohr.isNiceScrollInitialEnabled = true;
85				return;
86			}
87			if (bohr.isNiceScrollEnabled) return;
88			bohr.isNiceScrollEnabled = true;
89			bohr.previousOverflow = jqb('html').css('overflow-y');
90			bohr.previousScrollBehaviorHtml = jqb('html').css('scroll-behavior');
91			bohr.previousScrollBehaviorBody = jqb('body').css('scroll-behavior');
92			if (jqb('body').css('overflow-y').toLowerCase().indexOf('hidden') == -1) {
93				jqb('html').css('scroll-behavior', 'auto');
94				jqb('body').css('scroll-behavior', 'auto');
95				jqb('html').niceScroll({ cursorcolor: "rgba(0,0,0,0.5)", cursorborder: 'none', railpadding: { top: 1, right: 1, left: 1, bottom: 1 }, spacebarenabled: false });
96			}
97		},
98		disableMobileScrol: function () {
99			if (!bohr.isNiceScrollLoaded) {
100				bohr.isNiceScrollInitialEnabled = false;
101				return;
102			}
103			if (!bohr.isNiceScrollEnabled) return;
104			bohr.isNiceScrollEnabled = false;
105			jqb('html').getNiceScroll().remove();
106			jqb('html').css('overflow-y', bohr.previousOverflow);
107			jqb('html').css('scroll-behavior', bohr.previousScrollBehaviorHtml);
108			jqb('body').css('scroll-behavior', bohr.previousScrollBehaviorBody);
109		},
110		enableEdit: function () {
111			if (!bohr.isCkeditorLoaded) {
112				bohr.isEditInitialEnabled = true;
113				return;
114			}
115			if (bohr.isEditEnabled) return;
116			bohr.isEditEnabled = true;
117			const $editors = bohr.$('[data-bohr-cms]');
118			bohr.isCkeditorIniating = true;
119			let CKEditor_Count = $editors.length;
120			$editors.each(function () {
121				bohr.$(this).attr('contenteditable', true);
122				CKEDITOR.inline(this).on('instanceReady', function () {
123					CKEditor_Count--;
124					if (CKEditor_Count == 0) {
125						bohr.isCkeditorIniating = false;
126					}
127				});
128			});
129		},
130		disableEdit: function () {
131			try {
132				if (!bohr.isCkeditorLoaded) {
133					bohr.isEditInitialEnabled = false;
134					return;
135				}
136				if (!bohr.isEditEnabled) return;
137				bohr.isEditEnabled = false;
138				for (let i in CKEDITOR.instances) {
139					CKEDITOR.instances[i].destroy();
140				}
141				bohr.$('[data-bohr-cms]').each(function () {
142					bohr.$(this).attr('contenteditable', false);
143				});
144			} catch (e) {
145				console.log(e);
146			}
147		},
148		saveContent: function (cb) {
149			try {
150				if (!bohr.isEditEnabled) return false;
151				if (bohr.isCkeditorIniating) return false;
152				if (bohr.isSaving) return false;
153				bohr.isSaving = true;
154				let dados = [];
155				for (let i in CKEDITOR.instances) {
156					dados.push({
157						file: CKEDITOR.instances[i].container.data('bohr-file'),
158						index: CKEDITOR.instances[i].container.data('bohr-index'),
159						dist_file: CKEDITOR.instances[i].container.data('bohr-dist-file'),
160						dist_index: CKEDITOR.instances[i].container.data('bohr-dist-index'),
161						content: CKEDITOR.instances[i].getData()
162					});
163				}
164				bohr.$.ajax({
165					url: bohr.bohrURL + '/api/cms/save',
166					type: 'POST',
167					xhrFields: { withCredentials: true },
168					data: { 
169						REPO_OWNER: _BOHR_REPO_OWNER,
170						REPO_NAME: _BOHR_REPO_NAME,
171						REF_NAME: _BOHR_REF_NAME,
172						DATA: JSON.stringify(dados)
173					},
174					dataType: 'JSON',
175					complete: function (data, status) { 
176            bohr.isSaving = false; 
177            if(data.status === 200){
178              bohr.postMessage({ type:'showMessageSuccess' });
179            } else if(data.status === 401) {
180              bohr.postMessage({ type:'showPermissionMessageError' });
181            } else {
182              bohr.postMessage({ type:'showMessageError' });
183            }
184          }
185				}).done(function (r) {
186					console.log(r);
187					cb();
188				});
189				bohr.disableEdit();
190			} catch (e) {
191				console.log(e);
192			}
193		},
194		onDocumentLoaded: function (fn) {
195			if (document.readyState != 'loading') {
196				fn();
197			} else {
198				document.addEventListener('DOMContentLoaded', fn);
199			}
200		},
201		loadScript: function (url, cb) {
202			var script = document.createElement('script');
203			script.onload = function () {
204				cb && cb();
205			};
206			script.src = url;
207			document.head.appendChild(script);
208		},
209		loadCSS: function (url) {
210			var link = document.createElement('link');
211			link.rel = 'stylesheet';
212			link.type = 'text/css';
213			link.href = url;
214			link.media = 'all';
215			document.head.appendChild(link);
216		},
217		postCursorPosition(e) {
218			const { pageX, pageY } = e;
219	
220			bohr.postMessage({
221				type: 'cursorPosition',
222				position: {
223					view: 'deployPreview',
224					x: pageX,
225					y: pageY,
226				}
227			});
228		},
229		checkForEditors() {
230			const $editors = bohr.$('[data-bohr-cms]');
231			if ($editors.length > 0) bohr.postMessage({ type: 'enableEdit' });
232		},
233		postEscPress(e) {
234			if (e.key === 'Escape') bohr.postMessage({ type: 'escPress' });
235		}
236	};
237	bohr.init();
238})();

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.