Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 1023 vs 1024 for /trunk/Source Code/Libs/imgui/examples/addons_examples/html/main3.html

Diff revisions: vs.
  @@ -234,19 +234,127 @@
234 234
235 235
236 236 <script>
237 + var ASSERTIONS = 0;
238 + // All functions here should be maybeExported from jsifier.js
237 239
238 - (function() {
239 - var memoryInitializer = 'main3.html.mem';
240 - if (typeof Module['locateFile'] === 'function') {
241 - memoryInitializer = Module['locateFile'](memoryInitializer);
242 - } else if (Module['memoryInitializerPrefixURL']) {
243 - memoryInitializer = Module['memoryInitializerPrefixURL'] + memoryInitializer;
244 - }
245 - var meminitXHR = Module['memoryInitializerRequest'] = new XMLHttpRequest();
246 - meminitXHR.open('GET', memoryInitializer, true);
247 - meminitXHR.responseType = 'arraybuffer';
248 - meminitXHR.send(null);
249 - })();
240 + // Copied from https://github.com/strophe/strophejs/blob/e06d027/src/polyfills.js#L149
241 +
242 + // This code was written by Tyler Akins and has been placed in the
243 + // public domain. It would be nice if you left this header intact.
244 + // Base64 code from Tyler Akins -- http://rumkin.com
245 +
246 + var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
247 +
248 + var decodeBase64 = typeof atob === 'function' ? atob : function (input) {
249 + /**
250 + * Decodes a base64 string.
251 + * @param {String} input The string to decode.
252 + */
253 + var output = '';
254 + var chr1, chr2, chr3;
255 + var enc1, enc2, enc3, enc4;
256 + var i = 0;
257 + // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
258 + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
259 + do {
260 + enc1 = keyStr.indexOf(input.charAt(i++));
261 + enc2 = keyStr.indexOf(input.charAt(i++));
262 + enc3 = keyStr.indexOf(input.charAt(i++));
263 + enc4 = keyStr.indexOf(input.charAt(i++));
264 +
265 + chr1 = (enc1 << 2) | (enc2 >> 4);
266 + chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
267 + chr3 = ((enc3 & 3) << 6) | enc4;
268 +
269 + output = output + String.fromCharCode(chr1);
270 +
271 + if (enc3 !== 64) {
272 + output = output + String.fromCharCode(chr2);
273 + }
274 + if (enc4 !== 64) {
275 + output = output + String.fromCharCode(chr3);
276 + }
277 + } while (i < input.length);
278 + return output;
279 + };
280 +
281 + // Converts a string of base64 into a byte array.
282 + // Throws error on invalid input.
283 + function intArrayFromBase64(s) {
284 + if (typeof ENVIRONMENT_IS_NODE === 'boolean' && ENVIRONMENT_IS_NODE) {
285 + var buf;
286 + try {
287 + buf = Buffer.from(s, 'base64');
288 + } catch (_) {
289 + buf = new Buffer(s, 'base64');
290 + }
291 + return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
292 + }
293 +
294 + try {
295 + var decoded = decodeBase64(s);
296 + var bytes = new Uint8Array(decoded.length);
297 + for (var i = 0 ; i < decoded.length ; ++i) {
298 + bytes[i] = decoded.charCodeAt(i);
299 + }
300 + return bytes;
301 + } catch (_) {
302 + throw new Error('Converting base64 string to bytes failed.');
303 + }
304 + }
305 +
306 + // If filename is a base64 data URI, parses and returns data (Buffer on node,
307 + // Uint8Array otherwise). If filename is not a base64 data URI, returns undefined.
308 + function tryParseAsDataURI(filename) {
309 + var dataURIPrefix = 'data:application/octet-stream;base64,';
310 +
311 + if (!(
312 + String.prototype.startsWith ?
313 + filename.startsWith(dataURIPrefix) :
314 + filename.indexOf(dataURIPrefix) === 0
315 + )) {
316 + return;
317 + }
318 +
319 + return intArrayFromBase64(filename.slice(dataURIPrefix.length));
320 + }
321 + // All functions here should be maybeExported from jsifier.js
322 +
323 + /** @type {function(string, boolean=, number=)} */
324 + function intArrayFromString(stringy, dontAddNull, length) {
325 + var len = length > 0 ? length : lengthBytesUTF8(stringy)+1;
326 + var u8array = new Array(len);
327 + var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
328 + if (dontAddNull) u8array.length = numBytesWritten;
329 + return u8array;
330 + }
331 +
332 + function intArrayToString(array) {
333 + var ret = [];
334 + for (var i = 0; i < array.length; i++) {
335 + var chr = array[i];
336 + if (chr > 0xFF) {
337 + if (ASSERTIONS) {
338 + assert(false, 'Character code ' + chr + ' (' + String.fromCharCode(chr) + ') at offset ' + i + ' not in 0x00-0xFF.');
339 + }
340 + chr &= 0xFF;
341 + }
342 + ret.push(String.fromCharCode(chr));
343 + }
344 + return ret.join('');
345 + }
346 +
347 + var memoryInitializer = 'main3.html.mem';
348 + if (typeof Module['locateFile'] === 'function') {
349 + memoryInitializer = Module['locateFile'](memoryInitializer);
350 + } else if (Module['memoryInitializerPrefixURL']) {
351 + memoryInitializer = Module['memoryInitializerPrefixURL'] + memoryInitializer;
352 + }
353 + Module['memoryInitializerRequestURL'] = memoryInitializer;
354 + var meminitXHR = Module['memoryInitializerRequest'] = new XMLHttpRequest();
355 + meminitXHR.open('GET', memoryInitializer, true);
356 + meminitXHR.responseType = 'arraybuffer';
357 + meminitXHR.send(null);
250 358
251 359 var script = document.createElement('script');
252 360 script.src = "main3.js";