Browse Source

Fixed upload/paste create/add to vault not passing variable correctly.

pull/50/head
Teknikode 6 years ago
parent
commit
c17637ccad
  1. 4
      Teknik/Areas/Paste/Scripts/Paste.js
  2. 6
      Teknik/Areas/Upload/Scripts/Upload.js
  3. 6
      Teknik/Areas/Vault/Controllers/VaultController.cs
  4. 8
      Teknik/Scripts/Common.js

4
Teknik/Areas/Paste/Scripts/Paste.js

@ -12,7 +12,7 @@ function linkCreateVault(element) { @@ -12,7 +12,7 @@ function linkCreateVault(element) {
element.click(function () {
var pasteUrl = $(this).data('paste-url');
var pasteTitle = $(this).data('paste-title');
window.open(createVaultURL + '&items=' + encodeURIComponent(pasteUrl + ':' + pasteTitle), '_blank');
window.open(addParamsToUrl(createVaultURL, { items: encodeURIComponent(pasteUrl + ':' + pasteTitle) }), '_blank');
});
}
@ -21,6 +21,6 @@ function linkAddToVault(element) { @@ -21,6 +21,6 @@ function linkAddToVault(element) {
var addToVaultURL = $(this).data('add-to-vault-url');
var pasteUrl = $(this).data('paste-url');
var pasteTitle = $(this).data('paste-title');
window.open(addToVaultURL + '&items=' + encodeURIComponent(pasteUrl + ':' + pasteTitle), '_blank');
window.open(addParamsToUrl(addToVaultURL, { items: encodeURIComponent(pasteUrl + ':' + pasteTitle) }), '_blank');
});
}

6
Teknik/Areas/Upload/Scripts/Upload.js

@ -94,7 +94,8 @@ function linkCreateVault(element) { @@ -94,7 +94,8 @@ function linkCreateVault(element) {
});
if (allUploads.length > 0) {
var urlList = allUploads.join();
window.open(createVaultURL + '&items=' + encodeURIComponent(urlList), '_blank');
var finalUrl = addParamsToUrl(createVaultURL, { items: encodeURIComponent(urlList) });
window.open(finalUrl, '_blank');
}
else {
window.open(createVaultURL, '_blank');
@ -118,7 +119,8 @@ function linkAddToVault(element) { @@ -118,7 +119,8 @@ function linkAddToVault(element) {
});
if (allUploads.length > 0) {
var urlList = allUploads.join();
window.open(addToVaultURL + '&items=' + encodeURIComponent(urlList), '_blank');
var finalUrl = addParamsToUrl(addToVaultURL, { items: encodeURIComponent(urlList) });
window.open(finalUrl, '_blank');
}
else {
window.open(addToVaultURL, '_blank');

6
Teknik/Areas/Vault/Controllers/VaultController.cs

@ -113,7 +113,8 @@ namespace Teknik.Areas.Vault.Controllers @@ -113,7 +113,8 @@ namespace Teknik.Areas.Vault.Controllers
ViewBag.Title = "Create Vault";
ModifyVaultViewModel model = new ModifyVaultViewModel();
string[] allURLs = items.Split(',');
string decodedItems = HttpUtility.UrlDecode(items);
string[] allURLs = decodedItems.Split(',');
int index = 0;
foreach (string url in allURLs)
{
@ -191,7 +192,8 @@ namespace Teknik.Areas.Vault.Controllers @@ -191,7 +192,8 @@ namespace Teknik.Areas.Vault.Controllers
// If they passed any new items in via the parameters, let's add them
if (!string.IsNullOrEmpty(type) && !string.IsNullOrEmpty(items))
{
string[] allItems = items.Split(',');
string decodedItems = HttpUtility.UrlDecode(items);
string[] allItems = decodedItems.Split(',');
foreach (string newItem in allItems)
{
string[] urlInfo = newItem.Split(':');

8
Teknik/Scripts/Common.js

@ -240,6 +240,14 @@ function moveDown(item) { @@ -240,6 +240,14 @@ function moveDown(item) {
item.insertAfter(next);
});
}
function addParamsToUrl(origUrl, params) {
var paramStr = $.param(params);
var hasQuery = origUrl.indexOf("?") + 1;
var hasHash = origUrl.indexOf("#") + 1;
var appendix = (hasQuery ? "&" : "?") + paramStr;
return hasHash ? origUrl.replace("#", appendix + "#") : origUrl + appendix;
}
/***************************** TIMER Page Load *******************************/
var loopTime;
var startTime = new Date();

Loading…
Cancel
Save