mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 18:10:09 +00:00
tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
e10bdf83b0
commit
6539a7e949
27
index.html
27
index.html
@ -23,9 +23,11 @@ var reload = () => {
|
||||
|
||||
// process text...
|
||||
var text = Wiki.text
|
||||
var editing = $('.text').prop('contenteditable') != 'true'
|
||||
var filters = []
|
||||
|
||||
// expand macros...
|
||||
if($('.text').prop('contenteditable') != 'true'){
|
||||
if(editing){
|
||||
text = text
|
||||
// Syntax:
|
||||
// @<macro>( <args> )
|
||||
@ -39,8 +41,7 @@ var reload = () => {
|
||||
//console.log('>>>>>', macro, args)
|
||||
|
||||
if(macro == 'filter' && args.length == 1){
|
||||
console.log('FILTER:', args[0])
|
||||
// XXX
|
||||
filters.push(args[0])
|
||||
return ''
|
||||
}
|
||||
|
||||
@ -94,7 +95,7 @@ var reload = () => {
|
||||
})
|
||||
}
|
||||
|
||||
$('.text').html(activateWikiWords(text))
|
||||
$('.text').html(activateWikiWords(text, filters.indexOf('show_link_brackets') < 0 && editing))
|
||||
|
||||
// XXX save...
|
||||
localStorage['wiki-data'] = JSON.stringify(Wiki.__wiki_data)
|
||||
@ -103,7 +104,6 @@ var reload = () => {
|
||||
$('title').text(Wiki.location)
|
||||
}
|
||||
|
||||
// XXX add history support...
|
||||
var go = (path) => {
|
||||
history.pushState({
|
||||
wikipath: path
|
||||
@ -118,16 +118,27 @@ var go = (path) => {
|
||||
var clearWikiWords = elem => {
|
||||
// clear existing...
|
||||
elem.find('.WikiWord').each(function(){
|
||||
$(this).replaceWith(this.childNodes)})
|
||||
$(this).attr('braced') == 'yes' ?
|
||||
$(this).replaceWith(['['].concat(this.childNodes, [']']))
|
||||
: $(this).replaceWith(this.childNodes)
|
||||
})
|
||||
return elem
|
||||
}
|
||||
|
||||
var activateWikiWords = text =>
|
||||
var activateWikiWords = (text, show_brackets) =>
|
||||
text
|
||||
// set new...
|
||||
.replace(
|
||||
Wiki.__wiki_link__,
|
||||
'<a class="WikiWord" href="#" onclick="go($(this).text().replace(/^\\[|\\]$/g, \'\'))">$1</a>')
|
||||
function(l){
|
||||
return '<a '
|
||||
+'class="WikiWord" '
|
||||
+'href="#" '
|
||||
+'braced="'+ (show_brackets && l[0] == '[' ? 'yes' : 'no') +'"'
|
||||
+'onclick="go($(this).text().replace(/^\\[|\\]$/g, \'\'))">'
|
||||
+ (show_brackets && l[0] == '[' ? l.slice(1, -1) : l)
|
||||
+'</a>'
|
||||
})
|
||||
|
||||
|
||||
$(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user