Skip to content

Commit

Permalink
3.3.5
Browse files Browse the repository at this point in the history
Many changes since last github commit. see official 3.3.X change logs.
  • Loading branch information
zmandel committed Sep 8, 2015
1 parent 99cc0a2 commit d9bd228
Show file tree
Hide file tree
Showing 28 changed files with 1,210 additions and 493 deletions.
5 changes: 3 additions & 2 deletions License.txt
@@ -1,2 +1,3 @@
Plus for Trello, both the chrome extension and mobile app (the "software") is open source, licenced under the GNU GENERAL PUBLIC LICENSE, http://www.gnu.org/licenses/gpl-3.0.txt
Copyright (c) 2013 Zig Mandel <zmandel@gmail.com>
"Plus for Trello", both the browser extension and mobile app (the "software") is open source, licenced under the GNU GENERAL PUBLIC LICENSE, http://www.gnu.org/licenses/gpl-3.0.txt
Copyright (c) 2013 Zig Mandel <zmandel@gmail.com>
For licences of components that Plus uses (desktop and mobile) see http://plusfortrello.com/p/licences.html
3 changes: 0 additions & 3 deletions source/License.txt

This file was deleted.

21 changes: 4 additions & 17 deletions source/app.js
Expand Up @@ -186,22 +186,7 @@ $(function () {

//http://tablesorter.com/docs/example-parsers.html
//http://stackoverflow.com/a/2129479/2213940
if (true) {
$.tablesorter.addParser({
// set a unique id
id: 'links',
is: function (s) {
// return false so this parser is not auto detected
return false;
},
format: function (s) {
// format your data for normalization
return s.replace(new RegExp(/<.*?>/), "");
},
// set type, either numeric or text
type: 'text'
});
}
addTableSorterParsers();
loadOptions(function () {
entryPoint();
});
Expand Down Expand Up @@ -279,7 +264,9 @@ function loadOptions(callback) {
}

function doAllUpdates() {
markForUpdate();
markForUpdate();
if (isPlusDisplayDisabled())
return;
addCardCommentHelp();
}

Expand Down
28 changes: 23 additions & 5 deletions source/background.js
@@ -1,6 +1,5 @@
/// <reference path="intellisense.js" />


var g_dataTotalSpentThisWeek = { str: null, weeknum: null };
var g_msSyncRateLimit = 1000 * 1; //1 second (used to be larger and more relevant back when syncing on spreadsheets with my developer key
var MSDELAY_FIRSTSYNC = 500;
Expand Down Expand Up @@ -521,14 +520,20 @@ var g_dataSyncLast = { stage: "", ms: 0 }; //to avoid spamming tooltip update
var g_animationFrames = 18;
var g_msAnimationSpeed = 17;
var g_rotation = 0;
var g_bHilitePlusIcon = false;

function ease(x) {
return (1 - Math.sin(Math.PI / 2 + x * Math.PI)) / 2;
}

function animateFlip() {
if (true) { //review zig: temporarily stopped until rotation is fixed
g_bHilitePlusIcon = true;
updatePlusIcon(false);
setTimeout(function () {
g_bHilitePlusIcon = false;
updatePlusIcon(false);
}, 600);
return;
}

Expand All @@ -554,9 +559,16 @@ function animateFlip() {
worker();
}


function updatePlusIcon(bTooltipOnly) {
setTimeout(function () {
updatePlusIconWorker(bTooltipOnly); //review zig: ugly workarround because code sets storage props and inmediately calls updatePlusIcon
}, 100);
}

function updatePlusIconWorker(bTooltipOnly) {
bTooltipOnly = bTooltipOnly || false;
if (g_bLastPlusMenuIconError)
bTooltipOnly = false; //force it
var keyLastSync = "rowidLastHistorySynced";
var keyLastSyncViewed = "rowidLastHistorySyncedViewed";
var key_plus_datesync_last = "plus_datesync_last";
Expand Down Expand Up @@ -587,9 +599,12 @@ function updatePlusIcon(bTooltipOnly) {
bNew = true;
var strBase = "images/icon19";
if (bNew) {
strBase += "New";
strBase += "new";
}

if (g_bHilitePlusIcon)
strBase = "images/icon19hilite";

//returns false if there is no sync error
function setTooltipSyncStatus() {
var tooltip = "Plus for Trello\n";
Expand Down Expand Up @@ -1048,8 +1063,11 @@ function doShowTimerWindow(idCard) {
}
else {
g_mapTimerWindows[idCard] = window.id;
if (!window.alwaysOnTop)
chrome.windows.update(window.id, { height: window.height + 12 }); //grow to show panel enabling instructions
if (!window.alwaysOnTop) {
var heightNew = window.height + 12; //for the line showing panel instructions
var widthNew = window.width + 40; //some OSs (win10) need more space for the max/restore/min win buttons
chrome.windows.update(window.id, { height: heightNew, width: widthNew }); //grow to show panel enabling instructions
}
}
}
});
Expand Down
138 changes: 73 additions & 65 deletions source/board.js
Expand Up @@ -103,55 +103,51 @@ function updateCardsWorker(boardCur, responseParam, bShowBoardTotals, defaultSE,
var hashtags = [];
var bCardIsVisible = false;

//note: the "partx" functions are here to more easily detect performance issues using chrome profiling
function updateTitle() {

function part1() {
originalTitleTag = Card.titleTag(card);
function isElemVisible(elem) {
return (!$(elem).hasClass("hide")); //note: changed from using jquery visibility method, which eventually reads a width/height and strangely takes a long time in chrome
}

bCardIsVisible = isElemVisible(card);
updateTotals = (!g_bCheckedbSumFiltered || bCardIsVisible);
if (!updateTotals)
bFilteredCard = true;

if (!bCardIsVisible)
bHasHiddenCard = true;

function bUpdateTitle() {
originalTitleTag = Card.titleTag(card);
if (originalTitleTag.length == 0) {
bResetHtmlLast = true;
return false;
}

function part2() {
if (g_bChangeCardColor)
LabelsManager.update($(card));
//
// Get the estimated scrum units
//
var nodeTitle = originalTitleTag.contents().filter(function () {
return this.nodeType == 3;
});
if (nodeTitle && nodeTitle.length > 0)
title = nodeTitle[0].nodeValue;
else {
title = ""; //hack. some cases e.g. user moving the card while this runs, returns no node
bResetHtmlLast = true;
}
function isElemVisible(elem) {
return (!$(elem).hasClass("hide")); //note: changed from using jquery visibility method, which eventually reads a width/height and strangely takes a long time in chrome
}

part1();
part2();
bCardIsVisible = isElemVisible(card);
updateTotals = (!g_bCheckedbSumFiltered || bCardIsVisible);
if (!updateTotals)
bFilteredCard = true;

if (!bCardIsVisible)
bHasHiddenCard = true;

if (g_bChangeCardColor)
LabelsManager.update($(card));

var nodeTitle = originalTitleTag.contents().filter(function () { //this method covers cases when trello changes the html
return this.nodeType == 3;
});
if (nodeTitle && nodeTitle.length > 0)
title = nodeTitle[0].nodeValue;
else {
title = ""; //hack. some cases e.g. user moving the card while this runs, returns no node
bResetHtmlLast = true;
return false;
}
return true;
}


function updateSE() {
if (title == "") { //special case when couldnt parse it
if (title == "" || idCardCur==null) { //special case when couldnt parse it
estimation = 0;
spent = 0;
hashtags = [];
return;
}

var idCardCur = getIdCardFromUrl(originalTitleTag[0].href);
var se = parseSE(title, false, g_bAcceptSFT);
var seFromDb = mapIdCardToSE[idCardCur];

Expand Down Expand Up @@ -181,7 +177,7 @@ function updateCardsWorker(boardCur, responseParam, bShowBoardTotals, defaultSE,
// Show a title w/o the markup
//

var bRecurring = (se.titleNoSE.indexOf(TAG_RECURRING_CARD) >= 0);
bRecurring = (se.titleNoSE.indexOf(TAG_RECURRING_CARD) >= 0);
var cloneTitleTag = null;
var originalTitleSiblings = originalTitleTag.siblings('a.agile_clone_title');
if (originalTitleSiblings.size() == 0) {
Expand All @@ -193,41 +189,23 @@ function updateCardsWorker(boardCur, responseParam, bShowBoardTotals, defaultSE,
cloneTitleTag = originalTitleSiblings.eq(0);
}

var elRecurring = cloneTitleTag.children(".agile_recurring");

if (idCardCur && bCardIsVisible) {
var hashTimer = getCardTimerSyncHash(idCardCur);
rgKeysTimers.push(hashTimer);
mapKeysTimersData[hashTimer] = { titleTag: cloneTitleTag, idCard: idCardCur };
}

var cleanTitle = se.titleNoSE;
if (bRecurring) {
if (bRecurring)
cleanTitle = cleanTitle.replace(/\[R\]/g, "");
if (elRecurring.length != 0)
elRecurring.show();
else {
var imgRecurring = $("<img>").attr("src", chrome.extension.getURL("images/recurring.png"));
imgRecurring.attr("title", TAG_RECURRING_CARD);
var spanRecurring = $("<span>").addClass("agile_recurring");
spanRecurring.append(imgRecurring);
cloneTitleTag.append(spanRecurring);
}
}
else {
if (elRecurring.length != 0)
elRecurring.hide();
}


var ctlUpdate = cloneTitleTag.contents()[1];
var ctlUpdate = cloneTitleTag[0];
if (ctlUpdate !== undefined)
ctlUpdate.textContent = cleanTitle;
ctlUpdate.text = cleanTitle;
else {
var test = 1; //for breakpoint
}
}

updateTitle();
if (!bUpdateTitle())
return;
var idCardCur=getIdCardFromUrl(originalTitleTag[0].href);
var bRecurring = false;
updateSE();

//
Expand Down Expand Up @@ -270,6 +248,24 @@ function updateCardsWorker(boardCur, responseParam, bShowBoardTotals, defaultSE,
if (!bNoBadges)
spentBadge.contents().last()[0].textContent = spent;

//Recurring
if (true) {
//always create so it maintains order respect to s/e and stuff to the right
var elRecurring = badges.children(".agile_recurring");
if (elRecurring.length == 0) {
var imgRecurring = $("<img class='agile_image_recurring_back'>").attr("src", chrome.extension.getURL("images/recurring.png"));
imgRecurring.attr("title", "Recurring card");
var spanRecurring = $("<span>").addClass("agile_recurring");
spanRecurring.append(imgRecurring);
badges.append(spanRecurring);
}

if (bRecurring)
elRecurring.show();
else
elRecurring.hide();
}

// Hashtags
var hashtagsJq = badges.children('.agile_hashtags');
if (hashtagsJq.length == 0) {
Expand All @@ -287,6 +283,12 @@ function updateCardsWorker(boardCur, responseParam, bShowBoardTotals, defaultSE,
if (hashLoop.indexOf("!") >= 0)
spanLoop.addClass("agile_badge_hashtag_shout");
}

if (idCardCur && bCardIsVisible) {
var hashTimer = getCardTimerSyncHash(idCardCur);
rgKeysTimers.push(hashTimer);
mapKeysTimersData[hashTimer] = { titleTag: badges, idCard: idCardCur };
}
}

//
Expand Down Expand Up @@ -435,6 +437,10 @@ function updateWorker(bShowBoardTotals) {
updateNewTrelloFlag();
HelpButton.display();
InfoBoxManager.update();

if (isPlusDisplayDisabled())
return;

if (!g_bForceUpdate && isTimerRunningOnScreen())
return;

Expand Down Expand Up @@ -476,6 +482,8 @@ function removeTimerForCard(idCardParsed) {
}

function updateCards(boardCur, responseParam, bShowBoardTotals, bRecalcAgedCards) {
if (isPlusDisplayDisabled())
return;
if (bRecalcAgedCards === undefined)
bRecalcAgedCards = true;

Expand Down Expand Up @@ -586,15 +594,15 @@ function setUpdatingGlobalSums(boardCur, bUpdating) {
}
}

function processCardTimerIcon(stored, cloneTitleTag, idCard, stateLoop) {
var imgTimer = cloneTitleTag.find('.agile_timer_icon_small');
function processCardTimerIcon(stored, container, idCard, stateLoop) {
var imgTimer = container.find('.agile_timer_icon_small');
if (stored !== undefined && stored.msEnd == null) { //show
if (imgTimer.length == 0) {
imgTimer = $("<img>").attr("src", chrome.extension.getURL("images/iconspent.png")).addClass('agile_timer_icon_small');
imgTimer.attr("title", "Active timer");
var span = $("<span>");
span.append(imgTimer);
cloneTitleTag.append(span);
container.append(span);
setTimeout(function () {
showTimerPopup(idCard); //wait a little so we dont load many timer windows in parallel (and also give priority to trello board page loading)
}, 500+stateLoop.total * 100);
Expand Down
12 changes: 8 additions & 4 deletions source/buttons.js
Expand Up @@ -3,17 +3,19 @@

var HelpButton = {
strClass: 'agile_help_button',
create: function () {
create: function () {
var bPlusDisplayDisabled = isPlusDisplayDisabled();
var b = $('<span id="help_buttons_container"></span>').addClass('notranslate header-btn header-notifications ' + this.strClass);
b.hide();

var spanIcon = $('<span></span>').css('cursor', 'help');
var spanTour = $('<span class="agile_tour_link agile_plus_header_link">Tour</span>');
hookTour(spanTour);
var icon = $("<img>").attr("src",chrome.extension.getURL("images/iconspenthelp.png"));
var icon = $("<img>").attr("src", chrome.extension.getURL(bPlusDisplayDisabled ? "images/iconspenthelpwarn.png" : "images/iconspenthelp.png"));
icon.addClass("agile-spent-icon-header");
icon.attr("title", "Plus Help");
b.append(spanTour);
if (!bPlusDisplayDisabled)
b.append(spanTour);
spanIcon.append(icon);
b.append(spanIcon);
icon.click(function (evt) {
Expand Down Expand Up @@ -74,7 +76,9 @@ function insertPlusFeed(bForce) {
stateFeed = data;
var msNow = Date.now();
var msWait = 1000 * 60 * 60 * 3; //3 hours (there is a quota of 50,000 queries/day for all users) code.google.com/apis/console/b/0/?noredirect#project:147493868263:stats
//msWait = 1000; //1 sec, for test
//msWait = 1000; //1 sec, for test
if (isPlusDisplayDisabled())
msWait = 1000 * 60 * 60 * 0.5; //half hour in case there is a new g+ post about an issue fixed
if (msNow - stateFeed.msLastQuery > msWait) {
setTimeout(function () { //delay a few seconds because usually happens on trello page load, wait until that settles
sendExtensionMessage({ method: "getPlusFeed", msLastPostRetrieved: stateFeed.msLastPostReadByUser },
Expand Down

0 comments on commit d9bd228

Please sign in to comment.