Changeset 33045 for main/trunk/greenstone3/web/interfaces/default
- Timestamp:
- 2019-05-03T21:46:42+12:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/javascript-global-functions.js
r33043 r33045 13 13 } 14 14 15 // Debugging function to print a string's non-basic chars in hex 15 // Debugging function to print a string's non-basic chars in hex. So does string2hex on all non-basic and non-printable ASCII chars 16 // Dr Bainbridge said that printing anything with charCode over 128 in hex is okay, but I'd already made extra allowances for non-printable ASCII 16 17 // Based on https://stackoverflow.com/questions/36637146/javascript-encode-string-to-hex/36637293 17 18 // https://stackoverflow.com/questions/21647928/javascript-unicode-string-to-hex 18 gs.functions. string2hex= function(str) {19 gs.functions.debug_unicode_string = function(str) { 19 20 var hex, i; 20 21 … … 26 27 if(charcode < 20 || charcode > 126) { //doesn't work: if(str.charAt(i) < ' ' || str.charAt(i) > '~') { 27 28 hex = charcode.toString(16); 28 result += "x " + ("000"+hex).slice(-4);29 result += "x{" + ("000"+hex).slice(-4) + "}"; // looks like: x{4-char-codepoint} 29 30 } 30 31 else { … … 785 786 gs.functions.setArchivesMetadata = function(collection, site, documentID, metadataName, metadataPosition, metadataValue, prevMetadataValue, metamode, successResponseFunction, errorResponseFunction) 786 787 { 788 if(metadataValue) console.log("metaval: " + metadataValue + " | " + gs.functions.debug_unicode_string(metadataValue)); //metadataValue.hexEncode() 789 if(prevMetadataValue) console.log("prevmetaval: " + prevMetadataValue + " | " + gs.functions.debug_unicode_string(prevMetadataValue)); 790 787 791 if( typeof errorResponseFunction === 'undefined' ) { errorResponseFunction = null; } // force error callback to be defined: either null or has value 788 792
Note:
See TracChangeset
for help on using the changeset viewer.