I am trying to create new bigger presentation by appending copies of smaller presentations (modules of 3-4 slides). Though I know how to go about doing this, I find the performance to be less than satisfactory. It takes up to 4-5 minutes just to build the final presentation. I am wondering whether there is a way to speed this up. Could someone look at the POC I have so far and point out where I am going wrong? Any help is greatly appreciated!
//This function should run on open of document
function onOpen() {
var ui = SlidesApp
.getUi()
.createMenu('Modules')
.addItem('Create new deck...', 'createNewDeck')
.addToUi();
}
function createNewDeck() {
var html = HtmlService
.createHtmlOutputFromFile('Page')
.setTitle('Training Deck Builder')
.setWidth(300);
SlidesApp
.getUi() // Or DocumentApp or FormApp.
.showSidebar(html);
}
function doSomething() {
Logger.log('I just did something');
}
function addSlide(id) {
Logger.log('We are going to add slide number ' + id);
var currentPresentation = SlidesApp.getActivePresentation();
var newPresentation = SlidesApp
.openById(id)
.getSlides();
var slidesLength = newPresentation.length;
for (var i = 0; i < slidesLength; i++) {
currentPresentation.appendSlide(newPresentation[i])
}
}
Hello, world! <br>
<ul>
<strong>Experimentation</strong>
<br>
<input class="slideDeck" type="checkbox" value="1E8hACPZz3HPYinMQgtGz6ijT2GeTTGOkAb44Y64Yepw" />1| Introduction | Intro<br>
<input class="slideDeck" type="checkbox" value="1j4zyaG-66mV5YMrKVi2YHQRvQMAvEXsXv9UqsMSlTqI" />2| Setup | JS Timing<br>
</ul>
<input type="button" id="submitButton" value="Create Slides" onclick="onSubmit()" />
<script>
function onSubmit() {
document.getElementById('submitButton').disabled = true;
try {
var slides = document.getElementsByClassName('slideDeck');
[].forEach.call(slides, function (slide) {
console.dir(slide.value);
google.script.run.addSlide(slide.value);
});
} catch(e) {
console.log(e);
}
}
</script>