Skip to content

Instantly share code, notes, and snippets.

@brantwedel
Created March 20, 2017 16:05
Show Gist options
  • Save brantwedel/d028c1bdf1acb34bb00d702913d948b3 to your computer and use it in GitHub Desktop.
Save brantwedel/d028c1bdf1acb34bb00d702913d948b3 to your computer and use it in GitHub Desktop.
Script for adding select-all functionality to jscut.org using tampermonkey.net browser plugin
// ==UserScript==
// @name JSCUT Select All
// @namespace http://bitbased.net/
// @version 0.1
// @description Add double click select all to jscut.org
// @author Brant Wedel - bitbased.net
// @match http://jscut.org/jscut.html
// @grant none
// ==/UserScript==
(function() {
'use strict';
$("#MainSvg").off('click');
$("#MainSvg").click(function (e) {
// Ignore double click
if (e.originalEvent.detail > 1)
return;
var element = Snap.getElementByPoint(e.pageX, e.pageY);
if (element !== null) {
operationsViewModel.clickOnSvg(element) || tabsViewModel.clickOnSvg(element) || selectionViewModel.clickOnSvg(element);
if (selectionViewModel.selNumSelected() > 0) {
tutorial(3, 'Click "Create Operation" after you have finished selecting objects.');
}
}
});
$("#MainSvg").dblclick(function (e) {
// Toggle select all
if (selectionViewModel.selNumSelected() > 1) {
selectionViewModel.clearSelection();
return;
}
var selectedPaths = mainSvg.selectAll('path');
if (selectedPaths.length > 0) {
selectedPaths.forEach(function (element) {
if (element.attr("class") != "selectedPath") {
operationsViewModel.clickOnSvg(element) || tabsViewModel.clickOnSvg(element) || selectionViewModel.clickOnSvg(element);
}
});
if (selectionViewModel.selNumSelected() > 0) {
tutorial(3, 'Click "Create Operation" after you have finished selecting objects.');
}
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment