diff options
author | Haakon Meland Eriksen <haakon.eriksen@far.no> | 2014-06-24 19:34:36 +0200 |
---|---|---|
committer | Haakon Meland Eriksen <haakon.eriksen@far.no> | 2014-06-24 19:34:36 +0200 |
commit | b8dc9e855af2d30f33d0f90dc13d8cad0a7b3e70 (patch) | |
tree | 718df6305bcb82c8dcb4b287a7132422e748cdfb /library/jqupload/cors | |
parent | c2d520f1be115fb3cb5da2a35eb10146cecee8aa (diff) | |
parent | a92fb0b04c3e6474ec48faf8e4cc65c382e89d66 (diff) | |
download | volse-hubzilla-b8dc9e855af2d30f33d0f90dc13d8cad0a7b3e70.tar.gz volse-hubzilla-b8dc9e855af2d30f33d0f90dc13d8cad0a7b3e70.tar.bz2 volse-hubzilla-b8dc9e855af2d30f33d0f90dc13d8cad0a7b3e70.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'library/jqupload/cors')
-rw-r--r-- | library/jqupload/cors/postmessage.html | 75 | ||||
-rw-r--r-- | library/jqupload/cors/result.html | 24 |
2 files changed, 99 insertions, 0 deletions
diff --git a/library/jqupload/cors/postmessage.html b/library/jqupload/cors/postmessage.html new file mode 100644 index 000000000..3d1448f08 --- /dev/null +++ b/library/jqupload/cors/postmessage.html @@ -0,0 +1,75 @@ +<!DOCTYPE HTML> +<!-- +/* + * jQuery File Upload Plugin postMessage API 1.2.1 + * https://github.com/blueimp/jQuery-File-Upload + * + * Copyright 2011, Sebastian Tschan + * https://blueimp.net + * + * Licensed under the MIT license: + * http://www.opensource.org/licenses/MIT + */ +--> +<html lang="en"> +<head> +<meta charset="utf-8"> +<title>jQuery File Upload Plugin postMessage API</title> +<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> +</head> +<body> +<script> +/*jslint unparam: true, regexp: true */ +/*global $, Blob, FormData, location */ +'use strict'; +var origin = /^http:\/\/example.org/, + target = new RegExp('^(http(s)?:)?\\/\\/' + location.host + '\\/'); +$(window).on('message', function (e) { + e = e.originalEvent; + var s = e.data, + xhr = $.ajaxSettings.xhr(), + f; + if (!origin.test(e.origin)) { + throw new Error('Origin "' + e.origin + '" does not match ' + origin); + } + if (!target.test(e.data.url)) { + throw new Error('Target "' + e.data.url + '" does not match ' + target); + } + $(xhr.upload).on('progress', function (ev) { + ev = ev.originalEvent; + e.source.postMessage({ + id: s.id, + type: ev.type, + timeStamp: ev.timeStamp, + lengthComputable: ev.lengthComputable, + loaded: ev.loaded, + total: ev.total + }, e.origin); + }); + s.xhr = function () { + return xhr; + }; + if (!(s.data instanceof Blob)) { + f = new FormData(); + $.each(s.data, function (i, v) { + f.append(v.name, v.value); + }); + s.data = f; + } + $.ajax(s).always(function (result, statusText, jqXHR) { + if (!jqXHR.done) { + jqXHR = result; + result = null; + } + e.source.postMessage({ + id: s.id, + status: jqXHR.status, + statusText: statusText, + result: result, + headers: jqXHR.getAllResponseHeaders() + }, e.origin); + }); +}); +</script> +</body> +</html>
\ No newline at end of file diff --git a/library/jqupload/cors/result.html b/library/jqupload/cors/result.html new file mode 100644 index 000000000..225131495 --- /dev/null +++ b/library/jqupload/cors/result.html @@ -0,0 +1,24 @@ +<!DOCTYPE HTML> +<!-- +/* + * jQuery Iframe Transport Plugin Redirect Page 2.0.1 + * https://github.com/blueimp/jQuery-File-Upload + * + * Copyright 2010, Sebastian Tschan + * https://blueimp.net + * + * Licensed under the MIT license: + * http://www.opensource.org/licenses/MIT + */ +--> +<html lang="en"> +<head> +<meta charset="utf-8"> +<title>jQuery Iframe Transport Plugin Redirect Page</title> +</head> +<body> +<script> +document.body.innerText=document.body.textContent=decodeURIComponent(window.location.search.slice(1)); +</script> +</body> +</html> |