This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page showHeader="false" applyBodyTag="false" applyHtmlTag="false" docType="html-5.0"> | |
<html> | |
<head> | |
<title>Embed API Demo</title> | |
</head> | |
<body> | |
<!-- Step 1: Create the containing elements. --> | |
<section id="auth-button"></section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page showHeader="false" | |
standardStylesheets="false" | |
sidebar="false" | |
contentType="text/html" | |
applyBodyTag="false" | |
applyHtmlTag="false" | |
cache="true" | |
docType="html-5.0"> | |
<html> | |
<head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateFileList() { | |
bucket.listObjects({ Prefix: getPrefix() }, function(err, resp) { | |
if (err) { throw err; } | |
$('#fileList').empty(); | |
if (resp.Contents.length === 0) { | |
$('<li>').text('No files available').appendTo($('#fileList')); | |
} else { | |
$.each(resp.Contents, function(i, content) { | |
var key = content.Key; | |
var fileName = key.split('/').pop(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page standardController="Opportunity"> | |
<apex:iframe frameborder="false" width="100%" height="200" scrolling="true" | |
src="/idp/login?app=0spi0000000Kyou" /> | |
<script> | |
window.recordId = '{!id}'; | |
</script> | |
</apex:page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function initEventHandlers() { | |
// ... | |
// | |
$('#fileList').on('click', 'a.delete-link', function() { | |
var key = $(this).parents('li').data('key'); | |
if (confirm('Are you sure you want to delete the file "' + key + '" ?')) { | |
bucket.deleteObject({ Key: key }, function (err) { | |
updateFileList(); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateFileList() { | |
bucket.listObjects({}, function(err, resp) { | |
if (err) { throw err; } | |
$('#fileList').empty(); | |
$.each(resp.Contents, function(i, content) { | |
var viewLink = $('<a href="#" class="view-link">').text(content.Key); | |
var deleteLink = $('<a href="#" class="delete-link">').text('Delete'); | |
$('<li>').data('key', content.Key) | |
.append(viewLink) | |
.append(' [') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function uploadFile(files) { | |
if (files && files.length > 0) { | |
var file = files[0]; | |
var params = { Key: getPrefix() + file.name, ContentType: file.type, Body: file }; | |
bucket.putObject(params, function(err, resp) { | |
updateFileList(); | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getPrefix() { | |
try { | |
return window.parent.recordId ? window.parent.recordId + '/' : ''; | |
} catch(e) { | |
return ''; // when access is not allowed to parent window object (maybe in different origin) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<body> | |
<input type="hidden" id="samlResponse" value="{!$CurrentPage.parameters.SAMLResponse}" /> | |
<div> | |
Select File to Upload: <input type="file" id="fileSelect" /> | |
</div> | |
<ul id="fileList"></ul> | |
</body> | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateFileList() { | |
bucket.listObjects({}, function(err, resp) { | |
if (err) { throw err; } | |
$('#fileList').empty(); | |
$.each(resp.Contents, function(i, content) { | |
var viewLink = $('<a href="#" class="view-link">').text(content.Key); | |
$('<li>').data('key', content.Key) | |
.append(viewLink) | |
.appendTo($('#fileList')); | |
}); |