diff --git a/README.md b/README.md
index 009289e..84841dc 100644
--- a/README.md
+++ b/README.md
@@ -78,7 +78,7 @@ Play:
- Play modes for those who only caption or only draw
- Enter pressed in caption mode submits the caption
- Ability to bookmark games without participating
-- Show your panel position and track changes in unfinished games list
+- Show your panel position and track changes in unfinished games list and your experience
Forum:
@@ -89,6 +89,11 @@ Forum:
## CHANGELOG
+1.75.2016.2
+- Fixed captions of created games not being registered for progress tracking
+- Added tracking of changes in your level progress
+- Added an option to set smoothing threshold
+
1.74.2016.2
- New canvas: ability to apply custom CSS, experimental
diff --git a/drawception-anbt.user.js b/drawception-anbt.user.js
index a9b8c81..c494e44 100644
--- a/drawception-anbt.user.js
+++ b/drawception-anbt.user.js
@@ -2,7 +2,7 @@
// @name Drawception ANBT
// @author Grom PE
// @namespace http://grompe.org.ru/
-// @version 1.74.2016.2
+// @version 1.75.2016.2
// @description Enhancement script for Drawception.com - Artists Need Better Tools
// @downloadURL https://raw.github.com/grompe/Drawception-ANBT/master/drawception-anbt.user.js
// @match http://drawception.com/*
@@ -14,8 +14,8 @@
function wrapped() {
-var SCRIPT_VERSION = "1.74.2016.2";
-var NEWCANVAS_VERSION = 24; // Increase to update the cached canvas
+var SCRIPT_VERSION = "1.75.2016.2";
+var NEWCANVAS_VERSION = 25; // Increase to update the cached canvas
// == DEFAULT OPTIONS ==
@@ -98,7 +98,7 @@ Play
- Play modes for those who only caption or only draw
- Enter pressed in caption mode submits the caption
- Ability to bookmark games without participating
-- Show your panel position and track changes in unfinished games list
+- Show your panel position and track changes in unfinished games list and your experience
Forum
- Better-looking timestamps with correct timezone
- Clickable drawing panels
@@ -981,7 +981,7 @@ function deeper_main()
stupidPlugin.setAttribute("width", "1");
stupidPlugin.setAttribute("height", "1");
container.appendChild(stupidPlugin);
- if (options.fixTabletPluginGoingAWOL) fixPluginGoingAWOL();
+ if (options.fixTabletPluginGoingAWOL) fixPluginGoingAWOL();
}
bindCanvasEvents();
if (window.insandbox)
@@ -2093,6 +2093,11 @@ function betterCreateGame()
}
});
}
+
+ if (options.rememberPosition && $(".page-header h1").text().match(/Game Created/))
+ {
+ panelPositions.registerPanel();
+ }
}
function betterView()
@@ -2403,23 +2408,10 @@ function betterPanel()
if (options.rememberPosition && $(".regForm > .lead").text().match(/public game/)) // your own panel
{
- panelPositions.load();
- if (!panelPositions.player[panelId])
+ panelPositions.registerPanel(panelId, function(position)
{
- var profileUrl = $(".btn").has(".avatar").attr("href");
- $.get(profileUrl, function(html)
- {
- html = html.replace(/]*>/ig, ''); // prevent image preload
- var profilePage = $.parseHTML(html);
- var panelProgressText = $(profilePage).find("a[href='" + location.pathname + "']").next().find(".progress-bar-text").text();
- var panelPosition = parseInt(panelProgressText.match(/\d+/)[0]);
- panelPositions.player[panelId] = panelPosition;
- panelPositions.clear(profilePage);
- panelPositions.save();
-
- $(".regForm > .lead").append(" ").append($("").text(panelProgressText));
- });
- }
+ $(".regForm > .lead").append(" ").append($("").text(position.join(" of ")));
+ });
}
}
@@ -2427,21 +2419,27 @@ var panelPositions =
{
player: null,
last: null,
+ level: null,
+ experience: null,
load: function ()
{
- function loadObj(key)
+ function loadObj(key, fallback)
{
var val = localStorage.getItem(key);
- return val && JSON.parse(val) || {};
+ return val && JSON.parse(val) || fallback;
}
- panelPositions.player = loadObj("gpe_panelPositions");
- panelPositions.last = loadObj("gpe_lastGamePositions");
+ panelPositions.player = loadObj("gpe_panelPositions", {});
+ panelPositions.last = loadObj("gpe_lastGamePositions", {});
+ panelPositions.level = loadObj("gpe_lastLevel", null);
+ panelPositions.experience = loadObj("gpe_lastExperience", null);
},
save: function ()
{
localStorage.setItem("gpe_panelPositions", JSON.stringify(panelPositions.player));
localStorage.setItem("gpe_lastGamePositions", JSON.stringify(panelPositions.last));
+ localStorage.setItem("gpe_lastLevel", JSON.stringify(panelPositions.level));
+ localStorage.setItem("gpe_lastExperience", JSON.stringify(panelPositions.experience));
},
clear: function (page)
{
@@ -2456,6 +2454,42 @@ var panelPositions =
}).get();
clearKeys(panelPositions.player, existingIds);
clearKeys(panelPositions.last, existingIds);
+ },
+ registerPanel: function (panelId, callback)
+ {
+ function getPanelPosition (link)
+ {
+ var panelProgressText = link.next().find(".progress-bar-text").text();
+ return [parseInt(panelProgressText.match(/\d+/)[0]), parseInt(panelProgressText.match(/\d+/g)[1])];
+ }
+
+ panelPositions.load();
+ // panelId is undefined when the game is just created
+ if (!panelId || !panelPositions.player[panelId])
+ {
+ var profileUrl = $(".btn").has(".avatar").attr("href");
+ $.get(profileUrl, function(html)
+ {
+ html = html.replace(/]*>/ig, ''); // prevent image preload
+ var profilePage = $.parseHTML(html);
+
+ // Panel panelId is just created, record its position
+ if (panelId)
+ {
+ var position = getPanelPosition($(profilePage).find("a[href='" + location.pathname + "']"));
+ panelPositions.player[panelId] = position[0];
+ callback && callback(position);
+ }
+
+ // Panels with position 1 are always ours
+ $(profilePage).find("a")
+ .filter(function() { return $(this).next().hasClass("progress-striped") && getPanelPosition($(this))[0] == 1; })
+ .each(function() { panelPositions.player[getPanelId(this.href)] = 1; });
+
+ panelPositions.clear(profilePage);
+ panelPositions.save();
+ });
+ }
}
};
@@ -2790,12 +2824,12 @@ function betterPlayer()
var panelId = getPanelId($(this).prev().attr("href"));
var playerPanelPosition = panelPositions.player[panelId];
var lastSeenPanelPosition = panelPositions.last[panelId];
- var panelProgress = $(this).find(".progress-bar-text");
- var panelProgressText = panelProgress.text();
+ var panelProgressLabel = $(this).find(".progress-bar-text");
+ var panelProgressText = panelProgressLabel.text();
var panelPosition = parseInt(panelProgressText.match(/\d+/)[0]);
var totalPanelCount = parseInt(panelProgressText.match(/\d+/g)[1]);
- panelProgress.css("pointer-events", "none"); // to make tooltips work under label
+ panelProgressLabel.css("pointer-events", "none"); // to make tooltips work under label
if ((playerPanelPosition || lastSeenPanelPosition || panelPosition) < panelPosition)
{
$(this).find(".progress-bar")
@@ -2805,21 +2839,21 @@ function betterPlayer()
{
$('