This file contains hidden or 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 controller="ZipOpportunities" showHeader="true" sidebar="true"> | |
<head> | |
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script> | |
<script type="text/javascript"> | |
var j$ = jQuery.noConflict(); | |
j$(document).ready(function() { | |
var accountId = '{!accountId}'; // Get Account Id from the controller |
This file contains hidden or 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
public with sharing class ZipOpportunities { | |
public String accountId {get; set;} | |
public String zipFileName {get; set;} | |
/** | |
* Query for the Account using the parameter in the query string | |
* Set the filename for the ZIP file | |
**/ | |
public ZipOpportunities() { |
This file contains hidden or 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 controller="ChatterPage" showHeader="false" sidebar="false" standardStylesheets="true"> | |
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script> | |
<script> | |
// Capture all clicks on <a> elements and change the URL for the whole window | |
// Some <a> elements are used for JavaScript function calls, so only capture them | |
// when the URL starts with the / character. | |
jQuery(document).ready(function($) { | |
$('#chatter-container').contents().on('click', 'a', function(e) { | |
if($(this).attr('href').charAt(0) == '/') { |
This file contains hidden or 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
app.get('/accounts', function(req, res) { | |
// if auth has not been set, redirect to index | |
if (!req.session.accessToken || !req.session.instanceUrl) { res.redirect('/'); } | |
var query = 'SELECT id, name FROM account LIMIT 10'; | |
// open connection with client's stored OAuth details | |
var conn = new jsforce.Connection({ | |
accessToken: req.session.accessToken, | |
instanceUrl: req.session.instanceUrl | |
}); |
This file contains hidden or 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
/* SF OAuth request, redirect to SF login */ | |
app.get('/oauth/auth', function(req, res) { | |
res.redirect(oauth2.getAuthorizationUrl({scope: 'api id web'})); | |
}); | |
/* OAuth callback from SF, pass received auth code and get access token */ | |
app.get('/oauth/callback', function(req, res) { | |
var conn = new jsforce.Connection({oauth2: oauth2}); | |
var code = req.query.code; | |
conn.authorize(code, function(err, userInfo) { |
This file contains hidden or 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
// Salesforce OAuth2 client information | |
var oauth2 = new jsforce.OAuth2({ | |
clientId: ‘client id string’ | |
clientSecret: ‘client secret string’, | |
redirectUri: 'callback url' | |
}); |