From b7a3b320e534a86985da047f9e765b558af3125f Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 17 Jan 2018 21:22:42 -0500 Subject: [PATCH 1/4] Remove unused jquery.htmlstream Javascript library --- js/jquery.htmlstream.js | 157 ---------------------------------------- util/minifyjs.sh | 1 - 2 files changed, 158 deletions(-) delete mode 100644 js/jquery.htmlstream.js diff --git a/js/jquery.htmlstream.js b/js/jquery.htmlstream.js deleted file mode 100644 index c62c538f7..000000000 --- a/js/jquery.htmlstream.js +++ /dev/null @@ -1,157 +0,0 @@ -/* jQuery ajax stream plugin -* Version 0.1 -* Copyright (C) 2009 Chris Tarquini -* Licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License (http://creativecommons.org/licenses/by-sa/3.0/) -* Permissions beyond the scope of this license may be available by contacting petros000[at]hotmail.com. -*/ - -(function($) { - -// Save the original AJAX function -var ajax_old = $.ajax; -var get_old = $.get; -var post_old = $.post; -var active = true; -// Add our settings -$.ajaxSetup({stream: false,pollInterval: 500/*, onDataRecieved: function(){}*/ }); -$.enableAjaxStream = function(enable) -{ -if(typeof enable == 'undefined') enable = !active; -if(!enable) -{ -$.ajax = ajax_old; -$.get = get_old; -$.post = post_old; -active = false; -} -else -{ -$.ajax = ajax_stream; -$.get = ajax_get_stream; -$.post = ajax_post_stream; -active = true; -} - -} -var ajax_stream = $.ajax = function(options) -{ -//copied from original ajax function - options = jQuery.extend(true, options, jQuery.extend(true, {}, jQuery.ajaxSettings, options)); -if(options.stream) -{ -var timer = 0; -var offset = 0; -var xmlhttp = null; -var lastlen = 0; -var done = false; -var hook = function(xhr) -{ -xmlhttp = xhr; -checkagain(); -} -var fix = function(){ check('stream'); };// fixes weird bug with random numbers as arg -var checkagain = function(){if(!done) timer = setTimeout(fix,options.pollInterval);} -var check = function(status) -{ -if(typeof status == 'undefined') status = "stream"; -if(xmlhttp.status < 3) return; //only get the latest packet if data has been sent -var text = xmlhttp.responseText; -if(status == 'stream') //if we arent streaming then just flush the buffer -{ -if(text.length <= lastlen) { checkagain(); return;} -lastlength = text.length; -if(offset == text.length) { checkagain(); return;} -} -var pkt = text.substr(offset); -offset = text.length; -if($.isFunction(options.OnDataRecieved)) -{ -options.OnDataRecieved(pkt, status, xmlhttp.responseText, xmlhttp); -} -if(xmlhttp.status != 4) -checkagain(); -} -var complete = function(xhr,s) -{ -clearTimeout(timer);//done..stop polling -done = true; -// send final call -check(s); -} -// If the complete callback is set create a new callback that calls the users and outs -if($.isFunction(options.success)) -{ -var oc = options.success; -options.success = function(xhr,s){ complete(xhr,s); oc(xhr,s);}; - -} -else options.success = complete; -// Set up our hook on the beforeSend -if($.isFunction(options.beforeSend)) -{ -var obs = options.beforeSend; -options.beforeSend = function(xhr){ obs(xhr); hook(xhr);}; -} -else options.beforeSend = hook; - -} -ajax_old(options); -} - -var ajax_get_stream = $.get = function(url,data,callback,type,stream) -{ - if($.isFunction(data)) - { - var orgcb = callback; - callback = data; - if($.isFunction(orgcb)) - { - stream = orgcb; - } - data = null; - } - if($.isFunction(type)) - { - stream = type; - type = undefined; - } - var dostream = $.isFunction(stream); - return jQuery.ajax({ - type: "GET", - url: url, - data: data, - success: callback, - dataType: type, - stream: dostream, - OnDataRecieved: stream - }); - -} - -var ajax_post_stream = $.post = function(url,data,callback,type,stream) -{ - if($.isFunction(data)) - { - var orgcb = callback; - callback = data; - } - if($.isFunction(type)) - { - stream = type; - type = undefined; - } - var dostream = $.isFunction(stream); - return jQuery.ajax({ - type: "POST", - url: url, - data: data, - success: callback, - dataType: type, - stream: dostream, - OnDataRecieved: stream - }); - -} - -})(jQuery); - diff --git a/util/minifyjs.sh b/util/minifyjs.sh index b56571383..a2d53da3e 100755 --- a/util/minifyjs.sh +++ b/util/minifyjs.sh @@ -8,7 +8,6 @@ JSFILES=( "js/acl.js" "js/ajaxupload.js" "js/country.js" - "js/jquery.htmlstream.js" "js/main.js" "js/webtoolkit.base64.js" "view/theme/frost/js/acl.js" From f32eb0292969d3463f689c42181d12f5969da9ca Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 17 Jan 2018 21:23:03 -0500 Subject: [PATCH 2/4] Add bower/base64 to Composer --- composer.json | 3 ++- composer.lock | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 31d5db04a..c48a44a5e 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,8 @@ "paragonie/random_compat": "^2.0", "smarty/smarty": "^3.1", "michelf/php-markdown": "^1.7", - "fxp/composer-asset-plugin": "~1.3" + "fxp/composer-asset-plugin": "~1.3", + "bower-asset/base64": "^1.0" }, "repositories": [ { diff --git a/composer.lock b/composer.lock index 47160f952..a2aefe567 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,39 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "7a5d27cfcae62b1d9d10a10a343c0c96", + "content-hash": "fcf1ea05c07796ccf5ef2c437e6acffd", "packages": [ + { + "name": "bower-asset/base64", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/davidchambers/Base64.js.git", + "reference": "b2d49f347ed1bce61000a82769bffc837b7c79dc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/davidchambers/Base64.js/zipball/b2d49f347ed1bce61000a82769bffc837b7c79dc", + "reference": "b2d49f347ed1bce61000a82769bffc837b7c79dc", + "shasum": "" + }, + "type": "bower-asset-library", + "extra": { + "bower-asset-main": "./base64.js", + "bower-asset-ignore": [ + "**/.*", + "Makefile", + "coverage/", + "scripts/", + "test/" + ] + }, + "license": [ + "WTFPL" + ], + "description": "Base64 encoding and decoding", + "time": "2017-03-25T21:16:21+00:00" + }, { "name": "defuse/php-encryption", "version": "v1.2.1", From 0d9595d80a9c2ce5cab80ce3513f769f8a7bfbf6 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 17 Jan 2018 21:23:51 -0500 Subject: [PATCH 3/4] Update all references to webtoolkit.base64 --- util/minifyjs.sh | 2 +- view/templates/head.tpl | 2 +- view/templates/oembed_video.tpl | 2 +- view/theme/frio/templates/head.tpl | 2 +- view/theme/frost-mobile/templates/end.tpl | 2 +- view/theme/frost/templates/end.tpl | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/util/minifyjs.sh b/util/minifyjs.sh index a2d53da3e..6341860b1 100755 --- a/util/minifyjs.sh +++ b/util/minifyjs.sh @@ -9,7 +9,7 @@ JSFILES=( "js/ajaxupload.js" "js/country.js" "js/main.js" - "js/webtoolkit.base64.js" + "vendor/asset/base64/base64.min.js" "view/theme/frost/js/acl.js" "view/theme/frost/js/jquery.divgrow-1.3.1.f1.js" "view/theme/frost/js/main.js" diff --git a/view/templates/head.tpl b/view/templates/head.tpl index 559135ba1..c95f2cfa0 100644 --- a/view/templates/head.tpl +++ b/view/templates/head.tpl @@ -45,7 +45,7 @@ - + - + diff --git a/view/theme/frost-mobile/templates/end.tpl b/view/theme/frost-mobile/templates/end.tpl index 04416ad00..a1bc5129b 100644 --- a/view/theme/frost-mobile/templates/end.tpl +++ b/view/theme/frost-mobile/templates/end.tpl @@ -10,7 +10,7 @@ - + diff --git a/view/theme/frost/templates/end.tpl b/view/theme/frost/templates/end.tpl index b9768ba89..305a13281 100644 --- a/view/theme/frost/templates/end.tpl +++ b/view/theme/frost/templates/end.tpl @@ -12,7 +12,7 @@ - + From 8704a36682935d9a20e42fc7505243a6853a1c4f Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 17 Jan 2018 21:24:04 -0500 Subject: [PATCH 4/4] Remove js/webtoolkit.base64 --- js/webtoolkit.base64.js | 142 ---------------------------------------- 1 file changed, 142 deletions(-) delete mode 100644 js/webtoolkit.base64.js diff --git a/js/webtoolkit.base64.js b/js/webtoolkit.base64.js deleted file mode 100644 index 5fa3c1ed7..000000000 --- a/js/webtoolkit.base64.js +++ /dev/null @@ -1,142 +0,0 @@ -/** -* -* Base64 encode / decode -* http://www.webtoolkit.info/ -* -**/ - -var Base64 = { - - // private property - _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", - - // public method for encoding - encode : function (input) { - var output = ""; - var chr1, chr2, chr3, enc1, enc2, enc3, enc4; - var i = 0; - - input = Base64._utf8_encode(input); - - while (i < input.length) { - - chr1 = input.charCodeAt(i++); - chr2 = input.charCodeAt(i++); - chr3 = input.charCodeAt(i++); - - enc1 = chr1 >> 2; - enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); - enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); - enc4 = chr3 & 63; - - if (isNaN(chr2)) { - enc3 = enc4 = 64; - } else if (isNaN(chr3)) { - enc4 = 64; - } - - output = output + - this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + - this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); - - } - - return output; - }, - - // public method for decoding - decode : function (input) { - var output = ""; - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0; - - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); - - while (i < input.length) { - - enc1 = this._keyStr.indexOf(input.charAt(i++)); - enc2 = this._keyStr.indexOf(input.charAt(i++)); - enc3 = this._keyStr.indexOf(input.charAt(i++)); - enc4 = this._keyStr.indexOf(input.charAt(i++)); - - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; - - output = output + String.fromCharCode(chr1); - - if (enc3 != 64) { - output = output + String.fromCharCode(chr2); - } - if (enc4 != 64) { - output = output + String.fromCharCode(chr3); - } - - } - - output = Base64._utf8_decode(output); - - return output; - - }, - - // private method for UTF-8 encoding - _utf8_encode : function (string) { - string = string.replace(/\r\n/g,"\n"); - var utftext = ""; - - for (var n = 0; n < string.length; n++) { - - var c = string.charCodeAt(n); - - if (c < 128) { - utftext += String.fromCharCode(c); - } - else if((c > 127) && (c < 2048)) { - utftext += String.fromCharCode((c >> 6) | 192); - utftext += String.fromCharCode((c & 63) | 128); - } - else { - utftext += String.fromCharCode((c >> 12) | 224); - utftext += String.fromCharCode(((c >> 6) & 63) | 128); - utftext += String.fromCharCode((c & 63) | 128); - } - - } - - return utftext; - }, - - // private method for UTF-8 decoding - _utf8_decode : function (utftext) { - var string = ""; - var i = 0; - var c = c1 = c2 = 0; - - while ( i < utftext.length ) { - - c = utftext.charCodeAt(i); - - if (c < 128) { - string += String.fromCharCode(c); - i++; - } - else if((c > 191) && (c < 224)) { - c2 = utftext.charCodeAt(i+1); - string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); - i += 2; - } - else { - c2 = utftext.charCodeAt(i+1); - c3 = utftext.charCodeAt(i+2); - string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); - i += 3; - } - - } - - return string; - } - -}