Todoist Plus

Todoist.com adding right fixed panel for tasks multiselect

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name Todoist Plus
// @description Todoist.com adding right fixed panel for tasks multiselect
// @author DeTorres
// @version 0.1.2
// @date 2015-08-13
// @namespace https://todoist.com/app
// @match https://todoist.com/app*
// @license MIT License
// ==/UserScript==

var script = document.createElement('script');

script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js';
document.getElementsByTagName('head')[0].appendChild(script);

script.addEventListener('load', function(){
	jQuery = unsafeWindow['jQuery'];
	jQuery.noConflict();
	jQuery(document).ready(function() {
		var newStyle = "<style>" +
				"#my_panel {height:180px; line-height:30px; position:fixed; width:100px; padding:10px; top:40px; right:25px;text-align:right; border: 1px dotted black; background-color:#f2f2f2; margin:10px 0;} " +
		"</style>";
	
		jQuery('html head').append(newStyle);
		
		jQuery("body").prepend("<div id='my_panel'>" + 
			"Выделить:<br />" + 
			"<label><span style='color:green'>все (all)</span><input id='my_all_checker' type='checkbox' value='1' /> </label><br />" + 
			"<label><span>прозрачные</span><input id='my_transparent_checker' type='checkbox' value='1' /></label><br />" +
			"<label><span style='color:#64a8d9'>голубые</span> <input id='my_light_blue_checker' type='checkbox' value='1' /></label><br />" +
			"<label><span style='color:#0063a6'>синие</span> <input id='my_blue_checker' type='checkbox' value='1' /></label><br />" +
			"<label><span style='color:#d24726'>красные</span> <input id='my_red_checker' type='checkbox' value='1' /></label>" +
		"</div>");
		
		var getTasksByPriority = function(priority){
			var priorities = ["", "priority_1", "priority_2", "priority_3", "priority_4" ];
			var tasksSelector = ".items li.task_item";
			if(priority){
				tasksSelector += "." + priorities[priority];
			}
			return jQuery(tasksSelector);
		}
		
		var selectTasksAndTriggerMousedown = function(tasks){
			if( tasks.size() ) {
				var shiftClick = jQuery.Event("mousedown");
				shiftClick.shiftKey = true;
				
				tasks.toggleClass('selected');
				
				var firstElem = tasks.get(0);
				jQuery(firstElem).toggleClass('selected').trigger(shiftClick);
			}
			
			return true;
		}
		
		
		jQuery('input#my_transparent_checker').on("click", function() {
			selectTasksAndTriggerMousedown( getTasksByPriority(1) );
		});
		
		jQuery('input#my_light_blue_checker').on("click", function() {
			selectTasksAndTriggerMousedown( getTasksByPriority(2) );
		});
		
		jQuery('input#my_blue_checker').on("click", function() {
			selectTasksAndTriggerMousedown( getTasksByPriority(3) );
		});
		
		jQuery('input#my_red_checker').on("click", function() {
			selectTasksAndTriggerMousedown( getTasksByPriority(4) );
		});
		
		jQuery('input#my_all_checker').on("click", function() {
			selectTasksAndTriggerMousedown( getTasksByPriority(0) );
		});
    });
}, false);