Heimdall/resources/views/items/scripts.blade.php

81 lines
3.4 KiB
PHP
Raw Normal View History

2018-10-19 14:10:05 +00:00
<script src="{{ asset('js/select2.min.js') }}"></script>
2018-02-05 19:43:24 +00:00
<script>
$( function() {
2018-02-05 23:08:37 +00:00
var base = (document.querySelector('base') || {}).href;
2018-02-05 23:08:37 +00:00
var elem = $('.color-picker')[0];
var hueb = new Huebee( elem, {
// options
2018-10-28 20:41:46 +00:00
setBGColor: '.set-bg-elem'
});
2018-10-28 20:41:46 +00:00
hueb.on( 'change', function( color, hue, sat, lum ) {
$.get('{{ route('titlecolour') }}', {color}, function(data) {
$('#tile-preview .title').removeClass("black white");
$('#tile-preview .link').removeClass("black white");
$('#tile-preview .title').addClass(data);
$('#tile-preview .link').addClass(data);
});
})
var availableTags = @json(App\Application::autocomplete());
console.log(availableTags)
2018-02-05 19:43:24 +00:00
$( "#appname" ).autocomplete({
source: availableTags,
select: function( event, ui ) {
event.preventDefault();
// appload(ui.item.value);
$( "#appname" ).val(ui.item.label)
$('#apptype').val(ui.item.value).change()
2018-11-04 16:03:55 +00:00
}
});
// initial load
$('#tile-preview .title').html($('#appname').val());
$('#tile-preview .item').css('backgroundColor', $('#appcolour').val());
$('#tile-preview .app-icon').attr('src', $('#appimage img').attr('src'));
// Updates
2018-11-04 16:03:55 +00:00
$('#appname').on('keyup change', function(e) {
$('#tile-preview .title').html($(this).val());
})
$('#apptype').on('change', function(e) {
appload($(this).find('option:selected').val());
2018-11-04 16:03:55 +00:00
});
$('#appcolour').on('change', function(e) {
$('#tile-preview .item').css('backgroundColor', $(this).val());
})
$('.tags').select2();
function appload(appvalue) {
if(appvalue == 'None') {
$('#sapconfig').html('').hide();
2022-03-14 12:25:20 +00:00
$('#tile-preview .app-icon').attr('src', '/img/heimdall-icon-small.png');
$('#appimage').html("<img src='/img/heimdall-icon-small.png' />");
} else {
$.post('{{ route('appload') }}', { app: appvalue }, function(data) {
2018-10-28 20:41:46 +00:00
// Main details
2018-10-21 11:39:12 +00:00
$('#appimage').html("<img src='"+data.iconview+"' /><input type='hidden' name='icon' value='"+data.icon+"' />");
2018-02-05 20:59:38 +00:00
$('input[name=colour]').val(data.colour);
$('select[name=class]').val(data.appid);
2018-02-05 23:08:37 +00:00
hueb.setColor( data.colour );
$('input[name=pinned]').prop('checked', true);
2018-10-28 20:41:46 +00:00
// Preview details
$('#tile-preview .app-icon').attr('src', data.iconview);
$('#tile-preview .title').html(data.name);
2018-02-05 23:08:37 +00:00
if(data.config != null) {
2022-03-11 19:03:03 +00:00
$.get(base+'view/'+data.config, function(getdata) {
2018-02-05 23:08:37 +00:00
$('#sapconfig').html(getdata).show();
});
} else {
$('#sapconfig').html('').hide();
2018-02-05 23:08:37 +00:00
}
2018-02-05 20:59:38 +00:00
}, "json");
}
2018-02-17 00:13:38 +00:00
2018-11-04 16:03:55 +00:00
}
2018-02-17 00:13:38 +00:00
2018-02-05 19:43:24 +00:00
});
</script>