Skip to content

Commit

Permalink
CLDR-17248 Measure vote timing; log more times; fix warnings (#3404)
Browse files Browse the repository at this point in the history
-Make cldrTable.CLDR_TABLE_DEBUG true; log times to console

-Make new cldrTable.CLDR_TABLE_DEBUG_ZOOM false; not clear whether still useful

-Fix Chrome warnings, add id locale-search-input and input-add-translation

-Fix Chrome warnings, move import statements to top of surveytool.css

-Comments
  • Loading branch information
btangmu authored Dec 5, 2023
1 parent 974b361 commit c484491
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tools/cldr-apps/js/src/esm/cldrGui.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const leftSidebar =
" <div id='locale-info'>\n" +
" <div class='input-group input-group-sm'>\n" +
" <span class='input-group-addon refresh-search'><span class='glyphicon glyphicon-search'></span></span>\n" +
" <input type='text' class='form-control local-search' placeholder='Locale' />\n" +
" <input id='locale-search-input' type='text' class='form-control local-search' placeholder='Locale' />\n" +
" </div>\n" +
" <span id='locale-clear' class='refresh-search'>x</span>\n" +
" \n" +
Expand Down
33 changes: 31 additions & 2 deletions tools/cldr-apps/js/src/esm/cldrTable.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import * as cldrXPathUtils from "./cldrXpathUtils.mjs";
const HEADER_ID_PREFIX = "header_";
const ROW_ID_PREFIX = "row_"; // formerly "r@"

const CLDR_TABLE_DEBUG = false;
const CLDR_TABLE_DEBUG = true;
const CLDR_TABLE_DEBUG_ZOOM = false; // First column gets "zoom{JSON}" links -- what are they for??

/*
* NO_WINNING_VALUE indicates the server delivered path data without a valid winning value.
Expand Down Expand Up @@ -315,17 +316,41 @@ function refreshSingleRow(tr, theRow, onSuccess, onFailure) {
}

function singleRowLoadHandler(json, tr, theRow, onSuccess, onFailure) {
if (CLDR_TABLE_DEBUG) {
console.log("singleRowLoadHandler start time = " + Date.now());
}
try {
if (json.page.rows[tr.rowHash]) {
theRow = json.page.rows[tr.rowHash];
tr.theTable.json.page.rows[tr.rowHash] = theRow;
updateRow(tr, theRow);
if (CLDR_TABLE_DEBUG) {
console.log(
"singleRowLoadHandler after updateRow time = " + Date.now()
);
}
cldrSurvey.hideLoader();
onSuccess(theRow);
if (CLDR_TABLE_DEBUG) {
console.log(
"singleRowLoadHandler after onSuccess time = " + Date.now()
);
}
cldrGui.updateDashboardRow(json);
cldrInfo.showRowObjFunc(tr, tr.proposedcell, tr.proposedcell.showFn);
if (CLDR_TABLE_DEBUG) {
console.log(
"singleRowLoadHandler after showRowObjFunc time = " + Date.now()
);
}
cldrProgress.updateCompletionOneVote(theRow.hasVoted);
cldrGui.refreshCounterVetting();
if (CLDR_TABLE_DEBUG) {
console.log(
"singleRowLoadHandler after refreshCounterVetting time = " +
Date.now()
);
}
} else {
tr.className = "ferrbox";
console.log("could not find " + tr.rowHash + " in " + json);
Expand All @@ -339,6 +364,9 @@ function singleRowLoadHandler(json, tr, theRow, onSuccess, onFailure) {
} catch (e) {
console.log("Error in ajax post [refreshSingleRow] ", e.message);
}
if (CLDR_TABLE_DEBUG) {
console.log("singleRowLoadHandler end time = " + Date.now());
}
}

function singleRowErrHandler(err, tr, onFailure) {
Expand Down Expand Up @@ -707,7 +735,7 @@ function updateRowCodeCell(tr, theRow, cell) {
) {
cldrSurvey.appendExtraAttributes(cell, theRow);
}
if (CLDR_TABLE_DEBUG) {
if (CLDR_TABLE_DEBUG_ZOOM) {
const anch = document.createElement("i");
anch.className = "anch";
anch.id = theRow.xpathId;
Expand Down Expand Up @@ -854,6 +882,7 @@ function updateRowOthersCell(tr, theRow, cell, protoButton, formAdd) {
const input = document.createElement("input");
let popup;
input.className = "form-control input-add";
input.id = "input-add-translation";
cldrSurvey.setLang(input);
input.placeholder = "Add a translation";
const copyWinning = document.createElement("button");
Expand Down
20 changes: 19 additions & 1 deletion tools/cldr-apps/js/src/esm/cldrVote.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,20 @@ function handleVoteOk(json, tr, theRow, button, valToShow) {
}

function handleVoteSubmitted(json, tr, theRow, button, valToShow) {
if (CLDR_VOTE_DEBUG) {
console.log("handleVoteSubmitted start time = " + Date.now());
}
tr.className = "tr_checking2";
cldrTable.refreshSingleRow(
tr,
theRow,
function (theRow) {
if (CLDR_VOTE_DEBUG) {
console.log(
"handleVoteSubmitted anonymous callback for refreshSingleRow start time = " +
Date.now()
);
}
// submit went through. Now show the pop.
button.className = "ichoice-o";
button.checked = false;
Expand All @@ -189,11 +198,20 @@ function handleVoteSubmitted(json, tr, theRow, button, valToShow) {
// tried to submit, have errs or warnings.
showProposedItem(tr.inputTd, tr, theRow, valToShow, json.testResults);
}
if (CLDR_VOTE_DEBUG) {
console.log(
"handleVoteSubmitted anonymous callback for refreshSingleRow end time = " +
Date.now()
);
}
},
function (err) {
cldrRetry.handleDisconnect(err, json);
}
);
if (CLDR_VOTE_DEBUG) {
console.log("handleVoteSubmitted end time = " + Date.now());
}
}

function handleVoteNotSubmitted(json, tr, theRow, button, valToShow) {
Expand Down Expand Up @@ -230,7 +248,7 @@ function handleVoteErr(tr, message, button) {
* @returns the sanitized string
*/
function makeSafe(s) {
return s.replace(/[<>&]/g, '');
return s.replace(/[<>&]/g, "");
}

function logVote(rowHash, vHash, value) {
Expand Down
8 changes: 4 additions & 4 deletions tools/cldr-apps/src/main/webapp/surveytool.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
/* Made with CSSEdit and Espresso2 */
@charset "UTF-8";

/* TODO: should load this locally via webpack, see https://unicode-org.atlassian.net/browse/CLDR-9195 */
@import url("//fonts.googleapis.com/css?family=Noto+Sans:400italic,700italic,400,700");
@import url("//fonts.googleapis.com/css?family=Noto+Sans+Symbols:400italic,700italic,400,700");

span.age {
font-weight: bold;
font-style: italic;
Expand Down Expand Up @@ -1686,10 +1690,6 @@ table#voteinfo thead th:first-child {
sans-serif;
}

/* TODO: should load this locally via webpack, see https://unicode-org.atlassian.net/browse/CLDR-9195 */
@import url("//fonts.googleapis.com/css?family=Noto+Sans:400italic,700italic,400,700");
@import url("//fonts.googleapis.com/css?family=Noto+Sans+Symbols:400italic,700italic,400,700");

/* lang specific CSS */

/*
Expand Down

0 comments on commit c484491

Please sign in to comment.