1"use strict"; 2Object.defineProperty(exports, "__esModule", { value: true }); 3exports.AscPhotoSwipe = exports.getSvgUrlToShow = exports.getKalamFontEmbeded = void 0; 4var tslib_1 = require("tslib"); 5var React = require("react"); 6var AppNative_1 = require("../../../app/pics/jsw/data/AppNative"); 7importCss('/photos/pics/css/photos.css'); 8importCss('/photos/pics/css/photoswipe.css'); 9importCss('/photos/pics/css/photoswipe/default-skin.css'); 10importLegacyJsLib('/elearning/pics/js/fabric.js'); 11importLegacyJsLib('/photos/pics/js/photoswipe.js'); 12importLegacyJsLib('/photos/pics/js/photoswipe-ui-default.js'); 13importLegacyJsLib('/elearning/pics/js/etest/utilsETest.js'); 14function getKalamFontEmbeded() { 15 return tslib_1.__awaiter(this, void 0, void 0, function () { 16 var ret; 17 return tslib_1.__generator(this, function (_a) { 18 switch (_a.label) { 19 case 0: 20 ret = ''; 21 if (!(typeof window != 'undefined' && window.kalamFontStr)) return [3, 1]; 22 ret = window.kalamFontStr; 23 return [3, 3]; 24 case 1: return [4, new Promise(function (resolve, reject) { 25 $.get('/global/pics/gfonts/Kalam/fontEmbeded.css?v=2', function (data) { 26 window.kalamFontStr = data; 27 resolve(data); 28 }).fail(function () { 29 resolve(''); 30 }); 31 })]; 32 case 2: 33 ret = _a.sent(); 34 _a.label = 3; 35 case 3: return [2, ret]; 36 } 37 }); 38 }); 39} 40exports.getKalamFontEmbeded = getKalamFontEmbeded; 41function getSvgUrlToShow(svg) { 42 return tslib_1.__awaiter(this, void 0, void 0, function () { 43 var ts, svgElem, embededFontStr, ret; 44 return tslib_1.__generator(this, function (_a) { 45 switch (_a.label) { 46 case 0: 47 ts = Date.now(); 48 svgElem = $(svg); 49 return [4, getKalamFontEmbeded()]; 50 case 1: 51 embededFontStr = _a.sent(); 52 svgElem.find('image').each(function () { 53 $(this).closest('g').remove(); 54 $(this).remove(); 55 }); 56 svgElem.prepend('<defs><style>\n' + embededFontStr + '\n</style></defs>'); 57 ret = { 58 w: svgElem.attr('width'), 59 h: svgElem.attr('height'), 60 src: 'data:image/svg+xml;base64,' + encodeURIComponent(XBase64.encode(svgElem.get(0).outerHTML)), 61 }; 62 return [2, ret]; 63 } 64 }); 65 }); 66} 67exports.getSvgUrlToShow = getSvgUrlToShow; 68function AscPhotoSwipe(props) { 69 var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; 70 var mainElemRef = React.useRef(null); 71 var outerElemRef = React.useRef(null); 72 var commentElemRef = React.useRef(null); 73 var galleryRef = React.useRef(null); 74 var _l = React.useState(props.answerComment || ""), answerComment0 = _l[0], setAnswerComment = _l[1]; 75 var _m = React.useState([]), answerCommentAtts0 = _m[0], setAnswerCommentAtts = _m[1]; 76 var _o = React.useState(0), refreshCounter = _o[0], setRefreshCounter = _o[1]; 77 var citem0 = props.photos[props.index || 0]; 78 var _p = React.useState(citem0), currentItem = _p[0], setCurrentItem = _p[1]; 79 var currentItemRef = React.useRef(currentItem); 80 currentItemRef.current = currentItem; 81 var answerComment = props.getCommentFunc && currentItemRef.current ? props.getCommentFunc(currentItemRef.current) : ''; 82 var answerCommentAtts = props.getCommentAttsFunc && currentItemRef.current ? props.getCommentAttsFunc(currentItemRef.current) : null; 83 var bodyObj = props.getBodyFunc && currentItemRef.current ? props.getBodyFunc(currentItemRef.current) : { body: '', maxBody: '' }; 84 var body = bodyObj ? bodyObj.body : '';
85 var maxBody = bodyObj ? bodyObj.maxBody : ''; 86 var origComment = currentItem.origComment ? currentItem.origComment : { comment: answerComment, body: body, maxBody: maxBody, atts: answerCommentAtts ? answerCommentAtts.map(function (r) { return $.extend({}, r); }) : null }; 87 currentItem.origComment = origComment; 88 var _q = React.useState(null), items0 = _q[0], setItems0 = _q[1]; 89 var itemsRef = React.useRef(null); 90 var nativeAppVersion = (typeof window != 'undefined' ? (_a = window.EdupageApp) === null || _a === void 0 ? void 0 : _a.nativeAppVersion : null) || '2.1.0'; 91 React.useEffect(function () { 92 function prepareItems() { 93 var _a; 94 return tslib_1.__awaiter(this, void 0, void 0, function () { 95 var items, i, photo, pom, svg, item, svge; 96 return tslib_1.__generator(this, function (_b) { 97 switch (_b.label) { 98 case 0: 99 items = []; 100 i = 0; 101 _b.label = 1; 102 case 1: 103 if (!(i < props.photos.length)) return [3, 5]; 104 photo = $.extend({}, props.photos[i]); 105 if (!photo) 106 return [3, 4]; 107 photo.w = photo.width ? photo.width : 1200; 108 photo.h = photo.height ? photo.height : 800; 109 if (photo.rotation) { 110 photo.rotationDegrees = photo.rotation; 111 } 112 if (!(((_a = photo.src) === null || _a === void 0 ? void 0 : _a.startsWith('data:image/svg+xml')) || photo.commentSrc)) return [3, 3]; 113 pom = (photo.commentSrc || photo.src).split(','); 114 svg = XBase64.decode(decodeURIComponent(pom[1])); 115 item = $.extend({}, photo); 116 item.src = photo.forSrc || photo.src; 117 return [4, getSvgUrlToShow(svg)]; 118 case 2: 119 svge = _b.sent(); 120 item.svg = svge.src; 121 item.w = svge.w; 122 item.h = svge.h; 123 items.push(item); 124 return [3, 4]; 125 case 3: 126 items.push(photo); 127 _b.label = 4; 128 case 4: 129 i++; 130 return [3, 1]; 131 case 5: 132 itemsRef.current = items; 133 setItems0(items); 134 return [2]; 135 } 136 }); 137 }); 138 } 139 prepareItems(); 140 }, []); 141 React.useEffect(function () { 142 var items = items0; 143 if (!items) 144 return; 145 var citem0 = items[props.index || 0]; 146 setCurrentItem(citem0); 147 var gallery = new PhotoSwipe(mainElemRef.current, PhotoSwipeUI_Default, items, { 148 index: props.index || 0, 149 closeOnScroll: false, 150 closeOnVerticalDrag: false, 151 history: false, 152 tapToClose: false, 153 clickToCloseNonZoomable: false, 154 fullscreenEl: props.wasFullScreenBefore ? false : !MobileAppBridge.isIOS(), 155 wasFullScreenBefore: props.wasFullScreenBefore, 156 shareEl: false, 157 pinchToClose: false, 158 closeEl: MobileAppBridge.isActive() ? false : true, 159 loop: false, 160 maxSpreadZoom: 3 161 }); 162 gallery.init(); 163 var galleryClosing = false; 164 gallery.listen('close', function (e) { 165 if (props.onclose) { 166 props.onclose(); 167 } 168 }); 169 gallery.listen('beforeChange', function () { 170 setCurrentItem(gallery.currItem); 171 if (props.onslideChange) { 172 props.onslideChange(gallery.getCurrentIndex()); 173 } 174 var item = gallery.currItem; 175 $(mainElemRef.current).find('.showOriginalBtn').toggle((item.forSrc || item.editedSrc || item.commentSrc || item.h_commentSrc) ? true : false); 176 }); 177 gallery.listen('imageLoadComplete', function (index, item) { 178 }); 179 galleryRef.current = gallery; 180 $(mainElemRef.current).closest('.etest-return-div').data('pswp', galleryRef.current); 181 $(mainElemRef.current).find('.showOriginalBtn').toggle(((citem0 === null || citem0 === void 0 ? void 0 : citem0.forSrc) || (citem0 === null || citem0 === void 0 ? void 0 : citem0.editedSrc) || (citem0 === null || citem0 === void 0 ? void 0 : citem0.commentSrc) || (citem0 === null || citem0 === void 0 ? void 0 : citem0.h_commentSrc)) ? true : false); 182 autosize($(outerElemRef.current).find('textarea')); 183 }, [items0]); 184 React.useEffect(function () { 185 if (!commentElemRef) 186 return; 187 $(commentElemRef.current).find('.etest-atts-selector').etestAttachementsSelector({ 188 attachements: answerCommentAtts, 189 attachementsTitle: false, 190 pasteZone: $(commentElemRef.current), 191 hideCommentAtts: true, 192 onChange: function (atts) { 193 if (props.changeCommentAttsFunc) { 194 props.changeCommentAttsFunc(atts, currentItemRef.current); 195 } 196 } 197 }); 198 return function () { 199 $(commentElemRef.current).find('.etest-atts-selector').etestAttachementsSelector('destroy'); 200 }; 201 }, [answerCommentAtts]); 202 function rotateLeftClick() { 203 var gallery = galleryRef.current; 204 if (!gallery) 205 return; 206 gallery.rotateLeft(); 207 } 208 function rotateRightClick() { 209 var gallery = galleryRef.current; 210 if (!gallery) 211 return; 212 gallery.rotateRight(); 213 } 214 function answerCommentChange(e) { 215 if (props.changeCommentFunc) { 216 props.changeCommentFunc(e.currentTarget.value, currentItemRef.current); 217 } 218 setAnswerComment(e.currentTarget.value); 219 } 220 function saveClick() { 221 if (props.saveFunc) { 222 props.saveFunc(function () { 223 itemsRef.current.forEach(function (r) { 224 r.origComment = null; 225 }); 226 setRefreshCounter(refreshCounter + 1); 227 barShowMessage(ls(9863), 4000); 228 return 'recreate'; 229 }); 230 } 231 } 232 function bodyChange(e) { 233 if (props.changeBodyFunc) { 234 props.changeBodyFunc(e.currentTarget.value, currentItemRef.current); 235 } 236 setRefreshCounter(refreshCounter + 1); 237 } 238 function changeMaxBodyClick(e) { 239 if (props.changeNumPointsFunc) { 240 props.changeNumPointsFunc(currentItemRef.current, function () { 241 setRefreshCounter(refreshCounter + 1); 242 }); 243 } 244 } 245 function editImageClick(e) { 246 var _this = this; 247 var gallery = galleryRef.current; 248 var item = currentItemRef.current; 249 var svgBase64 = item.editedSvg || item.svg || ''; 250 var pom = (svgBase64).split(','); 251 var svg = pom[1] ? XBase64.decode(decodeURIComponent(pom[1])) : ''; 252 barLoadGoogleFont('Kalam'); 253 ASC.requireAsync('./../../../elearning/pics/jsw/TuiImageEditor.js').then(function (c) { 254 var elem = c.AscTuiImageEditorShow({ 255 imageSrc: item.editedSrc || item.src, 256 svg: svg, 257 svgJson: item.svgJson, 258 rotation: item.rotation, 259 width: item.w, 260 height: item.h, 261 initialZoomLevel: item.fitRatio ? gallery.getZoomLevel() / item.fitRatio : 0, 262 saveFunc: function (data) { 263 (function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { 264 var itemSrc, atts, dstAtt, _i, atts_1, a, _a; 265 var _b; 266 return tslib_1.__generator(this, function (_c) { 267 switch (_c.label) { 268 case 0: 269 itemSrc = item.forSrc ? item.forSrc : (_b = item.src) === null || _b === void 0 ? void 0 : _b.replace('&v=3', ''); 270 atts = answerCommentAtts ? answerCommentAtts.map(function (r) { return r; }) : []; 271 dstAtt = null; 272 for (_i = 0, atts_1 = atts; _i < atts_1.length; _i++) { 273 a = atts_1[_i]; 274 if (a.forSrc && itemSrc == a.forSrc) { 275 dstAtt = a; 276 } 277 } 278 if (!dstAtt) { 279 dstAtt = { 280 src: 'data:image/svg+xml;
280base64,' + encodeURIComponent(XBase64.encode(data.svg)), 281 name: item.name ? 'comment: ' + item.name : 'comment.svg', 282 forSrc: itemSrc, 283 svgJson: data.svgJson 284 }; 285 atts.push(dstAtt); 286 } 287 else { 288 dstAtt.src = 'data:image/svg+xml;base64,' + encodeURIComponent(XBase64.encode(data.svg)); 289 dstAtt.svgJson = data.svgJson; 290 } 291 if (data.rotation || data.rotation === 0) { 292 dstAtt.rotation = data.rotation; 293 localStorage.setItem('pswpimgrot:' + item.src, Math.floor(data.rotation / 90).toString()); 294 item.rotation = data.rotation; 295 } 296 if (props.changeCommentAttsFunc) { 297 props.changeCommentAttsFunc(atts, currentItemRef.current); 298 } 299 setAnswerCommentAtts(atts); 300 elem.find('.asc-tui-editor').css('opacity', 0); 301 setTimeout(function () { 302 barCloseDialog(elem); 303 }, 70); 304 item.forSrc = itemSrc; 305 item.src = itemSrc; 306 _a = item; 307 return [4, getSvgUrlToShow(data.svg)]; 308 case 1: 309 _a.svg = (_c.sent()).src; 310 item.svgJson = data.svgJson; 311 galleryRef.current.invalidateCurrItems(); 312 galleryRef.current.updateSize(true); 313 saveClick(); 314 return [2]; 315 } 316 }); 317 }); })(); 318 } 319 }); 320 }); 321 } 322 function showOrigClick(e) { 323 var item = currentItemRef.current; 324 if (item.commentSrc || item.h_commentSrc) { 325 if (!item.h_commentSrc) { 326 item.h_commentSrc = item.svg; 327 delete item.svg; 328 } 329 else { 330 item.svg = item.h_commentSrc; 331 delete item.h_commentSrc; 332 } 333 } 334 else if (item.forSrc) { 335 item.editedSrc = item.src; 336 item.editedSvg = item.svg; 337 item.src = item.forSrc; 338 delete item.svg; 339 delete item.forSrc; 340 } 341 else if (item.editedSrc) { 342 item.forSrc = item.src; 343 item.svg = item.editedSvg; 344 item.src = item.editedSrc; 345 } 346 galleryRef.current.invalidateCurrItems(); 347 galleryRef.current.updateSize(true); 348 } 349 function closeClick() { 350 var _a; 351 (_a = galleryRef.current) === null || _a === void 0 ? void 0 : _a.close(); 352 } 353 function shareClick(e) { 354 var _a, _b, _c, _d, _e; 355 var toDownload = [{ 356 url: ETestUtils.fixIOSSrc(((_a = currentItemRef.current) === null || _a === void 0 ? void 0 : _a.fileSrc) ? (_b = currentItemRef.current) === null || _b === void 0 ? void 0 : _b.fileSrc : (_c = currentItemRef.current) === null || _c === void 0 ? void 0 : _c.src) || "", 357 name: ((_d = currentItemRef.current) === null || _d === void 0 ? void 0 : _d.name) || "photo.jpg" 358 }]; 359 (_e = AppNative_1.AppNative.shareFiles) === null || _e === void 0 ? void 0 : _e.call(AppNative_1.AppNative, toDownload); 360 } 361 function downloadClick(e) { 362 var _a, _b; 363 if (!MobileAppBridge.isActive()) 364 return; 365 if (!AppNative_1.AppNative.downloadImages) 366 return; 367 if (MobileAppBridge.isActive() && MobileAppBridge.compareVersion(nativeAppVersion, '2.2.0') < 0) 368 return; 369 if (MobileAppBridge.isActive() && !MobileAppBridge.isIOS()) 370 return; 371 var href = $(e.currentTarget).attr('href'); 372 var toDownload = [{ url: href, name: ((_a = currentItemRef.current) === null || _a === void 0 ? void 0 : _a.name) || "photo.jpg" }]; 373 (_b = AppNative_1.AppNative.downloadImages) === null || _b === void 0 ? void 0 : _b.call(AppNative_1.AppNative, toDownload); 374 } 375 var downloadLink = ((_b = currentItemRef.current) === null || _b === void 0 ? void 0 : _b.fileSrc) ? (_c = currentItemRef.current) === null || _c === void 0 ? void 0 : _c.fileSrc : (_d = currentItemRef.current) === null || _d === void 0 ? void 0 : _d.src; 376 var iseq = ETestUtils.isEqual(answerCommentAtts, origComment.atts); 377 return (React.createElement("div", { ref: outerElemRef }, 378 React.createElement("div", { className: "pswp etest-player
378-front ui-front", tabIndex: -1, role: "dialog", "aria-hidden": "true", ref: mainElemRef, style: { zIndex: props.showAnswerComment ? 100 : null } }, 379 React.createElement("div", { className: "pswp__bg" }), 380 React.createElement("div", { className: "pswp__scroll-wrap" }, 381 React.createElement("div", { className: "pswp__container" }, 382 React.createElement("div", { className: "pswp__item" }), 383 React.createElement("div", { className: "pswp__item" }), 384 React.createElement("div", { className: "pswp__item" })), 385 React.createElement("div", { className: "pswp__ui pswp__ui--hidden" }, 386 React.createElement("div", { className: "pswp__top-bar nobtnbg" + (MobileAppBridge.isActive() ? ' galleryView mobileGalleryView' : '') }, 387 React.createElement("div", { className: "pswp__counter" }), 388 props.headerTitle && (React.createElement("div", { className: "etest-pswp-header-title" }, props.headerTitle)), 389 props.showAnswerComment 390 ? React.createElement("button", { className: "pswp__button pswp__button--close", title: ls(1567) + ' (Esc)', "aria-label": ls(1567) + ' (Esc)' }, 391 React.createElement("i", { className: "fa fa-fw fa-close", "aria-hidden": "true" })) 392 : React.createElement("button", { className: "pswp__button pswp__button--close", title: ls(1567) + ' (Esc)', "aria-label": ls(1567) + ' (Esc)' }, 393 React.createElement("i", { className: "fa fa-fw fa-close", "aria-hidden": "true" })), 394 React.createElement("button", { className: "pswp__button pswp__button--share", title: "Share", style: { display: 'none' } }), 395 !MobileAppBridge.isActive() && (React.createElement("button", { className: "pswp__button pswp__button--fs", title: ls(8343), "aria-label": ls(8343) }, 396 React.createElement("i", { className: "material-icons", "aria-hidden": "true" }, "fullscreen"))), 397 React.createElement("button", { className: "pswp__button", title: ls(1217).ucfirst(), "aria-label": ls(1217).ucfirst(), style: { background: 'none', color: '#fff' }, onClick: rotateRightClick }, 398 React.createElement("i", { className: "fa fa-fw fa-rotate-right" })), 399 React.createElement("button", { className: "pswp__button", title: ls(1216).ucfirst(), "aria-label": ls(1216).ucfirst(), style: { background: 'none', color: '#fff' }, onClick: rotateLeftClick }, 400 React.createElement("i", { className: "fa fa-fw fa-rotate-left" })), 401 React.createElement("button", { className: "pswp__button pswp__button--zoom", title: ls(10625), "aria-label": ls(10625) }, 402 React.createElement("i", { className: "fa fa-fw fa-search-plus", "aria-hidden": "true" })), 403 React.createElement("a", tslib_1.__assign({ href: ETestUtils.fixIOSSrc(((((_e = currentItemRef.current) === null || _e === void 0 ? void 0 : _e.fileSrc) ? (_f = currentItemRef.current) === null || _f === void 0 ? void 0 : _f.fileSrc : (_g = currentItemRef.current) === null || _g === void 0 ? void 0 : _g.src) || "").toString().replace('/cloud?', '/clouddownloadimg?').replace('/elearning/ruqjzfpv', '/elearning/ruqjzfpvdownload')), target: "_blank", className: "pswp__button", title: ls(3644), "aria-label": ls(3644), style: { background: 'none', color: '#fff' } }, tapOrClick(downloadClick)), 404 React.createElement("i", { className: "fa fa-fw fa-download", "aria-hidden": "true" })), 405 MobileAppBridge.isActive() && !MobileAppBridge.isIOS() && MobileAppBridge.compareVersion(nativeAppVersion, '2.2.0') >= 0 && (React.createElement("a", tslib_1.__assign({ "data-url": ETestUtils.fixIOSSrc(((((_h = currentItemRef.current) === null || _h === void 0 ? void 0 : _h.fileSrc) ? (_j = currentItemRef.current) === null || _j === void 0 ? void 0 : _j.fileSrc : (_k = currentItemRef.current) === null || _k === void 0 ? void 0 : _k.src) || "").toString().replace('/elearning/ruqjzfpv', '/elearning/ruqjzfpvdownload')), className: "pswp__button", title: ls(3644), "aria-label": ls(3644), style: { background: 'none', color: '#fff' } }, tapOrClick(shareClick)), 406 React.createElement("i", { className: "material-icons", "aria-hidden": "true" }, "share"))), 407 props.showAnswerComment && !MobileAppBridge.isActive() && (React.createElement("a", { className: "pswp__button", title: ls(10623), "aria-label": ls(10623), style: { background: 'none', color: '#fff' }, onClick: editImageClick }, 408 React.createElement("i", { className: "fa fa-fw fa-pencil", "aria-hidden": "true" }))), 409 true && (React.createElement("a", { className: "pswp__button showOriginalBtn", title: ls(10624), "aria-label": ls(10624), style: { background: 'none', color: '#fff' }, onClick: showOrigClick }, 410 React.createElement("i", { className: "fa fa-fw fa-object-group", "aria-hidden": "true" }))), 411 React.createElement("div", { className: "pswp__preloader" }, 412 React.createElement("div", { className: "pswp__preloader__icn" }, 413 React.createElement("div", { className: "pswp__preloader__cut" }, 414 React.createElement("div", { className: "pswp__preloader__donut" }))))), 415 React.createElement("div", { className: "pswp__share-modal pswp__share-modal--hidden pswp__single-tap" }, 416 React.createElement("div", { className: "pswp__share-tooltip" })), 417 React.createElement("button", { className: "pswp__button pswp__button--arrow--left", title: ls(3556) }), 418 React.createElement("button", { className: "pswp__button pswp__button--arrow--right", title: ls(4271) }), 419 React.createElement("div", { className: "pswp__caption" }, 420 React.createElement("div", { className: "pswp__caption__center" }))))), 421 props.showAnswerComment && (React.createElement("div", { className: "etest-pswp-comment-outer", ref: commentElemRef }, 422 React.createElement("div", { className: "etest-pswp-comment-inner" }, 423 React.createElement("div", { className: "etest-pswp-question-index" }, bodyObj && bodyObj.questionIndex ? bodyObj.questionIndex + '/' + bodyObj.maxQuestions : ''), 424 React.createElement("div", { className: "textareaOuter" }, 425 React.createElement("textarea", { className: "etest-pswp-comment-field", readOnly: !!props.answerCommentReadonly, value: answerComment, onChange: answerCommentChange, placeholder: ls(8394) }), 426 React.createElement("div", { className: "etest-atts-selector" })), 427 React.createElement("div", { className: "etest-pswp-score-outer" }, 428 React.createElement("div", { className: "etest-pswp-score-label" }, ls(9408)), 429 React.createElement("input", { className: "etest-pswp-comment-field etest-pswp-body-field", type: "text", value: body, onChange: bodyChange, placeholder: "" }), 430 React.createElement("a", { className: "etest-pswp-changebody-btn", onClick: changeMaxBodyClick, title: ls(8385) }, maxBody ? ' / ' + (Math.round(maxBody * 100) / 100).toString() : '')), 431 React.createElement("input", { type: "button", className: "flat-button etest-pwsp-comment-button " + (origComment.comment != answerComment || origComment.body != body || origComment.maxBody != maxBody || !ETestUtils.isEqual(answerCommentAtts, origComment.atts) ? 'flat-button-greenm' : 'etest-pswp-button-trblack'), onClick: saveClick, value: ls(1529), style: { textTransform: 'uppercase' } })))), 432 MobileAppBridge.isActive() && (React.createElement("a", tslib_1.__assign({ className: "app-header-action app-global-goback" }, tapOrClick(closeClick), { title: ls(1567) + '', "aria-label": ls(1567) + '' }), 433 React.createElement("i", { className: "material-icons", "aria-hidden": "true" }, ertl('arrow_back', 'arrow_forward')))))); 434} 435exports.AscPhotoSwipe = AscPhotoSwipe; 436(function (global) { 437 function UTF8toUnicode(str) { 438 return str.replace(/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g, function (str) { 439 return decodeURIComponent(escape(str)); 440 }); 441 } 442 function UnicodetoUTF8(str) { 443 return unescape(encodeURIComponent(str)); 444 } 445 var base64_encode = function () { 446 var BASE64CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
446+/'; 447 return function (str) { 448 str = UnicodetoUTF8(str); 449 if (global.btoa) 450 return global.btoa(str); 451 var r = [], i = 0, t = 0, len = str.length, c; 452 for (; i < len; i++) { 453 if (++t === 3) 454 t = 0; 455 c = str.charCodeAt(i); 456 switch (t) { 457 case 1: 458 r.push(c >> 2 & 0x3F); 459 break; 460 case 2: 461 r.push((str.charCodeAt(i - 1) << 4 | c >> 4) & 0x3F); 462 break; 463 case 0: 464 r.push((str.charCodeAt(i - 1) << 2 | c >> 6) & 0x3F); 465 r.push(c & 0x3F); 466 break; 467 } 468 if (i === len - 1 && t > 0) { 469 r.push(c << ((3 - t) << 1) & 0x3F); 470 } 471 } 472 for (i = 0, len = r.length; i < len; i++) 473 r[i] = BASE64CHARS.charAt(r[i]); 474 if (t) 475 while (3 - t++ > 0) 476 r.push('='); 477 return r.join(''); 478 }; 479 }(); 480 var base64_decode = function () { 481 var BASE64DECODER = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51]; 482 return function (str) { 483 if (global.atob) 484 return UTF8toUnicode(global.atob(str)); 485 var r = [], i = 0, t = 0, c, n, len, off; 486 i = 0; 487 n = BASE64DECODER[str.charCodeAt(0)]; 488 len = str.length; 489 while (i < len) { 490 t++; 491 c = n; 492 n = BASE64DECODER[str.charCodeAt(++i)]; 493 if (n === -1) { 494 i = len; 495 n = 0; 496 } 497 r.push(c << (t << 1) & 0xFF | n >> ((3 - t) << 1)); 498 if (t === 3) { 499 i++; 500 n = BASE64DECODER[str.charCodeAt(i)]; 501 t = 0; 502 } 503 } 504 return UTF8toUnicode(String.fromCharCode.apply(String, r)); 505 }; 506 }(); 507 var XBase64 = { 508 encode: base64_encode, 509 decode: base64_decode 510 }; 511 global.XBase64 = XBase64; 512})(window);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.