Warning: Cannot modify header information - headers already sent by (output started at /var/www/jonas-eriksen.dk/pic/private/index.php:1) in /var/www/jonas-eriksen.dk/pic/private/index.php on line 215
var/www/jonas-eriksen.dk/wiki/lib/plugins/include/script.js 0000644 00000001166 15233564450 0020017 0 ustar 00 /**
* Javascript functionality for the include plugin
*/
/**
* Highlight the included section when hovering over the appropriate include edit button
*
* @author Andreas Gohr
* @author Michael Klier
* @author Michael Hamann
*/
jQuery(function() {
jQuery('.btn_incledit')
.mouseover(function () {
jQuery(this).closest('.plugin_include_content').addClass('section_highlight');
})
.mouseout(function () {
jQuery('.section_highlight').removeClass('section_highlight');
});
});
// vim:ts=4:sw=4:et:
var/www/jonas-eriksen.dk/wiki/lib/plugins/prosemirror/script.js 0000644 00000014414 15233573175 0020763 0 ustar 00 /**
* Hide Prosemirror and show the default editor
*
* @param {string} text the wiki syntax to be shown in the textarea
*/
function showDefaultEditor(text) {
window.Prosemirror.destroyProsemirror();
window.proseMirrorIsActive = false;
dw_locktimer.init(dw_locktimer.timeout/1000, dw_locktimer.draft);
jQuery('#wiki__text').val(text).show();
jQuery('#size__ctl').show();
jQuery('.editBox > .toolbar').show();
}
/**
* Hide the default editor and start a new Prosemirror Editor
*
* @param {string} json the prosemirror document json
*/
function showProsemirror(json) {
const $textArea = jQuery('#wiki__text');
const $prosemirrorJsonInput = jQuery('#dw__editform').find('[name=prosemirror_json]').val(json);
try {
window.Prosemirror.enableProsemirror();
disableNativeFirefoxTableControls();
} catch (e) {
console.error(e);
let message = 'There was an error in the WYSIWYG editor. You will be redirected to the syntax editor in 5 seconds.';
if (window.SentryPlugin) {
SentryPlugin.logSentryException(e, {
tags: {
plugin: 'prosemirror',
'id': JSINFO.id,
},
extra: {
'content': $textArea.val(),
'json': $prosemirrorJsonInput.val(),
}
});
message += ' -- The error has been logged to Sentry.';
}
showErrorMessage(message);
setTimeout(function() {
jQuery('.plugin_prosemirror_useWYSIWYG').click();
}, 5000);
}
window.proseMirrorIsActive = true;
$textArea.hide();
jQuery('#size__ctl').hide();
jQuery('.editBox > .toolbar').hide();
jQuery('div.ProseMirror').focus();
if (dw_locktimer.addField) {
// todo remove this guard after the next stable DokuWiki release after Greebo
dw_locktimer.init(dw_locktimer.timeout/1000, dw_locktimer.draft, 'prosemirror__editor');
dw_locktimer.addField('input[name=prosemirror_json]');
} else {
console.warn('Draft saving in WYSIWYG is not available. Please upgrade your wiki to the current development snapshot.')
}
}
/**
* Disables Firefox's controls for editable tables, they are incompatible with prosemirror
*
* See https://github.com/ProseMirror/prosemirror/issues/432 and https://github.com/ProseMirror/prosemirror-tables/issues/22
*/
function disableNativeFirefoxTableControls() {
document.execCommand("enableObjectResizing", false, "false");
document.execCommand("enableInlineTableEditing", false, "false");
}
/**
* Initialize the prosemirror framework
*
* (This shouldn't do much until we actually use the editor, but we maybe shouldn't do this twice)
*/
function initializeProsemirror() {
try {
/* DOKUWIKI:include lib/bundle.js */
} catch (e) {
const $textArea = jQuery('#wiki__text');
console.error(e);
let message = 'There was an error initializing the WYSIWYG editor.';
if (window.SentryPlugin) {
SentryPlugin.logSentryException(e, {
tags: {
plugin: 'prosemirror',
'id': JSINFO.id,
},
extra: {
'content': $textArea.val(),
}
});
message += ' The error has been logged to sentry.';
}
showErrorMessage(message);
DokuCookie.setValue('plugin_prosemirror_useWYSIWYG', '');
}
}
/**
* Add the error message above the editor
*
* @param {string} errorMsg
*/
function showErrorMessage(errorMsg) {
jQuery('.editBox').before(
jQuery('').text(errorMsg)
);
}
/**
* Switch between WYSIWYG and Syntax editor
*/
function toggleEditor() {
const $textArea = jQuery('#wiki__text');
const $jsonField = jQuery('#dw__editform').find('[name=prosemirror_json]');
jQuery.post(DOKU_BASE + 'lib/exe/ajax.php', {
call: 'plugin_prosemirror_switch_editors',
data: window.proseMirrorIsActive ? $jsonField.val() : $textArea.val(),
getJSON: window.proseMirrorIsActive ? '0' : '1',
}).done(function handleSwitchEditorResponse(data) {
if (window.proseMirrorIsActive) {
showDefaultEditor(data.text);
} else {
showProsemirror(data.json);
}
}).fail(function (jqXHR, textStatus, errorThrown) {
console.error(jqXHR, textStatus, errorThrown); // FIXME: proper error handling
if (jqXHR.responseJSON && jqXHR.responseJSON.error) {
showErrorMessage(jqXHR.responseJSON.error);
} else {
let message = 'The request failed with an unexpected error.';
if (window.SentryPlugin) {
SentryPlugin.logSentryException(new Error(textStatus), {
tags: {
plugin: 'prosemirror',
'id': JSINFO.id,
status: jqXHR.status
},
extra: {
'content': $textArea.val(),
'responseText': jqXHR.responseText,
}
});
message += ' -- The error has been logged to Sentry.';
}
showErrorMessage(message);
}
});
const $current = DokuCookie.getValue('plugin_prosemirror_useWYSIWYG');
DokuCookie.setValue('plugin_prosemirror_useWYSIWYG', $current ? '' : '1');
}
/**
* If the cookie is set, then show the WYSIWYG editor and add the switch-editor-event to the button
*/
function handleEditSession() {
const $jsonField = jQuery('#dw__editform').find('[name=prosemirror_json]');
if (DokuCookie.getValue('plugin_prosemirror_useWYSIWYG')) {
showProsemirror($jsonField.val());
}
const $toggleEditorButton = jQuery('.plugin_prosemirror_useWYSIWYG');
$toggleEditorButton.on('click', toggleEditor);
}
jQuery(function () {
initializeProsemirror();
window.proseMirrorIsActive = false;
if (jQuery('#dw__editform').find('[name=prosemirror_json]').length) {
handleEditSession();
}
jQuery(window).on('fastwiki:afterSwitch', function(evt, viewMode, isSectionEdit, prevViewMode) {
if (viewMode === 'edit' || isSectionEdit) {
handleEditSession();
}
});
});
var/www/jonas-eriksen.dk/wiki/lib/plugins/styling/script.js 0000644 00000006246 15233630554 0020070 0 ustar 00 jQuery(function () {
/**
* Function to reload the preview styles in the main window
*
* @param {Window} target the main window
*/
function applyPreview(target) {
// remove style
var $style = target.jQuery('link[rel=stylesheet][href*="lib/exe/css.php"]');
$style.attr('href', '');
// append the loader screen
var $loader = target.jQuery('#plugin__styling_loader');
if (!$loader.length) {
$loader = target.jQuery('
' + LANG.plugins.styling.loader + '
');
$loader.css({
'position': 'absolute',
'width': '100%',
'height': '100%',
'top': 0,
'left': 0,
'z-index': 5000,
'background-color': '#fff',
'opacity': '0.7',
'color': '#000',
'font-size': '2.5em',
'text-align': 'center',
'line-height': 1.5,
'padding-top': '2em'
});
target.jQuery('body').append($loader);
}
// load preview in main window (timeout works around chrome updating CSS weirdness)
setTimeout(function () {
var now = new Date().getTime();
$style.attr('href', DOKU_BASE + 'lib/exe/css.php?preview=1&tseed=' + now);
}, 500);
}
var doreload = 1;
var $styling_plugin = jQuery('#plugin__styling');
// if we are not on the plugin page (either main or popup)
if (!$styling_plugin.length) {
// handle the preview cookie
if(DokuCookie.getValue('styling_plugin') == 1) {
applyPreview(window);
}
return; // nothing more to do here
}
/* ---- from here on we're in the popup or admin page ---- */
// add button on main page
if (!$styling_plugin.hasClass('ispopup')) {
var $form = $styling_plugin.find('form.styling').first();
var $btn = jQuery('');
$form.prepend($btn);
$btn.on('click', function (e) {
var windowFeatures = "menubar=no,location=no,resizable=yes,scrollbars=yes,status=false,width=500,height=500";
window.open(DOKU_BASE + 'lib/plugins/styling/popup.php', 'styling_popup', windowFeatures);
e.preventDefault();
e.stopPropagation();
}).wrap('');
return; // we exit here if this is not the popup
}
/* ---- from here on we're in the popup only ---- */
// reload the main page on close
window.onunload = function(e) {
if(doreload) {
DokuCookie.setValue('styling_plugin', 0);
if(window.opener) window.opener.document.location.reload();
}
return null;
};
// don't reload on our own buttons
jQuery(':button').click(function(e){
doreload = false;
});
// on first load apply preview
if(window.opener) applyPreview(window.opener);
// enable the preview cookie
DokuCookie.setValue('styling_plugin', 1);
});