MCPcopy Create free account
hub / github.com/microsoft/SandDance / getMaskDisplay

Function getMaskDisplay

docs/app/js/sanddance-app.js:50861–50885  ·  view source on GitHub ↗
(mask, maskCharData, maskChar)

Source from the content-addressed store, hash-verified

50859 return maskCharData;
50860}
50861function getMaskDisplay(mask, maskCharData, maskChar) {
50862 var maskDisplay = mask;
50863 if (!maskDisplay) return "";
50864 // Remove all backslashes
50865 maskDisplay = maskDisplay.replace(/\\/g, "");
50866 // lastDisplayIndex is is used to truncate the string if necessary.
50867 var lastDisplayIndex = 0;
50868 if (maskCharData.length > 0) lastDisplayIndex = maskCharData[0].displayIndex - 1;
50869 /**
50870 * For each input value, replace the character in the maskDisplay with the value.
50871 * If there is no value set for the format character, use the maskChar.
50872 */ for(var _i = 0, maskCharData_1 = maskCharData; _i < maskCharData_1.length; _i++){
50873 var charData = maskCharData_1[_i];
50874 var nextChar = " ";
50875 if (charData.value) {
50876 nextChar = charData.value;
50877 if (charData.displayIndex > lastDisplayIndex) lastDisplayIndex = charData.displayIndex;
50878 } else if (maskChar) nextChar = maskChar;
50879 // Insert the character into the maskdisplay at its corresponding index
50880 maskDisplay = maskDisplay.slice(0, charData.displayIndex) + nextChar + maskDisplay.slice(charData.displayIndex + 1);
50881 }
50882 // Cut off all mask characters after the last filled format value
50883 if (!maskChar) maskDisplay = maskDisplay.slice(0, lastDisplayIndex + 1);
50884 return maskDisplay;
50885}
50886function getRightFormatIndex(maskCharData, index) {
50887 for(var i = 0; i < maskCharData.length; i++){
50888 if (maskCharData[i].displayIndex >= index) return maskCharData[i].displayIndex;

Callers

nothing calls this directly

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected