comparison js/core.js @ 2596:2d820b7413a7

#37: Completed interfaceContext.getLabel. APE uses this getLabel for creating the page labels.
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Thu, 10 Nov 2016 16:46:47 +0000
parents 4fdaed765674
children 8188efa9415d
comparison
equal deleted inserted replaced
2595:4fdaed765674 2596:2d820b7413a7
3248 if (labelType == "none") { 3248 if (labelType == "none") {
3249 return ""; 3249 return "";
3250 } 3250 }
3251 switch (labelType) { 3251 switch (labelType) {
3252 case "letter": 3252 case "letter":
3253 return String.fromCharCode((index + offset) % 26 + 96); 3253 return String.fromCharCode((index + offset) % 26 + 97);
3254 case "capital": 3254 case "capital":
3255 return String.fromCharCode((index + offset) % 26 + 65); 3255 return String.fromCharCode((index + offset) % 26 + 66);
3256 case "number": 3256 case "number":
3257 return String(index + offset); 3257 return String(index + offset);
3258 default: 3258 default:
3259 return ""; 3259 return "";
3260 } 3260 }
3261 } 3261 }
3262 3262
3263 if (typeof labelStart !== "string") { 3263 if (typeof labelStart !== "string" || labelStart.length == 0) {
3264 labelStart = String.fromCharCode(0); 3264 labelStart = String.fromCharCode(0);
3265 } 3265 }
3266 3266
3267 switch (labelType) { 3267 switch (labelType) {
3268 case "letter": 3268 case "letter":
3269 labelStart = labelStart.charCodeAt(0); 3269 labelStart = labelStart.charCodeAt(0);
3270 if (labelStart.charCodeAt(0) < 97 || label.charCodeAt(0) > 122) { 3270 if (labelStart < 97 || labelStart > 122) {
3271 labelStart = 97; 3271 labelStart = 97;
3272 } 3272 }
3273 labelStart -= 97; 3273 labelStart -= 97;
3274 break; 3274 break;
3275 case "capital": 3275 case "capital":
3276 labelStart = labelStart.charCodeAt(0); 3276 labelStart = labelStart.charCodeAt(0);
3277 if (labelStart.charCodeAt(0) < 65 || label.charCodeAt(0) > 90) { 3277 if (labelStart < 65 || labelStart > 90) {
3278 labelStart = 65; 3278 labelStart = 65;
3279 } 3279 }
3280 labelStart -= 65; 3280 labelStart -= 65;
3281 break; 3281 break;
3282 case "number": 3282 case "number":
3283 if (!isFinite(Number(label))) { 3283 if (!isFinite(Number(labelStart))) {
3284 labelStart = 1; 3284 labelStart = 1;
3285 } 3285 }
3286 break; 3286 break;
3287 case "none": 3287 case "none":
3288 default: 3288 default:
3289 labelStart = ""; 3289 labelStart = 0;
3290 } 3290 }
3291 if (typeof index == "number") { 3291 if (typeof index == "number") {
3292 return calculateLabel(labelType, index, labelStart); 3292 return calculateLabel(labelType, index, labelStart);
3293 } else if (index.length && index.length > 0) { 3293 } else if (index.length && index.length > 0) {
3294 var a = [], 3294 var a = [],