Created
October 27, 2010 20:37
-
-
Save tbeseda/649921 to your computer and use it in GitHub Desktop.
Google App Script incrementPage creates a new subpage of a specified page that has a title of the next increment
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
| function incrementPage(parentURL, pageHTML) { | |
| var parentPage = SitesApp.getPageByUrl(parentURL) | |
| ,childPages = parentPage.getAllDescendants() | |
| ,biggest = 1000; | |
| for(i=0; i<childPages.length; i++) { | |
| var currentName = childPages[i].getName(); | |
| if(isNaN(currentName)) | |
| continue; | |
| +currentName; // make it a number | |
| if(currentName > biggest) | |
| biggest = currentName; | |
| } | |
| biggest++; | |
| var newPage = parentPage.createWebPage(biggest, biggest, pageHTML); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment