Skip to content

Commit

Permalink
Fix js lint warnings and bug, update manifest, add ugly icons
Browse files Browse the repository at this point in the history
  • Loading branch information
imightbeamy committed Apr 29, 2014
1 parent c5addfd commit f26923c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
50 changes: 27 additions & 23 deletions events.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
function EventMerger (key_function, clean_up_function) {
'use strict';

function EventMerger(key_function, clean_up_function) {
this.makeKey = key_function;
this.cleanUp = clean_up_function;
}

EventMerger.prototype = {
getEventSets: function($events) {
var event_sets = {},
getEventSets: function ($events) {
var event_sets = {},
makeKey = this.makeKey;
$events.each(function() {
var $event = $(this),
key = makeKey($event).replace(/\s/g,'');
event_sets[key] = event_sets[key] || [];
event_sets[key].push($event);
});
return event_sets;
$events.each(function () {
var $event = $(this),
key = makeKey($event).replace(/\s/g, '');
event_sets[key] = event_sets[key] || [];
event_sets[key].push($event);
});
return event_sets;
},
makeStripes: function (colors) {
var gradient = "repeating-linear-gradient( 45deg,",
pos = 0;
$.each(colors, function(i, c) {
$.each(colors, function (i, c) {
gradient += c + " " + pos + "px,";
pos+=10;
pos += 10;
gradient += c + " " + pos + "px,";
})
});
gradient = gradient.slice(0, -1);
gradient += ")"
gradient += ")";
return gradient;
},
mergeEvents: function (name, event_set) {
if (event_set.length > 1) {
var colors = $.map(event_set, function(event) {
var colors = $.map(event_set, function (event) {
return $(event).css('background-color');
});

var keep = event_set.shift();
$(event_set).each(function() {$(this).remove()});
$(event_set).each(function () {
$(this).parent().remove();
});

keep.css('background-image', this.makeStripes(colors));
this.cleanUp(keep);
Expand All @@ -47,21 +52,20 @@ EventMerger.prototype = {

/*****************************************************************************/

function eventKey ($event) {
function eventKey($event) {
var event_name = $event.find('dd span').text(),
event_time = $event.find('dt').text(),
col = $event.parents('.tg-col-eventwrapper').attr('id');
return event_name + event_time + col;
}

function cleanUp ($event) {
function cleanUp($event) {
var chip = $event.parents('.chip'),
left = Number(chip.css('left').replace(/[%px]*/g,''));
left = Number(chip.css('left').replace(/[%px]*/g, ''));
chip.css('width', 100 - left + "%");
$event.parents('td').find('.chip-border').remove();
}

merger = new EventMerger(eventKey, cleanUp);
$(document).on("DOMNodeInserted", ".tg-mainwrapper", function(e) {
var merger = new EventMerger(eventKey, cleanUp);
$(document).on("DOMNodeInserted", ".tg-mainwrapper", function () {
merger.mergeSets($('dl'));
});
});
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Google Caladar Mulit-Cal Even Merge",
"name": "Google Calendar Event Merge",
"description": "Chrome extension that visually merges the same event on multiple Google Calendars into one event with stripes.",
"version": "0.1",
"version": "1.0",
"content_scripts": [ {
"matches": [
"http://*/*",
Expand All @@ -14,5 +14,7 @@
"permissions": [
"https://www.google.com/calendar/*"
],
"icons": { "48": "icon48.png",
"128": "icon128.png" },
"manifest_version": 2
}

0 comments on commit f26923c

Please sign in to comment.