Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
53 lines (46 sloc) 2.1 KB
<html>
<title>PitchPrint Sample SDK</title>
<head>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://pitchprint.io/rsc/js/client.js"></script>
</head>
<body>
<div id="pp_loader_div"><img src="https://pitchprint.io/rsc/images/loaders/spinner_new.svg" ></div>
<button id="launch_btn" >Launch Designer</button>
<div id="pp_preview_div"></div>
</body>
<script>
(function() {
//Get handles to the UI elements we'll be using
var _launchButton = document.getElementById('launch_btn'),
_previewDiv = document.getElementById('pp_preview_div'),
_loaderDiv = document.getElementById('pp_loader_div');
//Disable the Launch button until PitchPrint is ready for use
_launchButton.setAttribute('disabled', 'disabled');
/*Initialize PitchPrint.
Kindly read more here on the options.. https://docs.pitchprint.com
*/
var ppclient = new PitchPrintClient({
apiKey: 'f80b84b4eb5cc81a140cb90f52e824f6', //Kinldy provide your own APIKey
designId: '3d8f3899904ef2392795c681091600d0', //Change this to your designId
custom: true
});
//Function to run once the app is validated (ready to be used)
var appValidated = () => {
_launchButton.removeAttribute('disabled'); //Enable the Launch button
_launchButton.onclick = () => ppclient.showApp(); //Attach event listener to the button when clicked to show the app
_loaderDiv.style.display = 'none'; //Hide the loader
};
//Function to run once the user has saved their project
var projectSaved = (_val) => {
let _data = _val.data; //You can console.log the _data varaible to see all that's passed down
if (_data && _data.previews && _data.previews.length) {
_previewDiv.innerHTML = _data.previews.reduce((_str, _prev) => `${_str}<img src="${_prev}">`, ''); //Show the preview images
}
};
//Attach events to the app. You can see a list of all the events here: https://docs.pitchprint.com
ppclient.on('app-validated', appValidated);
ppclient.on('project-saved', projectSaved);
})();
</script>
</html>