|
@@ -1,12 +1,56 @@ |
|
|
const defaultOrderRegistry = {};
|
|
|
const defaultOrderRegistry = {};
|
|
|
|
|
|
|
|
|
|
|
|
/* function notify(orderRegistry) {
|
|
|
|
|
|
if (!('listeners' in orderRegistry))
|
|
|
|
|
|
return;
|
|
|
|
|
|
for (let k in orderRegistry.listeners) {
|
|
|
|
|
|
orderRegistry.listeners[k](orderRegistry);
|
|
|
|
|
|
}
|
|
|
|
|
|
} */
|
|
|
|
|
|
|
|
|
|
|
|
function cursorDecor() {
|
|
|
|
|
|
let d = $('#cursor-decor');
|
|
|
|
|
|
if (d.length === 1)
|
|
|
|
|
|
return $(d[0]);
|
|
|
|
|
|
d = $('<div id="cursor-decor" style="z-index: 10000; position: absolute; left: 10px; top: 10px;"> \
|
|
|
|
|
|
<div class="progress" style="height: 8px;"> \
|
|
|
|
|
|
<div class="progress-bar progress-bar-striped progress-bar-animated" \
|
|
|
|
|
|
role="progressbar" aria-valuenow="100" aria-valuemin="0" \
|
|
|
|
|
|
aria-valuemax="100" style="width: 32px;"></div> \
|
|
|
|
|
|
</div> \
|
|
|
|
|
|
</div>');
|
|
|
|
|
|
$(document.body).append(d);
|
|
|
|
|
|
let pageX = 0, pageY = 0, scrollX = 0, scrollY = 0;
|
|
|
|
|
|
document.addEventListener('mousemove', e => {
|
|
|
|
|
|
pageX = e.pageX;
|
|
|
|
|
|
pageY = e.pageY;
|
|
|
|
|
|
d.css({ left: (e.pageX + 16) + 'px', top: (e.pageY + 16) + 'px' })
|
|
|
|
|
|
scrollX = window.scrollX;
|
|
|
|
|
|
scrollY = window.scrollY;
|
|
|
|
|
|
});
|
|
|
|
|
|
document.addEventListener('scroll', e => {
|
|
|
|
|
|
d.css({ left: (pageX + window.scrollX - scrollX + 16) + 'px',
|
|
|
|
|
|
top: (pageY + window.scrollY - scrollY + 16) + 'px' });
|
|
|
|
|
|
});
|
|
|
|
|
|
return d;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function updateCursorDecor(orderRegistry) {
|
|
|
|
|
|
const d = cursorDecor();
|
|
|
|
|
|
if (Object.keys(orderRegistry.pendingCompletion).length === 0)
|
|
|
|
|
|
d.hide();
|
|
|
|
|
|
else
|
|
|
|
|
|
d.show();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
function wbApplyPromiseOrdering(prom, orderRegistry) {
|
|
|
function wbApplyPromiseOrdering(prom, orderRegistry) {
|
|
|
let orderId;
|
|
|
let orderId;
|
|
|
|
|
|
|
|
|
if (!orderRegistry)
|
|
|
if (!orderRegistry)
|
|
|
orderRegistry = defaultOrderRegistry;
|
|
|
orderRegistry = defaultOrderRegistry;
|
|
|
|
|
|
|
|
|
if (Object.keys(orderRegistry).length === 0) {
|
|
|
|
|
|
|
|
|
//if (Object.keys(orderRegistry).length === 0) {
|
|
|
|
|
|
if (!('started' in orderRegistry)) {
|
|
|
orderRegistry.started = 0;
|
|
|
orderRegistry.started = 0;
|
|
|
orderRegistry.pendingCompletion = {};
|
|
|
orderRegistry.pendingCompletion = {};
|
|
|
orderRegistry.completed = { 0: true };
|
|
|
orderRegistry.completed = { 0: true };
|
|
@@ -15,6 +59,8 @@ function wbApplyPromiseOrdering(prom, orderRegistry) { |
|
|
orderRegistry.started += 1;
|
|
|
orderRegistry.started += 1;
|
|
|
orderId = orderRegistry.started;
|
|
|
orderId = orderRegistry.started;
|
|
|
// console.log('New orderId: ' + orderId);
|
|
|
// console.log('New orderId: ' + orderId);
|
|
|
|
|
|
// notify(orderRegistry);
|
|
|
|
|
|
cursorDecor().show();
|
|
|
|
|
|
|
|
|
const orderCallback = ((isCatch, payload) => {
|
|
|
const orderCallback = ((isCatch, payload) => {
|
|
|
// console.log('orderId: ' + orderId +
|
|
|
// console.log('orderId: ' + orderId +
|
|
@@ -41,6 +87,7 @@ function wbApplyPromiseOrdering(prom, orderRegistry) { |
|
|
// console.log('Garbage collect');
|
|
|
// console.log('Garbage collect');
|
|
|
orderRegistry.started = 0;
|
|
|
orderRegistry.started = 0;
|
|
|
orderRegistry.completed = { 0: true };
|
|
|
orderRegistry.completed = { 0: true };
|
|
|
|
|
|
cursorDecor().hide();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (isCatch)
|
|
|
if (isCatch)
|
|
|