Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.

  • Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
  • Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
  • Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
// ##########################################################################
// ##### Name: WikiBar.js ###################################################
// ##### Version: 0.0.3-beta ################################################
// ##### Letzte Änderung: 14.01.2017 ########################################
// ##### Autor: FNDE [[Benutzer:FNDE/Script/WikiBar]] #######################
// ##########################################################################

function bar_set_option(action, value) {

    switch (action) {

        case 'toggle':
            bar_config.toggle = bar_charcode[value];
            break;

        case 'close':
            bar_config.close = bar_charcode[value];
            break;

        case 'immediately':
            bar_config.immediately = value;
            break;

        case 'bg_color':
            bar_config.bg_color = value;
            break;

        case 'text_color':
            bar_config.text_color = value;
            break;

        case 'key_color':
            bar_config.key_color = value;
            break;

        case 'box_bg_color':
            bar_config.box_bg_color = value;
            break;

        case 'box_border_color':
            bar_config.box_border_color = value;
            break;

        case 'line_color':
            bar_config.line_color = value;
            break;

    }

}

function bar_add_bar_item(key, action, condition) {

    bar_item = new Object();

    bar_item.key = key;
    bar_item.action = action;
    bar_item.condition = condition;

    bar_settings[bar_settings_array] = bar_item;
    bar_settings_array = bar_settings_array + 1;

}

function bar_add_delimiter(bool) {

    if (bool === true) {

        bar_item = new Object();
        bar_item.delimiter = true;

        bar_settings[bar_settings_array] = bar_item;
        bar_settings_array = bar_settings_array + 1;

    }

}

function bar_append_overlay() {

    $('body').append('<style>.custom_wiki_div_mode { display: inline; padding: 3px; padding-right: 6px; background-color: transparent !important; } .custom_wiki_highlight * { color: #000 !important; }' +
        '.custom_wiki_highlight { background-color: #f0e001 !important; color: #000 !important; } .custom_wiki_line { position: relative; left: -20px; border-top: 1px solid ' + bar_config.line_color + '; opacity: 0.3; width: 210px;' +
        'margin-top: 8px; padding-bottom: 10px; background: transparent !important; } #custom_wiki_inline { border-radius: 7px; z-index: 999; background-color: ' + bar_config.box_bg_color + ' !important; opacity: 1; padding: 20px;' +
        'border: 2px solid ' + bar_config.box_border_color + '; } #custom_wiki_toolbar { display: none;z-index: 100; font-size: 16pt; position: fixed; top: 0px; left: 0px; background-color: ' + bar_config.bg_color + ' !important; color: ' + bar_config.text_color + ' !important;' +
        'width: 100%; height: 100%; padding: 150px; padding-left: 35%; line-height: 40px; } #custom_wiki_inline .custom_wiki_hoch { position: relative; top: -1px; padding-right: 2px; padding-left: 2px; } #custom_wiki_inline b { color: ' + bar_config.key_color + '; }</style>');

    $('body').append('<div id="custom_wiki_toolbar"><div id="custom_wiki_inline"></div></div>');

    $('#custom_wiki_toolbar').hide();

    bar_append_bar_items();

}

function bar_append_action(value, index, type) {

    $('#custom_wiki_inline').append('<div id="custom_wiki_op_' + index + '" class="custom_wiki_div_mode"><span class="custom_wiki_hoch">(</span><b>' + value.key + '</b><span class="custom_wiki_hoch">)</span> ' + value.action + '</div><br>');

    $(document).keydown(function(event) {

        if (event.keyCode == bar_charcode[value.key] && (bar_toggle_status === true || (bar_config.immediately == true && !$("textarea,input").is(":focus")))) {

            $("#custom_wiki_op_" + index).addClass("custom_wiki_highlight");

            if (type == 1) {

                $(value.condition)[0].click();
				
                if ($(value.condition).prop('tagName') != 'A' || $(value.condition).attr('href') == '#') {

                    $('html, body').animate({
                        scrollTop: $(value.condition).offset().top - 300
                    }, 150);
					
                    bar_close_overlay();

                }

            } else if (type == 2) {
                window.location.href = value.condition;
            } else if (type == 3) {

                switch (value.condition) {
                    case '[close_window]':
                    bar_close_overlay();
                        break;
                    case '[exit_window]':
                    window.close();
                        break;
                }

            }

            if (bar_config.immediately == false) {
                bar_toggle_status = false;
            } else {
                bar_config.immediately = false;
                setTimeout(function() {
                    bar_config.immediately = true;
                }, 150);

            }

        }

    });

}

