2016-12-12 22:23:15 +00:00
|
|
|
(function() {
|
|
|
|
if (!OCA.GpxEdit) {
|
|
|
|
OCA.GpxEdit = {};
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
2016-12-13 01:01:47 +00:00
|
|
|
function addLogoLine(name){
|
|
|
|
var url = OC.generateUrl('/apps/gpxedit/getExtraSymbol?');
|
|
|
|
var fullurl = url+'name='+encodeURI(name);
|
|
|
|
var nameWe = name.replace(/\.png$/, '');
|
2016-12-13 10:53:39 +00:00
|
|
|
$('div#extraSymbols table').append('<tr class="extraSymbol" id="'+nameWe+'">'+
|
|
|
|
'<td><img src="'+fullurl+'"></td><td><label> '+nameWe+' </label></td>'+
|
|
|
|
'<td><button class="delExtraSymbol icon-delete icon" name="'+name+'" title="Remove"></button></td></tr>');
|
2016-12-13 01:01:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function deleteLogo(button){
|
|
|
|
button.removeClass('icon-delete').addClass('icon-loading-small');
|
|
|
|
var name = button.attr('name');
|
|
|
|
var req = {
|
|
|
|
name : name,
|
|
|
|
}
|
|
|
|
var url = OC.generateUrl('/apps/gpxedit/deleteExtraSymbol');
|
|
|
|
$.post(url, req).done(function (response) {
|
2016-12-13 10:53:39 +00:00
|
|
|
button.parent().parent().remove();
|
2016-12-13 01:01:47 +00:00
|
|
|
OC.msg.finishedSuccess('#extraSymbolsSettingsMsg', response.data.message);
|
|
|
|
}).fail(function(){
|
|
|
|
OC.msg.finishedError('#extraSymbolsSettingsMsg', 'Failed');
|
|
|
|
button.addClass('icon-delete').removeClass('icon-loading-small');
|
|
|
|
});
|
|
|
|
}
|
2016-12-12 22:23:15 +00:00
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
var url = OC.generateUrl('/apps/gpxedit/getExtraSymbol?');
|
2016-12-13 10:53:39 +00:00
|
|
|
$('tr.extraSymbol img').each(function(){
|
2016-12-12 22:23:15 +00:00
|
|
|
var filename = $(this).attr('src');
|
|
|
|
var fullurl = url+'name='+encodeURI(filename);
|
|
|
|
$(this).attr('src', fullurl);
|
|
|
|
});
|
|
|
|
|
2016-12-13 01:01:47 +00:00
|
|
|
var uploadParamsSymbol = {
|
|
|
|
pasteZone: null,
|
|
|
|
dropZone: null,
|
|
|
|
done: function (e, response) {
|
|
|
|
addLogoLine(response.result.data.name);
|
|
|
|
OC.msg.finishedSaving('#extraSymbolsSettingsMsg', response.result);
|
|
|
|
$('label#uploadsymbol').addClass('icon-upload').removeClass('icon-loading-small');
|
|
|
|
},
|
|
|
|
submit: function(e, response) {
|
|
|
|
OC.msg.startSaving('#extraSymbolsSettingsMsg');
|
|
|
|
$('label#uploadsymbol').removeClass('icon-upload').addClass('icon-loading-small');
|
2016-12-13 11:56:46 +00:00
|
|
|
if ($('input#addExtraSymbolName').val() === ''){
|
|
|
|
OC.msg.finishedError('#extraSymbolsSettingsMsg', 'Empty symbol name');
|
|
|
|
e.preventDefault();
|
|
|
|
$('label#uploadsymbol').addClass('icon-upload').removeClass('icon-loading-small');
|
|
|
|
}
|
2016-12-13 01:01:47 +00:00
|
|
|
},
|
|
|
|
fail: function (e, response){
|
2016-12-13 11:56:46 +00:00
|
|
|
OC.msg.finishedError('#extraSymbolsSettingsMsg', response._response.jqXHR.responseJSON.data.message);
|
2016-12-13 01:01:47 +00:00
|
|
|
$('label#uploadsymbol').addClass('icon-upload').removeClass('icon-loading-small');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$('#uploadsymbol').fileupload(uploadParamsSymbol);
|
|
|
|
$('body').on('click', 'button.delExtraSymbol', function(e) {
|
|
|
|
deleteLogo($(this));
|
|
|
|
});
|
|
|
|
|
2016-12-12 22:23:15 +00:00
|
|
|
});
|