| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | <!DOCTYPE html> | 
					
						
							|  |  |  | <html> | 
					
						
							|  |  |  | <!--html manifest="pwiki.appcache"--> | 
					
						
							|  |  |  | <head> | 
					
						
							|  |  |  | <title>pWiki</title> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <meta charset="utf-8"> | 
					
						
							|  |  |  | <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <link rel="manifest" href="manifest.json"> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-Bold.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-BoldItalic.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-ExtraBold.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-ExtraBoldItalic.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-Italic.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-Light.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-LightItalic.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-Regular.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-Semibold.ttf"> | 
					
						
							|  |  |  | <link rel="prefetch" href="css/fonts/Open_Sans/OpenSans-SemiboldItalic.ttf"> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <link rel="stylesheet" href="css/fonts.css"> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-05 20:44:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-06 22:48:09 +03:00
										 |  |  | <!-- NativeMarkdown --> | 
					
						
							|  |  |  | <script src="ext-lib/showdown.min.js"></script> | 
					
						
							|  |  |  | <script> | 
					
						
							|  |  |  | var MarkdownPage = { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | </script> | 
					
						
							|  |  |  | <!-- NativeMarkdown --> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-05 20:44:25 +03:00
										 |  |  | <!-- MediumEditor --> | 
					
						
							|  |  |  | <!--link rel="stylesheet" href="experiments/medium-editor/css/medium-editor.css">
 | 
					
						
							|  |  |  | <link rel="stylesheet" href="experiments/medium-editor/css/themes/default.css"> | 
					
						
							|  |  |  | <script src="ext-lib/showdown.min.js"></script> | 
					
						
							|  |  |  | <script src="experiments/medium-editor/js/medium-editor.js"></script> | 
					
						
							|  |  |  | <script src="experiments/medium-editor/js/me-markdown.standalone.js"></script> | 
					
						
							|  |  |  | <script> | 
					
						
							|  |  |  | var setupMediumEditor = async function () { | 
					
						
							|  |  |  | 	var editorelem = document.querySelector('.medium-editor') | 
					
						
							|  |  |  | 	if(editorelem){ | 
					
						
							|  |  |  | 		console.log('MediumEditor: setup...') | 
					
						
							|  |  |  | 		var page = pwiki.get('..') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// load the initial state... | 
					
						
							|  |  |  | 		var converter = new showdown.Converter() | 
					
						
							|  |  |  | 		editorelem.innerHTML = converter.makeHtml(await page.raw) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		var elem = document.querySelector('.medium-markdown') | 
					
						
							|  |  |  | 		editor = new MediumEditor(editorelem, { | 
					
						
							|  |  |  | 			extensions: { | 
					
						
							|  |  |  | 				markdown: new MeMarkdown(function(code) { | 
					
						
							| 
									
										
										
										
											2022-10-06 22:48:09 +03:00
										 |  |  | 					saveLiveContent(page.path, code) | 
					
						
							| 
									
										
										
										
											2022-10-05 20:44:25 +03:00
										 |  |  | 					// XXX DEBUG... | 
					
						
							|  |  |  | 					elem  | 
					
						
							|  |  |  | 						&& (elem.textContent = code) }) } }) } } | 
					
						
							|  |  |  | </script--> | 
					
						
							|  |  |  | <!-- MediumEditor --> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <!-- ToastUIEditor --> | 
					
						
							|  |  |  | <!-- ToastUIEditor --> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | </head> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <style> | 
					
						
							| 
									
										
										
										
											2022-08-21 23:07:47 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-03 10:57:54 +03:00
										 |  |  | body { | 
					
						
							|  |  |  | 	font-size: 1.1em; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-03 02:35:14 +03:00
										 |  |  | h1:empty { | 
					
						
							|  |  |  | 	display: none; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-03 10:57:54 +03:00
										 |  |  | a { | 
					
						
							|  |  |  | 	text-decoration: none; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | a:hover { | 
					
						
							|  |  |  | 	text-decoration: underline; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-21 23:07:47 +03:00
										 |  |  | .show-on-hover { | 
					
						
							|  |  |  | 	opacity: 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | :hover>.show-on-hover { | 
					
						
							|  |  |  | 	opacity: 0.4; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | .show-on-hover:hover { | 
					
						
							|  |  |  | 	opacity: 0.8; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-02 21:15:22 +03:00
										 |  |  | /* Spinner... */ | 
					
						
							|  |  |  | .spinner { | 
					
						
							| 
									
										
										
										
											2022-10-31 02:29:21 +03:00
										 |  |  | 	position: fixed; | 
					
						
							| 
									
										
										
										
											2022-09-02 21:15:22 +03:00
										 |  |  | 	display: flex; | 
					
						
							|  |  |  | 	text-align: center; | 
					
						
							|  |  |  | 	left: 50%; | 
					
						
							|  |  |  | 	top: 50%; | 
					
						
							|  |  |  | 	width: 100px; | 
					
						
							|  |  |  | 	height: 100px; | 
					
						
							|  |  |  | 	margin-top: -50px; | 
					
						
							|  |  |  | 	margin-left: -50px; | 
					
						
							|  |  |  | 	white-space: nowrap; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-10 04:11:00 +03:00
										 |  |  | 	background: transparent; | 
					
						
							|  |  |  | 	pointer-events: none; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-02 21:15:22 +03:00
										 |  |  | 	animation: fadein 2s 1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | .spinner span { | 
					
						
							|  |  |  | 	position: relative; | 
					
						
							|  |  |  | 	display: inline-block; | 
					
						
							|  |  |  | 	font-size: 2em; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	animation: loading 2s infinite ; | 
					
						
							|  |  |  | 	animation-delay: calc(0.2s * var(--i)); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-09-10 04:11:00 +03:00
										 |  |  | body:not(.loading) .page.spinner { | 
					
						
							|  |  |  | 	display: none; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | body.loading .page.spinner { | 
					
						
							|  |  |  | 	opacity: 0.9; | 
					
						
							|  |  |  | 	animation: fadein 1s 1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | body.loading .page.spinner span { | 
					
						
							| 
									
										
										
										
											2022-09-10 04:25:59 +03:00
										 |  |  | 	font-size: 4em; | 
					
						
							|  |  |  | 	animation: loading 2s infinite ; | 
					
						
							| 
									
										
										
										
											2022-09-10 04:11:00 +03:00
										 |  |  | 	animation-delay: calc(0.2s * var(--i)); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-09-02 21:15:22 +03:00
										 |  |  | @keyframes fadein { | 
					
						
							|  |  |  | 	from { | 
					
						
							|  |  |  | 		opacity: 0; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	50% { | 
					
						
							|  |  |  | 		opacity: 0.8; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	to { | 
					
						
							|  |  |  | 		opacity: 1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | @keyframes loading { | 
					
						
							|  |  |  | 	0%, 60% { | 
					
						
							|  |  |  | 		transform: rotateY(360deg); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-19 04:26:13 +03:00
										 |  |  | .error .msg { | 
					
						
							|  |  |  | 	font-weight: bold; | 
					
						
							|  |  |  | 	color: red; | 
					
						
							|  |  |  | 	margin-bottom: 1em; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | .error { | 
					
						
							|  |  |  | 	background: lightyellow; | 
					
						
							|  |  |  | 	padding: 1em; | 
					
						
							| 
									
										
										
										
											2022-11-20 02:14:50 +03:00
										 |  |  | 	box-shadow: inset 3px 5px 15px 5px rgba(0,0,0,0.03); | 
					
						
							| 
									
										
										
										
											2022-11-19 04:26:13 +03:00
										 |  |  | 	border: dashed red 1px; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-31 04:24:12 +03:00
										 |  |  | textarea { | 
					
						
							|  |  |  | 	font-size: 1.2em; | 
					
						
							|  |  |  | 	border: none; | 
					
						
							|  |  |  | 	resize: none; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-09-25 19:22:32 +03:00
										 |  |  | [contenteditable] { | 
					
						
							| 
									
										
										
										
											2022-10-31 04:24:12 +03:00
										 |  |  | 	outline: 0px solid transparent; | 
					
						
							| 
									
										
										
										
											2022-09-25 19:22:32 +03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-10-31 04:24:12 +03:00
										 |  |  | textarea:empty:after, | 
					
						
							| 
									
										
										
										
											2022-09-25 19:22:32 +03:00
										 |  |  | [contenteditable]:empty:after { | 
					
						
							|  |  |  | 	display: block; | 
					
						
							|  |  |  | 	content: 'Empty'; | 
					
						
							|  |  |  | 	opacity: 0.3; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-02 21:15:22 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-10 18:44:00 +03:00
										 |  |  | .tree-page-title:empty:after { | 
					
						
							|  |  |  | 	content: "/"; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | </style> | 
					
						
							| 
									
										
										
										
											2022-10-28 01:34:58 +03:00
										 |  |  | <!-- 
 | 
					
						
							|  |  |  | Do not edit here... | 
					
						
							|  |  |  | This is loaded with the style defined by the system  | 
					
						
							|  |  |  | --> | 
					
						
							|  |  |  | <style id="style"></style> | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | <!-- XXX do we need this??? --> | 
					
						
							|  |  |  | <script src="bootstrap.js"></script> | 
					
						
							| 
									
										
										
										
											2022-08-04 14:29:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | <!--script data-main="pwiki2" src="ext-lib/require.js"></script--> | 
					
						
							|  |  |  | <script src="ext-lib/require.js"></script> | 
					
						
							|  |  |  | <script> | 
					
						
							| 
									
										
										
										
											2022-09-17 19:39:39 +03:00
										 |  |  | //--------------------------------------------------------------------- | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-02 21:15:22 +03:00
										 |  |  | var DEBUG = true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-17 19:39:39 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | //--------------------------------------------------------------------- | 
					
						
							|  |  |  | // Module loading... | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | var makeFallbacks =  | 
					
						
							|  |  |  | function(paths, search=['lib']){ | 
					
						
							|  |  |  | 	return Object.entries(paths) | 
					
						
							|  |  |  | 		.map(function([key, path]){ | 
					
						
							|  |  |  | 			// package... | 
					
						
							|  |  |  | 			if(path.endsWith('/')){ | 
					
						
							|  |  |  | 				return [key, path] } | 
					
						
							|  |  |  | 			return [ | 
					
						
							|  |  |  | 				key, | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					path, | 
					
						
							|  |  |  | 					...search | 
					
						
							|  |  |  | 						.map(function(base){ | 
					
						
							|  |  |  | 							return base +'/'+ path.split(/[\\\/]+/g).pop() }), | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 			] }) | 
					
						
							|  |  |  | 		.reduce(function(res, [key, value]){ | 
					
						
							|  |  |  | 			res[key] = value | 
					
						
							|  |  |  | 			return res }, {}) } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-17 19:39:39 +03:00
										 |  |  | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | require.config({ | 
					
						
							|  |  |  | 	paths: { | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | 		...makeFallbacks({ | 
					
						
							|  |  |  | 			'ig-doc': 'node_modules/ig-doc/doc', | 
					
						
							|  |  |  | 			'ig-stoppable': 'node_modules/ig-stoppable/stoppable', | 
					
						
							|  |  |  | 			'object-run': 'node_modules/object-run/run', | 
					
						
							|  |  |  | 			'ig-object': 'node_modules/ig-object/object', | 
					
						
							|  |  |  | 		}), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// packages... | 
					
						
							|  |  |  | 		'ig-types': [ | 
					
						
							|  |  |  | 			'node_modules/ig-types', | 
					
						
							|  |  |  | 			'lib/types', | 
					
						
							|  |  |  | 		], | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | 		// external stuff... | 
					
						
							|  |  |  | 		...makeFallbacks({ | 
					
						
							|  |  |  | 			'jszip': 'node_modules/jszip/dist/jszip', | 
					
						
							|  |  |  | 			'pouchdb': 'node_modules/pouchdb/dist/pouchdb', | 
					
						
							|  |  |  | 			'showdown': 'node_modules/showdown/dist/showdown', | 
					
						
							| 
									
										
										
										
											2022-10-10 01:10:32 +03:00
										 |  |  | 			'idb-keyval': 'node_modules/idb-keyval/dist/umd', | 
					
						
							| 
									
										
										
										
											2022-11-03 23:48:53 +03:00
										 |  |  | 			'flexsearch': 'node_modules/flexsearch/dist/flexsearch.bundle', | 
					
						
							| 
									
										
										
										
											2022-11-26 13:22:10 +03:00
										 |  |  | 			'any-date-parser': 'node_modules/any-date-parser/dist/browser-bundle', | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | 		}, ['ext-lib']), | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 	packages: [ | 
					
						
							|  |  |  | 		'ig-types', | 
					
						
							|  |  |  | 	] | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-06 11:09:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-17 19:39:39 +03:00
										 |  |  | //--------------------------------------------------------------------- | 
					
						
							|  |  |  | // Editor -- save changes... | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-28 01:44:04 +03:00
										 |  |  | /* XXX GLOBAL_STYLE | 
					
						
							| 
									
										
										
										
											2022-10-28 01:34:58 +03:00
										 |  |  | // XXX might be a good idea to make this a method of pwiki??? | 
					
						
							|  |  |  | var STYLE_UPDATED = false | 
					
						
							|  |  |  | var updateStyle = async function(){ | 
					
						
							|  |  |  | 	document.querySelector('#style').innerHTML =  | 
					
						
							| 
									
										
										
										
											2022-10-29 01:40:27 +03:00
										 |  |  | 		await pwiki.get('/.config/Style/_text').text } | 
					
						
							| 
									
										
										
										
											2022-10-28 01:44:04 +03:00
										 |  |  | //*/ | 
					
						
							| 
									
										
										
										
											2022-10-28 01:34:58 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | // XXX might be a good idea to make this a method of pwiki??? | 
					
						
							|  |  |  | var CONFIG_UPDATED = false | 
					
						
							|  |  |  | var updateConfig = async function(){ | 
					
						
							|  |  |  | 	// XXX need to set this to something... | 
					
						
							|  |  |  | 	// XXX | 
					
						
							|  |  |  | 	// XXX need to use a parser that supports comments and stuff... | 
					
						
							| 
									
										
										
										
											2022-10-29 01:40:27 +03:00
										 |  |  | 	return JSON.parse(await pwiki.get('/.config/Config/_text').text) } | 
					
						
							| 
									
										
										
										
											2022-10-28 01:34:58 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-17 19:39:39 +03:00
										 |  |  | // XXX versioning?? | 
					
						
							| 
									
										
										
										
											2022-09-19 00:18:23 +03:00
										 |  |  | var SAVE_LIVE_TIMEOUT = 5000 | 
					
						
							|  |  |  | var SAVE_LIVE_QUEUE = {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var saveLiveContent =  | 
					
						
							|  |  |  | function(path, text){ | 
					
						
							|  |  |  | 	SAVE_LIVE_QUEUE[path] = text  | 
					
						
							|  |  |  | 	// clear editor page cache... | 
					
						
							|  |  |  | 	pwiki.cache = null } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-17 19:39:39 +03:00
										 |  |  | var SAVE_QUEUE = {} | 
					
						
							| 
									
										
										
										
											2022-09-19 00:18:23 +03:00
										 |  |  | var saveContent = | 
					
						
							|  |  |  | function(path, text){ | 
					
						
							| 
									
										
										
										
											2022-09-25 19:22:32 +03:00
										 |  |  | 	SAVE_QUEUE[path] = text } | 
					
						
							| 
									
										
										
										
											2022-09-19 00:18:23 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | var saveAll = | 
					
						
							|  |  |  | function(){ | 
					
						
							|  |  |  | 	saveNow() | 
					
						
							|  |  |  | 	var queue = Object.entries(SAVE_QUEUE) | 
					
						
							|  |  |  | 	SAVE_QUEUE = {} | 
					
						
							|  |  |  | 	queue | 
					
						
							|  |  |  | 		.forEach(function([path, text]){ | 
					
						
							|  |  |  | 			console.log('saving changes to:', path) | 
					
						
							|  |  |  | 			pwiki.get(path).raw = text }) } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-17 19:39:39 +03:00
										 |  |  | var saveNow =  | 
					
						
							| 
									
										
										
										
											2022-09-19 00:18:23 +03:00
										 |  |  | function(){ | 
					
						
							|  |  |  | 	var queue = Object.entries(SAVE_LIVE_QUEUE) | 
					
						
							|  |  |  | 	SAVE_LIVE_QUEUE = {} | 
					
						
							|  |  |  | 	NEW_TITLE = undefined | 
					
						
							|  |  |  | 	queue | 
					
						
							|  |  |  | 		.forEach(function([path, text]){ | 
					
						
							|  |  |  | 			console.log('saving changes to:', path) | 
					
						
							|  |  |  | 			pwiki.get(path).raw = text }) } | 
					
						
							|  |  |  | setInterval(saveNow, SAVE_LIVE_TIMEOUT) | 
					
						
							| 
									
										
										
										
											2022-09-17 19:39:39 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //--------------------------------------------------------------------- | 
					
						
							|  |  |  | // Spinner/loading... | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // loading spinner... | 
					
						
							|  |  |  | window.startSpinner = function(){ | 
					
						
							|  |  |  | 	document.body.classList.add('loading') } | 
					
						
							|  |  |  | window.stopSpinner = function(){ | 
					
						
							|  |  |  | 	document.body.classList.remove('loading') } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //--------------------------------------------------------------------- | 
					
						
							|  |  |  | // General setup... | 
					
						
							| 
									
										
										
										
											2022-08-06 11:09:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-17 19:39:39 +03:00
										 |  |  | document.pwikiloaded = new Event('pwikiloaded') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-17 12:05:00 +03:00
										 |  |  | var logTime = async function(promise, msg=''){ | 
					
						
							|  |  |  | 	var t = Date.now() | 
					
						
							|  |  |  | 	var res = await promise | 
					
						
							|  |  |  | 	t = Date.now() - t | 
					
						
							|  |  |  | 	DEBUG  | 
					
						
							|  |  |  | 		&& console.log(`## ${ | 
					
						
							|  |  |  | 				typeof(msg) == 'function' ?  | 
					
						
							|  |  |  | 					msg(res)  | 
					
						
							|  |  |  | 					: msg | 
					
						
							|  |  |  | 			} (${t}ms)`) | 
					
						
							|  |  |  | 	return res } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-17 19:39:39 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-19 00:18:23 +03:00
										 |  |  | REFRESH_DELAY = 20 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var refresh = async function(){ | 
					
						
							|  |  |  | 	startSpinner() | 
					
						
							|  |  |  | 	setTimeout(function(){ | 
					
						
							|  |  |  | 		logTime( | 
					
						
							|  |  |  | 			pwiki.refresh(),  | 
					
						
							|  |  |  | 			pwiki.location) }, REFRESH_DELAY) } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-17 19:39:39 +03:00
										 |  |  | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | // start loading pWiki... | 
					
						
							| 
									
										
										
										
											2022-08-16 11:00:23 +03:00
										 |  |  | require(['./browser'], function(browser){  | 
					
						
							| 
									
										
										
										
											2022-09-17 19:39:39 +03:00
										 |  |  | 	var pwiki = window.pwiki = browser.pwiki  | 
					
						
							| 
									
										
										
										
											2022-08-06 11:09:25 +03:00
										 |  |  | 	pwiki.dom = document.querySelector('#pWiki') | 
					
						
							| 
									
										
										
										
											2022-08-16 11:00:23 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-10 11:42:31 +03:00
										 |  |  | 	// handle location.hash/history (both directions) | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | 	window.addEventListener('hashchange', function(evt){ | 
					
						
							|  |  |  | 		evt.preventDefault() | 
					
						
							| 
									
										
										
										
											2022-08-31 18:49:59 +03:00
										 |  |  | 		var [path, hash] = decodeURI(location.hash).slice(1).split('#') | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | 		path = path.trim() == '' ?  | 
					
						
							| 
									
										
										
										
											2022-08-31 15:46:51 +03:00
										 |  |  | 			pwiki.location | 
					
						
							| 
									
										
										
										
											2022-08-10 15:29:45 +03:00
										 |  |  | 			//'/' | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | 			: path | 
					
						
							| 
									
										
										
										
											2022-08-11 10:39:55 +03:00
										 |  |  | 		// treat links as absolute unless explicitly relative... | 
					
						
							| 
									
										
										
										
											2022-08-10 15:29:45 +03:00
										 |  |  | 		path = /^\.\.?([\\\/].*)?$/.test(path) ? | 
					
						
							|  |  |  | 			path | 
					
						
							|  |  |  | 			: '/'+path | 
					
						
							| 
									
										
										
										
											2022-09-10 04:11:00 +03:00
										 |  |  | 		startSpinner() | 
					
						
							|  |  |  | 		// NOTE: setTimeout(..) to allow the spinner to start... | 
					
						
							| 
									
										
										
										
											2022-09-14 09:57:32 +03:00
										 |  |  | 		// NOTE: this seems not to work if the REFRESH_DELAY is too small... | 
					
						
							| 
									
										
										
										
											2022-09-10 04:11:00 +03:00
										 |  |  | 		setTimeout(function(){ | 
					
						
							| 
									
										
										
										
											2022-09-14 09:57:32 +03:00
										 |  |  | 			pwiki.location = [path, hash] }, REFRESH_DELAY) }) | 
					
						
							| 
									
										
										
										
											2022-11-21 03:04:48 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// scroll... | 
					
						
							|  |  |  | 	// NOTE: we restore scroll position only on history navigation... | 
					
						
							| 
									
										
										
										
											2022-11-22 02:26:28 +03:00
										 |  |  | 	var save_scroll = async function(){  | 
					
						
							|  |  |  | 		history.replaceState({  | 
					
						
							|  |  |  | 			path: pwiki.location, | 
					
						
							|  |  |  | 			// XXX HACK this will work only on full page... | 
					
						
							|  |  |  | 			scroll: document.scrollingElement.scrollTop, | 
					
						
							|  |  |  | 		}, '', window.location.hash) } | 
					
						
							| 
									
										
										
										
											2022-11-21 03:04:48 +03:00
										 |  |  | 	// save scroll position just after scroll is done... | 
					
						
							| 
									
										
										
										
											2022-11-22 02:26:28 +03:00
										 |  |  | 	var _scrolling | 
					
						
							| 
									
										
										
										
											2022-11-21 03:04:48 +03:00
										 |  |  | 	window.addEventListener('scroll', function(evt){ | 
					
						
							| 
									
										
										
										
											2022-11-22 02:26:28 +03:00
										 |  |  | 		_scrolling | 
					
						
							|  |  |  | 			&& clearTimeout(_scrolling) | 
					
						
							|  |  |  | 		_scrolling = setTimeout(save_scroll, 200) }) | 
					
						
							| 
									
										
										
										
											2022-11-21 03:04:48 +03:00
										 |  |  | 	// get scroll position from history state... | 
					
						
							|  |  |  | 	window.addEventListener('popstate', function(evt){ | 
					
						
							|  |  |  | 		pwiki.__scroll = (evt.state ?? {}).scroll }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-10 11:42:31 +03:00
										 |  |  | 	pwiki | 
					
						
							| 
									
										
										
										
											2022-09-03 10:57:54 +03:00
										 |  |  | 		.onBeforeNavigate(function(){ | 
					
						
							| 
									
										
										
										
											2022-09-19 00:18:23 +03:00
										 |  |  | 			saveAll() }) | 
					
						
							| 
									
										
										
										
											2022-10-28 14:10:31 +03:00
										 |  |  | 		.navigate(async function(){ | 
					
						
							| 
									
										
										
										
											2022-08-10 11:42:31 +03:00
										 |  |  | 			// NOTE: we do not need to directly update location.hash here as | 
					
						
							|  |  |  | 			//		that will push an extra history item... | 
					
						
							| 
									
										
										
										
											2022-08-10 15:29:45 +03:00
										 |  |  | 			history.replaceState( | 
					
						
							| 
									
										
										
										
											2022-11-21 03:04:48 +03:00
										 |  |  | 				{ path: this.location },  | 
					
						
							| 
									
										
										
										
											2022-09-04 01:53:01 +03:00
										 |  |  | 				'', | 
					
						
							| 
									
										
										
										
											2022-08-31 15:46:51 +03:00
										 |  |  | 				'#'+this.location  | 
					
						
							| 
									
										
										
										
											2022-08-10 15:29:45 +03:00
										 |  |  | 					+(this.hash ?  | 
					
						
							|  |  |  | 						'#'+this.hash  | 
					
						
							|  |  |  | 						: '')) | 
					
						
							| 
									
										
										
										
											2022-10-28 01:44:04 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			/* XXX GLOBAL_STYLE | 
					
						
							| 
									
										
										
										
											2022-10-28 01:34:58 +03:00
										 |  |  | 			// style... | 
					
						
							|  |  |  | 			if(STYLE_UPDATED){ | 
					
						
							|  |  |  | 				STYLE_UPDATED = false | 
					
						
							|  |  |  | 				await updateStyle() } | 
					
						
							| 
									
										
										
										
											2022-10-28 01:44:04 +03:00
										 |  |  | 			//*/ | 
					
						
							| 
									
										
										
										
											2022-10-28 01:34:58 +03:00
										 |  |  | 			// config... | 
					
						
							|  |  |  | 			if(CONFIG_UPDATED){ | 
					
						
							|  |  |  | 				CONFIG_UPDATED = false | 
					
						
							|  |  |  | 				await updateConfig() } | 
					
						
							| 
									
										
										
										
											2022-08-10 11:42:31 +03:00
										 |  |  | 			// NOTE: we are intentionally not awaiting for this -- this  | 
					
						
							|  |  |  | 			//		separates the navigate and load events... | 
					
						
							| 
									
										
										
										
											2022-09-17 12:05:00 +03:00
										 |  |  | 			logTime( | 
					
						
							|  |  |  | 				this.refresh(),  | 
					
						
							| 
									
										
										
										
											2022-09-17 12:45:58 +03:00
										 |  |  | 				this.location) }) | 
					
						
							| 
									
										
										
										
											2022-08-10 11:42:31 +03:00
										 |  |  | 		.onLoad(function(evt){ | 
					
						
							| 
									
										
										
										
											2022-08-26 18:41:05 +03:00
										 |  |  | 			var that = this | 
					
						
							| 
									
										
										
										
											2022-09-10 04:11:00 +03:00
										 |  |  | 			// stop spinner... | 
					
						
							|  |  |  | 			stopSpinner() | 
					
						
							| 
									
										
										
										
											2022-08-10 11:42:31 +03:00
										 |  |  | 			// handle title... | 
					
						
							| 
									
										
										
										
											2022-10-03 02:35:14 +03:00
										 |  |  | 			// NOTE: we set the global title to either the last <title>  | 
					
						
							|  |  |  | 			//		tag value or the attr .title  | 
					
						
							|  |  |  | 			var titles = [...document.querySelectorAll('title')] | 
					
						
							|  |  |  | 			titles[0].innerHTML =  | 
					
						
							|  |  |  | 				`${titles.length > 1 ?  | 
					
						
							| 
									
										
										
										
											2022-11-02 15:06:43 +03:00
										 |  |  | 					titles.at(-1).innerText | 
					
						
							| 
									
										
										
										
											2022-10-03 02:35:14 +03:00
										 |  |  | 					: this.title} — pWiki` | 
					
						
							| 
									
										
										
										
											2022-11-21 03:04:48 +03:00
										 |  |  | 			// scroll... | 
					
						
							|  |  |  | 			this.hash ? | 
					
						
							|  |  |  | 				// to anchor element... | 
					
						
							|  |  |  | 				this.dom | 
					
						
							| 
									
										
										
										
											2022-08-10 15:29:45 +03:00
										 |  |  | 					.querySelector('#'+ this.hash) | 
					
						
							| 
									
										
										
										
											2022-08-26 18:41:05 +03:00
										 |  |  | 					.scrollIntoView()  | 
					
						
							| 
									
										
										
										
											2022-11-21 03:04:48 +03:00
										 |  |  | 				// restore history position... | 
					
						
							|  |  |  | 				// XXX HACK this will work only on full page... | 
					
						
							|  |  |  | 				: (document.scrollingElement.scrollTop = this.__scroll ?? 0) | 
					
						
							| 
									
										
										
										
											2022-10-05 20:44:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// XXX MediumEditor... | 
					
						
							|  |  |  | 			//setupMediumEditor() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-26 18:41:05 +03:00
										 |  |  | 			// handle refresh... | 
					
						
							|  |  |  | 			// NOTE: we need to do this as hashchange is only triggered  | 
					
						
							|  |  |  | 			//		when the hash is actually changed... | 
					
						
							| 
									
										
										
										
											2022-08-31 18:49:59 +03:00
										 |  |  | 			for(var lnk of this.dom.querySelectorAll(`a[href="${location.hash}"]`)){ | 
					
						
							| 
									
										
										
										
											2022-09-19 00:18:23 +03:00
										 |  |  | 				lnk.addEventListener('click', refresh) } }) | 
					
						
							| 
									
										
										
										
											2022-10-31 02:29:21 +03:00
										 |  |  | 		.delete(refresh) | 
					
						
							| 
									
										
										
										
											2022-08-16 11:00:23 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-28 01:34:58 +03:00
										 |  |  | 	// handle special file updates... | 
					
						
							| 
									
										
										
										
											2022-10-28 14:10:31 +03:00
										 |  |  | 	// NOTE: the actual updates are done .navigate(..) | 
					
						
							| 
									
										
										
										
											2022-10-28 01:34:58 +03:00
										 |  |  | 	pwiki.store | 
					
						
							|  |  |  | 		.update(function(_, path){ | 
					
						
							| 
									
										
										
										
											2022-10-28 01:44:04 +03:00
										 |  |  | 			// XXX GLOBAL_STYLE | 
					
						
							|  |  |  | 			//if(path == '/.config/Style'){ | 
					
						
							|  |  |  | 			//	STYLE_UPDATED = true } | 
					
						
							| 
									
										
										
										
											2022-10-28 01:34:58 +03:00
										 |  |  | 			if(path == '/.config/Config'){ | 
					
						
							|  |  |  | 				CONFIG_UPDATED = true } }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-16 11:00:23 +03:00
										 |  |  | 	// wait for stuff to finish... | 
					
						
							| 
									
										
										
										
											2022-10-26 19:18:21 +03:00
										 |  |  | 	browser.setup.then(async function(){ | 
					
						
							|  |  |  | 		// index... | 
					
						
							|  |  |  | 		await logTime( | 
					
						
							|  |  |  | 			pwiki.store.index(),  | 
					
						
							|  |  |  | 			'Indexing') | 
					
						
							| 
									
										
										
										
											2022-10-28 01:34:58 +03:00
										 |  |  | 		// setup global stuff... | 
					
						
							| 
									
										
										
										
											2022-10-28 01:44:04 +03:00
										 |  |  | 		// XXX GLOBAL_STYLE | 
					
						
							|  |  |  | 		//updateStyle() | 
					
						
							| 
									
										
										
										
											2022-10-28 01:34:58 +03:00
										 |  |  | 		updateConfig() | 
					
						
							| 
									
										
										
										
											2022-08-16 11:00:23 +03:00
										 |  |  | 		// show current page... | 
					
						
							| 
									
										
										
										
											2022-09-10 04:11:00 +03:00
										 |  |  | 		pwiki.location = decodeURI(location.hash).slice(1) }) })  | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-13 14:57:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-10 04:11:00 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-25 20:27:17 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-17 19:39:39 +03:00
										 |  |  | //--------------------------------------------------------------------- | 
					
						
							|  |  |  | // Export... | 
					
						
							| 
									
										
										
										
											2022-08-14 03:00:06 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-13 14:57:53 +03:00
										 |  |  | // XXX | 
					
						
							| 
									
										
										
										
											2022-09-18 20:45:55 +03:00
										 |  |  | var exportData = async function(options={}){ | 
					
						
							|  |  |  | 	var filename | 
					
						
							|  |  |  | 	if(typeof(options) == 'string'){ | 
					
						
							|  |  |  | 		filename = options | 
					
						
							|  |  |  | 		options = arguments[1] ?? {} } | 
					
						
							|  |  |  | 	var blob = new Blob( | 
					
						
							|  |  |  | 		[await pwiki.store.json({stringify: true, space: 4, ...options})],  | 
					
						
							|  |  |  | 		{type: "text/plain;charset=utf-8"}); | 
					
						
							| 
									
										
										
										
											2022-08-13 14:57:53 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	var a = document.createElement('a') | 
					
						
							|  |  |  |     var blobURL = a.href = URL.createObjectURL(blob) | 
					
						
							| 
									
										
										
										
											2022-09-18 20:45:55 +03:00
										 |  |  |     a.download = filename | 
					
						
							|  |  |  | 		?? options.filename  | 
					
						
							| 
									
										
										
										
											2022-09-30 05:21:51 +03:00
										 |  |  | 		?? (Date.timeStamp() +'.pWiki.json') | 
					
						
							| 
									
										
										
										
											2022-08-13 14:57:53 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     //document.body.appendChild(a) | 
					
						
							|  |  |  |     a.dispatchEvent(new MouseEvent("click")) | 
					
						
							|  |  |  |     //document.body.removeChild(a) | 
					
						
							|  |  |  |     //URL.revokeObjectURL(blobURL) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-17 19:39:39 +03:00
										 |  |  | //--------------------------------------------------------------------- | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | </script> | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 19:47:08 +03:00
										 |  |  | <body> | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-11 10:39:55 +03:00
										 |  |  | <!-- XXX need to add something passive but animated here... --> | 
					
						
							| 
									
										
										
										
											2022-09-02 21:15:22 +03:00
										 |  |  | <div id="pWiki"> | 
					
						
							|  |  |  | 	<div class="spinner"> | 
					
						
							|  |  |  | 		<span style="--i:0">p</span> | 
					
						
							|  |  |  | 		<span style="--i:1">W</span> | 
					
						
							|  |  |  | 		<span style="--i:2">i</span> | 
					
						
							|  |  |  | 		<span style="--i:3">k</span> | 
					
						
							|  |  |  | 		<span style="--i:4">i</span> | 
					
						
							|  |  |  | 	</div> | 
					
						
							|  |  |  | </div> | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-10 04:11:00 +03:00
										 |  |  | <div class="page spinner"> | 
					
						
							| 
									
										
										
										
											2022-09-10 04:25:59 +03:00
										 |  |  | 	<span style="--i:0">.</span> | 
					
						
							|  |  |  | 	<span style="--i:1">.</span> | 
					
						
							|  |  |  | 	<span style="--i:2">.</span> | 
					
						
							| 
									
										
										
										
											2022-09-10 04:11:00 +03:00
										 |  |  | </div> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-04 11:00:21 +03:00
										 |  |  | </body> | 
					
						
							|  |  |  | </html> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <!-- vim:set sw=4 ts=4 : --> |