Skip to content
Snippets Groups Projects
Commit 53dd96c6 authored by RANWEZ Pierre's avatar RANWEZ Pierre :anchor:
Browse files

:sparkles: feat: midi learn on focused, cleaning useless code

parent 69206c50
No related branches found
No related tags found
1 merge request!1✨ feat: CSSLSD V2
......@@ -137,7 +137,9 @@ function analyseAll() {
var all = [];
var parser = new CSSParser();
var sheet = parser.parse(result.css, false, false);
if (sheet.cssRules.length > 0) {
sheet.cssRules.forEach(element => {
if (element.declarations.length > 0) {
element.declarations.forEach(css => {
var templates = [];
cssValue = css.valueText;
......@@ -235,7 +237,9 @@ function analyseAll() {
templates: templates
});
});
}
});
}
chrome.storage.sync.set({ all: all });
});
}
......@@ -305,8 +309,10 @@ function onMessage({ type, data }) {
case 'midiEvent': {
if (dataMidi != data) {
$('#midiEvent').text(data);
if (editor.isFocused()) {
editor.session.insert(editor.getCursorPosition(), data)
var focusedTd = $('[contenteditable]:focus');
var focusedCol = $(focusedTd).index('#parameters tr:eq(' + $(focusedTd).parent().index('#parameters tr') + ') td');
if (focusedTd.length > 0 && focusedCol == 4) {
focused.text(focused.text() + ' ' + data);
}
dataMidi = data;
}
......@@ -326,61 +332,11 @@ function onMessage({ type, data }) {
}
}
$(document).keydown(function (event) {
// If Control or Command key is pressed and the S key is pressed
// run save function. 83 is the key code for S.
if ((event.ctrlKey || event.metaKey) && event.which == 83) {
// Save Function
event.preventDefault();
updateCss();
return false;
}
}
);
$(document).keydown(function (event) {
// If Control or Command key is pressed and the S key is pressed
// run save function. 83 is the key code for S.
if ((event.ctrlKey || event.metaKey) && event.which == 79) {
// Save Function
event.preventDefault();
activateButton = !activateButton;
chrome.storage.sync.set({ activate: activateButton }, function () {
if (activateButton) {
$('#onOff').text('Désactiver');
var API = chrome || browser;
API.tabs.query({ active: true, currentWindow: true }, function (tabs) {
if (tabs[0] && tabs[0].favIconUrl) {
chrome.storage.sync.set({ activateFav: tabs[0].favIconUrl });
}
});
} else {
$('#onOff').text('Activer');
}
chrome.tabs.query({ active: true, currentWindow: true },
function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, { type: 'start', data: activateButton });
}
);
});
return false;
}
}
);
$('#onOff').on('click', function () {
activateButton = !activateButton;
chrome.storage.sync.set({ activate: activateButton }, function () {
if (activateButton) {
$('#onOff').addClass('active');
var API = chrome || browser;
API.tabs.query({ active: true, currentWindow: true }, function (tabs) {
if (tabs[0] && tabs[0].favIconUrl) {
chrome.storage.sync.set({ activateFav: tabs[0].favIconUrl });
}
});
} else {
$('#onOff').removeClass('active');
}
......@@ -479,7 +435,6 @@ $(document).on('click', '.icon-tabler-minus', function () {
// Wait messages from content script
chrome.runtime.onMessage.addListener(onMessage);
// Indicate to Background that the popup is ready
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment