-
Notifications
You must be signed in to change notification settings - Fork 0
Cav Scripts
Google Apps Script Project URL
The site tools functions are built to grab certain information from from the 7th Cavalry Website after logging into the website. Currently the Google PropertiesService is used to fetch login information contained within the Script Properties (See table at end of page linked for scope limitations).
To call the Site Tools functions after importing the library use CavScripts.siteTools(). Also a new object must be created to utilize scripts.
This method gets the session cookie through the use of Google's urlFetchApp Service.
Variable Name | Type | Description |
---|---|---|
user | string | 7Cav Forum username |
pw | string | 7Cav Forum password |
getPage will throw an error if the URL entered is not a proper 7cav.us URL.
Variable Name | Type | Description |
---|---|---|
N/A | string | session cookie |
This method retrieves the raw HTML of a webpage that would require a login. Authentication for the forum is retrieved via the getCookie method documented above.
Variable Name | Type | Description |
---|---|---|
URL | string | URL of a 7cav.us webpage |
This method retrieves a list of threads present on a forum.
Example:
var tools = new CavScripts.siteTools();
tools.getThreads("https://7cav.us/forums/public-announcements.180/")[0].author;
//Will return author of first thread listed in public announcments forum.
Variable Name | Type | Description |
---|---|---|
URL | string | 7Cav forum url |
pageOptions | integer | How the method will handle multiple pages [Default: 0] (see below for parameters) NOT IN USE... YET |
pageOptions Parameters: (Will only use parameter 0 till feature is fixed)
- 0 - Only first page
- 1 - All pages
- 2 - Only last page
getThreads will throw an error if the URL is not a proper 7cav.us forum URL (7cav.us/forums/).
Primary output will be an array with each index being a object literal containing the following information about each thread:
Variable Name | Type | Description |
---|---|---|
title | string | Title of the thread |
id | integer | Thread ID |
author | string | Author of the Thread (Ex: Smith.K) |
dateStarted | Date | Date thread was started UNDER CONSTRUCTION |
dateUpdated | Date | Date of most recent post on thread UNDER CONSTRUCTION |
This method grabs specific information from a thread
Examples:
var tools = new CavScripts.siteTools();
tools.parseThread("https://7cav.us/threads/today-we-remember.41228/").threadAuthor;
//Will return "Parsons.B"
var tools = new CavScripts.siteTools();
tools.parseThread("https://7cav.us/threads/today-we-remember.41228/").posts[0].contents;
//Will return raw HTML of the first post
Variable Name | Type | Description |
---|---|---|
URL | string | URL of a 7cav.us thread |
pageOptions | integer | How the method will handle multiple pages [Default: 0] (see below for parameters) NOT IN USE... YET |
pageOptions Parameters: (Will only use parameter 0 till feature is fixed)
- 0 - Only first page
- 1 - All pages
- 2 - Only last page
parseThread will throw an error if the URL is not a proper 7cav.us thread URL (7cav.us/threads/)
Output will be parameters of parseThread (Ex parseThread().threadAuthor )
Key | Type | Description |
---|---|---|
title | string | Thread title |
id | integer | Thread ID (see URL) |
threadAuthor | string | Thread author (Ex: Smith.J) |
parentForum | string | Name of forum thread is contained in |
dateStart | date | JS date thread was started |
posts | array | Array with information of every post. See below this table for further info. |
dateUpdate | date | JS date of last post made to thread |
posts Array
Each index in the array will be an object literal containing information about each post. See table below for information in each index
Key | Type | Description |
---|---|---|
author | string | Post author (Ex: Bell.K) |
date | date | JS date post was created |
contents | string | Raw HTML of the post contents |
This method grabs specific information about a provided Milpac
Examples:
var tools = new CavScripts.siteTools();
tools.getMilpac("https://7cav.us/rosters/profile?uniqueid=446").fullName;
//Will return "Kyle Bell"
Variable Name | Type | Description |
---|---|---|
URL | string | URL of a 7cav.us milpac profile |
parseThread will throw an error if the URL is not a proper 7cav.us milpac URL (7cav.us/rosters/profile?uniqueid=)
Output will be parameters of getMilpac (Ex parseThread().threadAuthor )
Key | Type | Description |
---|---|---|
fullName | string | Trooper's full name (Ex: John Smith) |
rank | string | Troopers rank (Ex: Private First Class) |
primaryBillet | string | Troopers primary/combat billet |
secondaryBillets | array | Array of troopers secondary billets UNDER CONSTRUCTION |
enlistedDate | string | Date trooper enlisted (Ex: Aug 20, 2013) |
serviceRecord | array | Array containing each service record entry. Each index will be an object literal containing key/value pairs about an entry. See below for further info. |
awards | array | Array containing each award entry. Each index will be an object literal containing key/value pairs about an entry. See below for further info. |
serviceRecord Array
Each index in the array contains the following:
Key | Type | Description |
---|---|---|
date | string | Date of record entry (Ex: Nov 10, 2018) |
entry | string | The service record entry |
awards Array
Each index in the array contains the following:
Key | Type | Description |
---|---|---|
date | string | Date of record entry (Ex: Nov 10, 2018) |
name | string | Name of the award |
details | string | Details provided for the award |