mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Fixed CORs issues with running web workers. Changed URLs for workers and scripts imported inside workers to Blob URLs.
This commit is contained in:
parent
90c5f7d5c2
commit
15393324b0
@ -40,13 +40,14 @@
|
|||||||
addEventListener('load', function () {
|
addEventListener('load', function () {
|
||||||
var code = document.querySelector('#code');
|
var code = document.querySelector('#code');
|
||||||
var language = document.querySelector('#syntaxLanguage');
|
var language = document.querySelector('#syntaxLanguage');
|
||||||
var worker = new Worker('@Scripts.Url("~/bundles/syntaxWorker")');
|
var worker = new Worker(GenerateBlobURL('@Scripts.Url("~/bundles/syntaxWorker")'));
|
||||||
worker.onmessage = function (event) {
|
worker.onmessage = function (event) {
|
||||||
code.innerHTML = event.data.value;
|
code.innerHTML = event.data.value;
|
||||||
language.innerText = event.data.language;
|
language.innerText = event.data.language;
|
||||||
}
|
}
|
||||||
|
var scriptBlob = GenerateBlobURL('@Scripts.Url("~/bundles/highlight")');
|
||||||
var obj = {
|
var obj = {
|
||||||
script: '@Scripts.Url("~/bundles/highlight")',
|
script: scriptBlob,
|
||||||
code: code.textContent
|
code: code.textContent
|
||||||
};
|
};
|
||||||
worker.postMessage(obj);
|
worker.postMessage(obj);
|
||||||
|
@ -26,10 +26,11 @@
|
|||||||
<script>
|
<script>
|
||||||
addEventListener('load', function () {
|
addEventListener('load', function () {
|
||||||
var code = document.querySelector('#code');
|
var code = document.querySelector('#code');
|
||||||
var worker = new Worker('@Scripts.Url("~/bundles/syntaxWorker")');
|
var worker = new Worker(GenerateBlobURL('@Scripts.Url("~/bundles/syntaxWorker")'));
|
||||||
worker.onmessage = function (event) {
|
worker.onmessage = function (event) {
|
||||||
code.innerHTML = event.data.value;
|
code.innerHTML = event.data.value;
|
||||||
}
|
}
|
||||||
|
var scriptBlob = GenerateBlobURL('@Scripts.Url("~/bundles/highlight")');
|
||||||
var obj = {
|
var obj = {
|
||||||
script: '@Scripts.Url("~/bundles/highlight")',
|
script: '@Scripts.Url("~/bundles/highlight")',
|
||||||
code: code.textContent
|
code: code.textContent
|
||||||
|
@ -199,7 +199,7 @@ function encryptFile(file, callback) {
|
|||||||
callback(e.target.result, keyStr, ivStr, filetype, fileExt, fileID, saveKey, serverSideEncrypt);
|
callback(e.target.result, keyStr, ivStr, filetype, fileExt, fileID, saveKey, serverSideEncrypt);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var worker = new Worker(encScriptSrc);
|
var worker = new Worker(GenerateBlobURL(encScriptSrc));
|
||||||
|
|
||||||
worker.addEventListener('message', function (e) {
|
worker.addEventListener('message', function (e) {
|
||||||
switch (e.data.cmd) {
|
switch (e.data.cmd) {
|
||||||
@ -227,11 +227,14 @@ function encryptFile(file, callback) {
|
|||||||
$("#progress-" + fileID).children('.progress-bar').html('Error Occured');
|
$("#progress-" + fileID).children('.progress-bar').html('Error Occured');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate the script to include as a blob
|
||||||
|
var scriptBlob = GenerateBlobURL(aesScriptSrc);
|
||||||
|
|
||||||
// Execute worker with data
|
// Execute worker with data
|
||||||
var objData =
|
var objData =
|
||||||
{
|
{
|
||||||
cmd: 'encrypt',
|
cmd: 'encrypt',
|
||||||
script: aesScriptSrc,
|
script: scriptBlob,
|
||||||
key: keyStr,
|
key: keyStr,
|
||||||
iv: ivStr,
|
iv: ivStr,
|
||||||
chunkSize: chunkSize,
|
chunkSize: chunkSize,
|
||||||
|
@ -18,7 +18,7 @@ by editing this MSBuild file. In order to learn more about this please visit htt
|
|||||||
<SkipExtraFilesOnServer>False</SkipExtraFilesOnServer>
|
<SkipExtraFilesOnServer>False</SkipExtraFilesOnServer>
|
||||||
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
|
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
|
||||||
<EnableMSDeployBackup>True</EnableMSDeployBackup>
|
<EnableMSDeployBackup>True</EnableMSDeployBackup>
|
||||||
<UserName>Administrator</UserName>
|
<UserName>Uncled1023</UserName>
|
||||||
<_SavePWD>True</_SavePWD>
|
<_SavePWD>True</_SavePWD>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
@ -173,6 +173,21 @@ function getAnchor() {
|
|||||||
return (urlParts.length > 1) ? urlParts[1] : null;
|
return (urlParts.length > 1) ? urlParts[1] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function GenerateBlobURL(url) {
|
||||||
|
var cachedBlob = null;
|
||||||
|
jQuery.ajax({
|
||||||
|
url: url,
|
||||||
|
success: function (result) {
|
||||||
|
var workerJSBlob = new Blob([result], {
|
||||||
|
type: "text/javascript"
|
||||||
|
});
|
||||||
|
cachedBlob = window.URL.createObjectURL(workerJSBlob);
|
||||||
|
},
|
||||||
|
async: false
|
||||||
|
});
|
||||||
|
return cachedBlob;
|
||||||
|
}
|
||||||
|
|
||||||
AddAntiForgeryToken = function (data) {
|
AddAntiForgeryToken = function (data) {
|
||||||
data.__RequestVerificationToken = $('#__AjaxAntiForgeryForm input[name=__RequestVerificationToken]').val();
|
data.__RequestVerificationToken = $('#__AjaxAntiForgeryForm input[name=__RequestVerificationToken]').val();
|
||||||
return data;
|
return data;
|
||||||
|
Loading…
Reference in New Issue
Block a user