Object.size = function(obj) {
    var size = 0,key;
    for (key in obj) {
        
		if (obj.hasOwnProperty(key)) size++;
		
    }
    return size;
};

function bar_close_overlay() {

    bar_toggle_status = false;
	
    $("#custom_wiki_toolbar").fadeOut(100, function() {
		
    $("#custom_wiki_inline div").removeClass('custom_wiki_highlight');
	
    });

}

$.fn.hasAttr = function(name) {
	
    return this.attr(name) !== undefined;
	
};

function bar_append_bar_items() {

    var loop = 1;
    var bar_settings_size = Object.size(bar_settings);
	var is_delimiter = false;

    $.each(bar_settings, function(index, value) {

        if (value.delimiter === undefined) {

            if (value.condition.indexOf("http://") == -1 && value.condition.indexOf("https://") == -1) {

                if ($(value.condition).length && !$(value.condition).hasAttr('disabled')) {

                    bar_append_action(value, index, 1);
                    loop = loop + 1;
					is_delimiter = false;

                } else if (value.condition.charAt(0) == '[' && value.condition.charAt(value.condition.length - 1) == ']') {

                    bar_append_action(value, index, 3);
                    loop = loop + 1;
					is_delimiter = false;

                }

            } else {

                bar_append_action(value, index, 2);
                loop = loop + 1;
				is_delimiter = false;

            }

        } else {
			
            if (loop != bar_settings_size && loop != 1 && is_delimiter==false) {
				
                $('#custom_wiki_inline').append('<div class="custom_wiki_line"></div>');
				is_delimiter = true;
				
            }
			
            loop = loop + 1;
        }

    });

}

function bar_keybind_global() {

    $(document).keydown(function(event) {

        if (event.keyCode == bar_config.close) {
            bar_close_overlay();
        }

        if (event.keyCode == bar_config.toggle && !$("textarea,input").is(":focus")) {

            if ($('#custom_wiki_toolbar').is(':visible')) {
                bar_toggle_status = false;
            } else {
                bar_toggle_status = true;
            }

            $("#custom_wiki_toolbar").fadeToggle(100);

        }

    });

}

var bar_settings = new Object();
var bar_config = new Object();
var bar_toggle_status = false;
var bar_settings_array = 0;
var bar_item;

var bar_charcode = new Object({

    '0': 96,
    '1': 97,
    '2': 98,
    '3': 99,
    '4': 100,
    '5': 101,
    '6': 102,
    '7': 103,
    '8': 104,
    '9': 105,
    'F1': 112,
    'F2': 113,
    'F3': 114,
    'F4': 115,
    'F5': 116,
    'F6': 117,
    'F7': 118,
    'F8': 119,
    'F9': 120,
    'F10': 121,
    'F11': 122,
    'F12': 123,
    '&#10006;': 106, // multiply
    '&times;': 106, // multiply
    '&plus;': 107, // plus
    '&minus;': 109, // minus
    '&#247;': 111, // divide
    ',': 110, // null comma
    'DEL': 46, // delete
    'INS': 45, // insert
    '&#8593;': 38, // arrow up
    '&#8595;': 40, // arrow down
    '&#8592;': 37, // arrow left
    '&#8594;': 39, // arrow right
    'END': 35, // end page
    'HOME': 34, // top page
    '_': 32, // blank
    'ESC': 27, // escape
    '&#8656;': 8, // backspace
    'ALT': 18,
    'SHIFT': 16,
    'ENTER': 13,
    '&crarr;': 13,
    'TAB': 9

});

$(document).ready(function() {

    if (typeof bar_setup == 'function') {

        bar_setup();

    } else {
	
        alert('WikiBar: Setup() not found!');
		
    }

    bar_append_overlay();
    bar_keybind_global();

});