chore: Add eslint prettier phpcs config PSR2
This commit is contained in:
parent
a53192beeb
commit
d30edb6749
10 changed files with 2417 additions and 297 deletions
3
.eslintignore
Normal file
3
.eslintignore
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
huebee.js
|
||||||
|
jquery-ui.min.js
|
||||||
|
bootstrap.js
|
13
.eslintrc
Normal file
13
.eslintrc
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"extends": ["airbnb-base", "prettier"],
|
||||||
|
"plugins": ["prettier"],
|
||||||
|
"rules": {
|
||||||
|
"prettier/prettier": ["error"]
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"browser": true
|
||||||
|
},
|
||||||
|
"globals": {
|
||||||
|
"$": true
|
||||||
|
}
|
||||||
|
}
|
1325
package-lock.json
generated
1325
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -7,10 +7,16 @@
|
||||||
"watch-poll": "mix watch -- --watch-options-poll=1000",
|
"watch-poll": "mix watch -- --watch-options-poll=1000",
|
||||||
"hot": "mix watch --hot",
|
"hot": "mix watch --hot",
|
||||||
"prod": "npm run production",
|
"prod": "npm run production",
|
||||||
"production": "mix --production"
|
"production": "mix --production",
|
||||||
|
"lint": "eslint 'resources/assets/js/*'"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bootstrap-sass": "^3.4.3",
|
"bootstrap-sass": "^3.4.3",
|
||||||
|
"eslint": "^8.28.0",
|
||||||
|
"eslint-config-airbnb-base": "^15.0.0",
|
||||||
|
"eslint-config-prettier": "^8.5.0",
|
||||||
|
"eslint-plugin-import": "^2.26.0",
|
||||||
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
"jquery": "^3.6.1",
|
"jquery": "^3.6.1",
|
||||||
"laravel-mix": "^6.0.49",
|
"laravel-mix": "^6.0.49",
|
||||||
"sass": "^1.56.1",
|
"sass": "^1.56.1",
|
||||||
|
|
23
phpcs.xml
Normal file
23
phpcs.xml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="PHP_CodeSniffer">
|
||||||
|
<description>The coding standard for our project.</description>
|
||||||
|
<rule ref="PSR2"/>
|
||||||
|
|
||||||
|
<file>app</file>
|
||||||
|
<file>bootstrap</file>
|
||||||
|
<file>config</file>
|
||||||
|
<file>database</file>
|
||||||
|
<file>resources</file>
|
||||||
|
<file>routes</file>
|
||||||
|
<file>tests</file>
|
||||||
|
|
||||||
|
<exclude-pattern>bootstrap/cache/*</exclude-pattern>
|
||||||
|
<exclude-pattern>bootstrap/autoload.php</exclude-pattern>
|
||||||
|
<exclude-pattern>*/migrations/*</exclude-pattern>
|
||||||
|
<exclude-pattern>*/seeds/*</exclude-pattern>
|
||||||
|
<exclude-pattern>*.blade.php</exclude-pattern>
|
||||||
|
<exclude-pattern>*.js</exclude-pattern>
|
||||||
|
|
||||||
|
<!-- Show progression -->
|
||||||
|
<arg value="p"/>
|
||||||
|
</ruleset>
|
2
public/js/app.js
vendored
2
public/js/app.js
vendored
File diff suppressed because one or more lines are too long
2
public/mix-manifest.json
generated
2
public/mix-manifest.json
generated
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"/css/app.css": "/css/app.css?id=9a25947db63214edd4e6f459200dfa62",
|
"/css/app.css": "/css/app.css?id=9a25947db63214edd4e6f459200dfa62",
|
||||||
"/js/app.js": "/js/app.js?id=b71fe417971ee1aaaaa84e3824221126"
|
"/js/app.js": "/js/app.js?id=894c631b0c521ca3e5df669b4220f77b"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,120 +1,122 @@
|
||||||
$.when( $.ready ).then(function() {
|
$.when($.ready).then(() => {
|
||||||
|
const base = (document.querySelector("base") || {}).href;
|
||||||
|
|
||||||
var base = (document.querySelector('base') || {}).href;
|
const itemID = $("form[data-item-id]").data("item-id");
|
||||||
|
const fakePassword = "*****";
|
||||||
|
|
||||||
var itemID = $('form[data-item-id]').data('item-id');
|
// If in edit mode and password field is present, fill it with stars
|
||||||
var fakePassword = '*****';
|
if (itemID) {
|
||||||
|
const passwordField = $('input[name="config[password]"]').first();
|
||||||
|
|
||||||
// If in edit mode and password field is present, fill it with stars
|
if (passwordField.length > 0) {
|
||||||
if (itemID) {
|
passwordField.attr("value", fakePassword);
|
||||||
var passwordField = $('input[name="config[password]"]').first();
|
|
||||||
|
|
||||||
if (passwordField.length > 0) {
|
|
||||||
passwordField.attr('value', fakePassword);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($('.message-container').length) {
|
if ($(".message-container").length) {
|
||||||
setTimeout(
|
setTimeout(() => {
|
||||||
function()
|
$(".message-container").fadeOut();
|
||||||
{
|
}, 3500);
|
||||||
$('.message-container').fadeOut();
|
}
|
||||||
}, 3500);
|
|
||||||
}
|
|
||||||
|
|
||||||
// from https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
|
// from https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
|
||||||
// Set the name of the hidden property and the change event for visibility
|
// Set the name of the hidden property and the change event for visibility
|
||||||
var hidden, visibilityChange;
|
let hidden;
|
||||||
if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support
|
let visibilityChange;
|
||||||
hidden = "hidden";
|
if (typeof document.hidden !== "undefined") {
|
||||||
visibilityChange = "visibilitychange";
|
// Opera 12.10 and Firefox 18 and later support
|
||||||
} else if (typeof document.msHidden !== "undefined") {
|
hidden = "hidden";
|
||||||
hidden = "msHidden";
|
visibilityChange = "visibilitychange";
|
||||||
visibilityChange = "msvisibilitychange";
|
} else if (typeof document.msHidden !== "undefined") {
|
||||||
} else if (typeof document.webkitHidden !== "undefined") {
|
hidden = "msHidden";
|
||||||
hidden = "webkitHidden";
|
visibilityChange = "msvisibilitychange";
|
||||||
visibilityChange = "webkitvisibilitychange";
|
} else if (typeof document.webkitHidden !== "undefined") {
|
||||||
}
|
hidden = "webkitHidden";
|
||||||
|
visibilityChange = "webkitvisibilitychange";
|
||||||
|
}
|
||||||
|
|
||||||
var livestatsRefreshTimeouts = [];
|
const livestatsRefreshTimeouts = [];
|
||||||
var livestatsFuncs = [];
|
const livestatsFuncs = [];
|
||||||
var livestatsContainers = $('.livestats-container');
|
const livestatsContainers = $(".livestats-container");
|
||||||
function stopLivestatsRefresh() {
|
function stopLivestatsRefresh() {
|
||||||
for (var timeoutId of livestatsRefreshTimeouts) {
|
livestatsRefreshTimeouts.forEach((timeoutId) => {
|
||||||
window.clearTimeout(timeoutId);
|
window.clearTimeout(timeoutId);
|
||||||
}
|
|
||||||
}
|
|
||||||
function startLivestatsRefresh() {
|
|
||||||
for (var fun of livestatsFuncs) {
|
|
||||||
fun();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (livestatsContainers.length > 0) {
|
|
||||||
if (typeof document.addEventListener === "undefined" || hidden === undefined) {
|
|
||||||
console.log("This browser does not support visibilityChange");
|
|
||||||
} else {
|
|
||||||
document.addEventListener(visibilityChange, function() {
|
|
||||||
if (document[hidden]) {
|
|
||||||
stopLivestatsRefresh();
|
|
||||||
} else {
|
|
||||||
startLivestatsRefresh();
|
|
||||||
}
|
|
||||||
}, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
livestatsContainers.each(function(index){
|
|
||||||
var id = $(this).data('id');
|
|
||||||
var dataonly = $(this).data('dataonly');
|
|
||||||
var increaseby = (dataonly == 1) ? 20000 : 1000;
|
|
||||||
var container = $(this);
|
|
||||||
var max_timer = 30000;
|
|
||||||
var timer = 5000;
|
|
||||||
var fun = function worker() {
|
|
||||||
$.ajax({
|
|
||||||
url: base+'get_stats/'+id,
|
|
||||||
dataType: 'json',
|
|
||||||
success: function(data) {
|
|
||||||
container.html(data.html);
|
|
||||||
if(data.status == 'active') timer = increaseby;
|
|
||||||
else {
|
|
||||||
if(timer < max_timer) timer += 2000;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
complete: function(jqXHR) {
|
|
||||||
if (jqXHR.status > 299) {
|
|
||||||
// Stop polling when we get errors
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Schedule the next request when the current one's complete
|
|
||||||
livestatsRefreshTimeouts[index] = window.setTimeout(worker, timer);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
livestatsFuncs[index] = fun;
|
|
||||||
fun();
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function readURL(input) {
|
|
||||||
|
|
||||||
if (input.files && input.files[0]) {
|
|
||||||
var reader = new FileReader();
|
|
||||||
|
|
||||||
reader.onload = function(e) {
|
|
||||||
$('#appimage img').attr('src', e.target.result);
|
|
||||||
};
|
|
||||||
|
|
||||||
reader.readAsDataURL(input.files[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#upload').change(function() {
|
|
||||||
readURL(this);
|
|
||||||
});
|
});
|
||||||
/*$(".droppable").droppable({
|
}
|
||||||
|
function startLivestatsRefresh() {
|
||||||
|
livestatsFuncs.forEach((fun) => {
|
||||||
|
fun();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (livestatsContainers.length > 0) {
|
||||||
|
if (
|
||||||
|
typeof document.addEventListener === "undefined" ||
|
||||||
|
hidden === undefined
|
||||||
|
) {
|
||||||
|
console.log("This browser does not support visibilityChange");
|
||||||
|
} else {
|
||||||
|
document.addEventListener(
|
||||||
|
visibilityChange,
|
||||||
|
() => {
|
||||||
|
if (document[hidden]) {
|
||||||
|
stopLivestatsRefresh();
|
||||||
|
} else {
|
||||||
|
startLivestatsRefresh();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
livestatsContainers.each(function (index) {
|
||||||
|
const id = $(this).data("id");
|
||||||
|
const dataonly = $(this).data("dataonly");
|
||||||
|
const increaseby = dataonly === 1 ? 20000 : 1000;
|
||||||
|
const container = $(this);
|
||||||
|
const maxTimer = 30000;
|
||||||
|
let timer = 5000;
|
||||||
|
const fun = function worker() {
|
||||||
|
$.ajax({
|
||||||
|
url: `${base}get_stats/${id}`,
|
||||||
|
dataType: "json",
|
||||||
|
success(data) {
|
||||||
|
container.html(data.html);
|
||||||
|
if (data.status === "active") timer = increaseby;
|
||||||
|
else if (timer < maxTimer) timer += 2000;
|
||||||
|
},
|
||||||
|
complete(jqXHR) {
|
||||||
|
if (jqXHR.status > 299) {
|
||||||
|
// Stop polling when we get errors
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schedule the next request when the current one's complete
|
||||||
|
livestatsRefreshTimeouts[index] = window.setTimeout(worker, timer);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
livestatsFuncs[index] = fun;
|
||||||
|
fun();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function readURL(input) {
|
||||||
|
if (input.files && input.files[0]) {
|
||||||
|
const reader = new FileReader();
|
||||||
|
|
||||||
|
reader.onload = function (e) {
|
||||||
|
$("#appimage img").attr("src", e.target.result);
|
||||||
|
};
|
||||||
|
|
||||||
|
reader.readAsDataURL(input.files[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#upload").change(function () {
|
||||||
|
readURL(this);
|
||||||
|
});
|
||||||
|
/* $(".droppable").droppable({
|
||||||
tolerance: "intersect",
|
tolerance: "intersect",
|
||||||
drop: function( event, ui ) {
|
drop: function( event, ui ) {
|
||||||
var tag = $( this ).data('id');
|
var tag = $( this ).data('id');
|
||||||
|
@ -129,153 +131,160 @@ $.when( $.ready ).then(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});*/
|
}); */
|
||||||
|
|
||||||
$( '#sortable' ).sortable({
|
$("#sortable").sortable({
|
||||||
stop: function (event, ui) {
|
stop() {
|
||||||
var idsInOrder = $('#sortable').sortable('toArray', {
|
const idsInOrder = $("#sortable").sortable("toArray", {
|
||||||
attribute: 'data-id'
|
attribute: "data-id",
|
||||||
});
|
});
|
||||||
$.post(
|
$.post(`${base}order`, { order: idsInOrder });
|
||||||
base+'order',
|
},
|
||||||
{ order:idsInOrder }
|
});
|
||||||
);
|
$("#sortable").sortable("disable");
|
||||||
}
|
|
||||||
|
|
||||||
});
|
$("#main")
|
||||||
$('#sortable').sortable('disable');
|
.on("mouseenter", "#sortable.ui-sortable-disabled .item", function () {
|
||||||
|
$(this).siblings(".tooltip").addClass("active");
|
||||||
$('#main').on('mouseenter', '#sortable.ui-sortable-disabled .item', function () {
|
$(".refresh", this).addClass("active");
|
||||||
$(this).siblings('.tooltip').addClass('active')
|
|
||||||
$('.refresh', this).addClass('active')
|
|
||||||
}).on('mouseleave', '.item', function () {
|
|
||||||
$(this).siblings('.tooltip').removeClass('active')
|
|
||||||
$('.refresh', this).removeClass('active')
|
|
||||||
})
|
})
|
||||||
$('#config-buttons').on('mouseenter', 'a', function () {
|
.on("mouseleave", ".item", function () {
|
||||||
$('.tooltip', this).addClass('active');
|
$(this).siblings(".tooltip").removeClass("active");
|
||||||
}).on('mouseleave', 'a', function () {
|
$(".refresh", this).removeClass("active");
|
||||||
$('.tooltip', this).removeClass('active');
|
});
|
||||||
|
$("#config-buttons")
|
||||||
|
.on("mouseenter", "a", function () {
|
||||||
|
$(".tooltip", this).addClass("active");
|
||||||
})
|
})
|
||||||
|
.on("mouseleave", "a", function () {
|
||||||
$('.searchform > form').on('submit', function (event) {
|
$(".tooltip", this).removeClass("active");
|
||||||
if ($('#search-container select[name=provider]').val() === 'tiles') {
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#search-container').on('input', 'input[name=q]', function () {
|
$(".searchform > form").on("submit", (event) => {
|
||||||
const search = this.value
|
if ($("#search-container select[name=provider]").val() === "tiles") {
|
||||||
const items = $('#sortable').children('.item-container')
|
event.preventDefault();
|
||||||
if($('#search-container select[name=provider]').val() === 'tiles') {
|
}
|
||||||
if(search.length > 0) {
|
});
|
||||||
items.hide()
|
|
||||||
items.filter(function () {
|
$("#search-container")
|
||||||
const name = $(this).data('name').toLowerCase();
|
.on("input", "input[name=q]", function () {
|
||||||
return name.includes(search.toLowerCase())
|
const search = this.value;
|
||||||
}).show()
|
const items = $("#sortable").children(".item-container");
|
||||||
} else {
|
if ($("#search-container select[name=provider]").val() === "tiles") {
|
||||||
items.show()
|
if (search.length > 0) {
|
||||||
}
|
items.hide();
|
||||||
|
items
|
||||||
|
.filter(function () {
|
||||||
|
const name = $(this).data("name").toLowerCase();
|
||||||
|
return name.includes(search.toLowerCase());
|
||||||
|
})
|
||||||
|
.show();
|
||||||
} else {
|
} else {
|
||||||
items.show()
|
items.show();
|
||||||
}
|
|
||||||
}).on('change', 'select[name=provider]', function () {
|
|
||||||
const items = $('#sortable').children('.item-container')
|
|
||||||
if($(this).val() === 'tiles') {
|
|
||||||
$('#search-container button').hide()
|
|
||||||
const search = $('#search-container input[name=q]').val()
|
|
||||||
if(search.length > 0) {
|
|
||||||
items.hide()
|
|
||||||
items.filter(function () {
|
|
||||||
const name = $(this).data('name').toLowerCase();
|
|
||||||
return name.includes(search.toLowerCase())
|
|
||||||
}).show()
|
|
||||||
} else {
|
|
||||||
items.show()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$('#search-container button').show()
|
|
||||||
items.show()
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
items.show();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
.on("change", "select[name=provider]", function () {
|
||||||
$('#app').on('click', '#config-button', function(e) {
|
const items = $("#sortable").children(".item-container");
|
||||||
e.preventDefault();
|
if ($(this).val() === "tiles") {
|
||||||
var app = $('#app');
|
$("#search-container button").hide();
|
||||||
var active = (app.hasClass('header'));
|
const search = $("#search-container input[name=q]").val();
|
||||||
app.toggleClass('header');
|
if (search.length > 0) {
|
||||||
if(active) {
|
items.hide();
|
||||||
$('.add-item').hide();
|
items
|
||||||
$('.item-edit').hide();
|
.filter(function () {
|
||||||
$('#app').removeClass('sidebar');
|
const name = $(this).data("name").toLowerCase();
|
||||||
$('#sortable .tooltip').css('display', '')
|
return name.includes(search.toLowerCase());
|
||||||
$('#sortable').sortable('disable');
|
})
|
||||||
|
.show();
|
||||||
} else {
|
} else {
|
||||||
$('#sortable .tooltip').css('display', 'none')
|
items.show();
|
||||||
$('#sortable').sortable('enable');
|
|
||||||
setTimeout(function() {
|
|
||||||
$('.add-item').fadeIn();
|
|
||||||
$('.item-edit').fadeIn();
|
|
||||||
}, 350);
|
|
||||||
|
|
||||||
}
|
|
||||||
}).on('click', '#add-item, #pin-item', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var app = $('#app');
|
|
||||||
var active = (app.hasClass('sidebar'));
|
|
||||||
app.toggleClass('sidebar');
|
|
||||||
|
|
||||||
}).on('click', '.close-sidenav', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var app = $('#app');
|
|
||||||
app.removeClass('sidebar');
|
|
||||||
|
|
||||||
}).on('click', '#test_config', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var apiurl = $('#create input[name=url]').val();
|
|
||||||
|
|
||||||
var override_url = $('#sapconfig input[name="config[override_url]"]').val();
|
|
||||||
if(override_url.length && override_url != '') {
|
|
||||||
apiurl = override_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = {};
|
|
||||||
data['url'] = apiurl;
|
|
||||||
$('.config-item').each(function(index){
|
|
||||||
var config = $(this).data('config');
|
|
||||||
data[config] = $(this).val();
|
|
||||||
});
|
|
||||||
|
|
||||||
data['id'] = $('form[data-item-id]').data('item-id');
|
|
||||||
|
|
||||||
if (data.password && data.password === fakePassword) {
|
|
||||||
data.password = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$.post(base+'test_config', { data: data }, function(data) {
|
|
||||||
alert(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
$('#pinlist').on('click', 'a', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var current = $(this);
|
|
||||||
var id = current.data('id');
|
|
||||||
var tag = current.data('tag');
|
|
||||||
$.get(base+'items/pintoggle/'+id+'/true/'+tag, function(data) {
|
|
||||||
var inner = $(data).filter('#sortable').html();
|
|
||||||
$('#sortable').html(inner);
|
|
||||||
current.toggleClass('active');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
$('#itemform').on('submit', function(e) {
|
|
||||||
var passwordField = $('input[name="config[password]"]').first();
|
|
||||||
if (passwordField.length > 0) {
|
|
||||||
if (passwordField.attr('value') === fakePassword) {
|
|
||||||
passwordField.attr('value', '');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$("#search-container button").show();
|
||||||
|
items.show();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#app")
|
||||||
|
.on("click", "#config-button", (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const app = $("#app");
|
||||||
|
const active = app.hasClass("header");
|
||||||
|
app.toggleClass("header");
|
||||||
|
if (active) {
|
||||||
|
$(".add-item").hide();
|
||||||
|
$(".item-edit").hide();
|
||||||
|
$("#app").removeClass("sidebar");
|
||||||
|
$("#sortable .tooltip").css("display", "");
|
||||||
|
$("#sortable").sortable("disable");
|
||||||
|
} else {
|
||||||
|
$("#sortable .tooltip").css("display", "none");
|
||||||
|
$("#sortable").sortable("enable");
|
||||||
|
setTimeout(() => {
|
||||||
|
$(".add-item").fadeIn();
|
||||||
|
$(".item-edit").fadeIn();
|
||||||
|
}, 350);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on("click", "#add-item, #pin-item", (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const app = $("#app");
|
||||||
|
// const active = app.hasClass("sidebar");
|
||||||
|
app.toggleClass("sidebar");
|
||||||
|
})
|
||||||
|
.on("click", ".close-sidenav", (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const app = $("#app");
|
||||||
|
app.removeClass("sidebar");
|
||||||
|
})
|
||||||
|
.on("click", "#test_config", (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
let apiurl = $("#create input[name=url]").val();
|
||||||
|
|
||||||
|
const overrideUrl = $(
|
||||||
|
'#sapconfig input[name="config[override_url]"]'
|
||||||
|
).val();
|
||||||
|
if (overrideUrl.length && overrideUrl !== "") {
|
||||||
|
apiurl = overrideUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = {};
|
||||||
|
data.url = apiurl;
|
||||||
|
$(".config-item").each(function () {
|
||||||
|
const config = $(this).data("config");
|
||||||
|
data[config] = $(this).val();
|
||||||
|
});
|
||||||
|
|
||||||
|
data.id = $("form[data-item-id]").data("item-id");
|
||||||
|
|
||||||
|
if (data.password && data.password === fakePassword) {
|
||||||
|
data.password = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
$.post(`${base}test_config`, { data }, (responseData) => {
|
||||||
|
alert(responseData);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$("#pinlist").on("click", "a", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const current = $(this);
|
||||||
|
const id = current.data("id");
|
||||||
|
const tag = current.data("tag");
|
||||||
|
$.get(`${base}items/pintoggle/${id}/true/${tag}`, (data) => {
|
||||||
|
const inner = $(data).filter("#sortable").html();
|
||||||
|
$("#sortable").html(inner);
|
||||||
|
current.toggleClass("active");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$("#itemform").on("submit", () => {
|
||||||
|
const passwordField = $('input[name="config[password]"]').first();
|
||||||
|
if (passwordField.length > 0) {
|
||||||
|
if (passwordField.attr("value") === fakePassword) {
|
||||||
|
passwordField.attr("value", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
61
resources/assets/js/keyBindings.js
vendored
61
resources/assets/js/keyBindings.js
vendored
|
@ -1,38 +1,45 @@
|
||||||
const focusSearch = event => {
|
const focusSearch = (event) => {
|
||||||
const searchInput = document.querySelector('input[name="q"]');
|
const searchInput = document.querySelector('input[name="q"]');
|
||||||
if (searchInput) {
|
if (searchInput) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
searchInput.focus();
|
searchInput.focus();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const openFirstNonHiddenItem = event => {
|
const openFirstNonHiddenItem = (event) => {
|
||||||
if (event.target !== document.querySelector('input[name="q"]')) {
|
if (event.target !== document.querySelector('input[name="q"]')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document.querySelector('#search-container select[name=provider]').value !== 'tiles') {
|
const providerSelect = document.querySelector(
|
||||||
return;
|
"#search-container select[name=provider]"
|
||||||
}
|
);
|
||||||
|
|
||||||
const item = document.querySelector('#sortable section.item-container:not([style="display: none;"]) a');
|
if (providerSelect.value !== "tiles") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ('href' in item) {
|
const item = document.querySelector(
|
||||||
event.preventDefault();
|
'#sortable section.item-container:not([style="display: none;"]) a'
|
||||||
window.open(item.href);
|
);
|
||||||
}
|
|
||||||
|
if ("href" in item) {
|
||||||
|
event.preventDefault();
|
||||||
|
window.open(item.href);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const KEY_BINDINGS = {
|
const KEY_BINDINGS = {
|
||||||
'/': focusSearch,
|
"/": focusSearch,
|
||||||
'Enter': openFirstNonHiddenItem
|
Enter: openFirstNonHiddenItem,
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener('keydown', function (event) {
|
document.addEventListener("keydown", (event) => {
|
||||||
try {
|
try {
|
||||||
if (event.key in KEY_BINDINGS) {
|
if (event.key in KEY_BINDINGS) {
|
||||||
KEY_BINDINGS[event.key](event);
|
KEY_BINDINGS[event.key](event);
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
}
|
}
|
||||||
});
|
} catch (e) {
|
||||||
|
// Nothing to do
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue