/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$(function () {
var linuxservice = function (befehl_id, that) {
$.post('../ajax/linuxbefehle_service.php', {
action: 'new',
befehl_id: befehl_id
}, function (data) {
eintraege = JSON.parse(data);
anzahl = eintraege.length;
konsole = '';
for (i = 0; i < anzahl; i++) {
konsole += eintraege[i].schalter + ' ' + eintraege[i].description + '
';
}
that.parent().find('.console').remove();
that.parent().append('
')
});
}
var console_engine = function (befehl_id, that, mode) {
if (mode == 'up' || mode == 'down') {
that.parent().find('.console').remove();
}
if (mode == 'single' || mode == 'down') {
if (typeof that.parent().find('.console').html() === 'undefined') {
that.parent().append('')
linuxservice(befehl_id, that);
} else {
that.parent().find('.console').remove();
}
}
}
$('.out').click(function () {
mode = $(this).attr('mode-id');
kat_id = $(this).parent().parent().parent().attr('data-id');
target = $(this).parent().parent().parent().parent().parent();
elements = target.find('[kat-id=' + kat_id + ']');
$(elements).each(function (index) {
befehl_id = $(this).attr('data-id');
var that = $(this);
if (that.attr('class') == 'row lin-befehl') {
console_engine(befehl_id, that, mode);
}
});
});
$('.scroll').click(function () {
jump = $(this).attr('data-id');
$('html, body').animate({
scrollTop: $("#anker-" + jump + "-lin-level1").offset().top - 130
}, 210);
});
$('.lin-level1 .col-sm-3').click(function () {
kat_id = $(this).attr('data-id');
});
$('#remove-search').click(function () {
$("#suchergebnis-box").hide();
$('.suchbegriff').val('');
$('.suchbegriff').focus();
});
$('#show-search').click(function () {
elements = $('#suchergebnis').find('.lin-befehl');
mode = 'down'
$(this).hide();
$('#hide-search').show();
$(elements).each(function (index) {
befehl_id = $(this).attr('data-id');
var that = $(this);
if (that.attr('class') == 'row lin-befehl') {
console_engine(befehl_id, that, mode);
}
});
});
$('#hide-search').click(function () {
elements = $('#suchergebnis').find('.lin-befehl');
mode = 'up';
$(this).hide();
$('#show-search').show();
$(elements).each(function (index) {
befehl_id = $(this).attr('data-id');
var that = $(this);
if (that.attr('class') == 'row lin-befehl') {
console_engine(befehl_id, that, mode);
}
});
});
$('#show-kat').click(function () {
$("#kat-box").show();
$('#show-kat').hide();
$('#hide-kat').show();
});
$('#hide-kat').click(function () {
$("#kat-box").hide();
$('#hide-kat').hide();
$('#show-kat').show();
});
$('#hide-kat').click(function () {
$("#kat-box").hide();
$('#hide-kat').hide();
$('#show-kat').show();
});
$('#download').click(function () {
$(this).html('');
var that = $(this);
$.post('../ajax/linuxbefehle_service.php', {
action: 'download'
}, function (data) {
that.html(data);
});
});
$(document).keypress(function (e) {
if (e.which == 13) {
$('#suche').click()
}
});
var quality_message=function(value){
if(value<100){
quality='Meinten Sie etwa..'+value
}else{
quality='';
}
return quality;
}
$('#suche').click(function () {
suchbegriff = $('.suchbegriff').val();
$("#suchergebnis-box").show();
$.post('../ajax/linuxbefehle_service.php', {
action: 'search',
suchbegriff: suchbegriff
}, function (data) {
$('#suchergebnis').html(data);
ergebnis = JSON.parse(data);
eintraege=ergebnis.response;
anzahl = eintraege.length;
quality=ergebnis.quality;
$('#message').html(quality_message(quality));
konsole = '';
if (anzahl == 0) {
konsole = 'Das haben wir leider nicht - aber viele andere schöne Sachen
';
} else {
for (i = 0; i < anzahl; i++) {
datensatz = $('#befehl_template').clone(true);
datensatz.find('#anker-dummy').attr('data-id', eintraege[i].id);
datensatz.find('.col-sm-3').html(eintraege[i].schalter);
datensatz.find('.col-sm-9').html(eintraege[i].description);
konsole = konsole + datensatz.html();
}
}
//$("#suchergebnis").html('' + konsole + '
');
$("#suchergebnis").html(konsole);
$('.lin-befehl').unbind("click");
$('.lin-befehl').bind("click", function () {
befehl_id = $(this).attr('data-id');
var that = $(this);
console_engine(befehl_id, that, 'single');
});
});
});
$('.lin-befehl').click(function () {
befehl_id = $(this).attr('data-id');
var that = $(this);
console_engine(befehl_id, that, 'single');
});
});