@@ -11,6 +11,10 @@ function onOpen()
1111
1212 ui . createMenu ( 'MLA Helper' )
1313
14+ . addItem ( 'Launch GUI' , 'launchGUI' )
15+
16+ . addSeparator ( )
17+
1418 . addItem ( 'Make MLA Header' , 'newHeader' )
1519
1620 . addItem ( 'New Quote' , 'newQuote' )
@@ -22,23 +26,21 @@ function onOpen()
2226 . addSeparator ( )
2327 . addItem ( 'Book' , 'newCitation' ) )
2428
25- . addSeparator ( )
26-
27- . addItem ( "Times New Romanator" , "timesNew" )
28- . addItem ( "Italicator" , "italixer" )
29+ . addSubMenu ( DocumentApp . getUi ( ) . createMenu ( 'Fonts' )
30+ . addItem ( "Times New Romanator" , "timesNew" )
31+ . addItem ( "Italicator" , "italixer" ) )
2932
3033 . addToUi ( ) ;
3134
32- ui . alert ( "MLA Helper script by WillDevv12 \n\n Catch me on GitHub: https://github.com/WillDev12" )
35+ ui . alert ( "MLA Helper v1.0.5 script by WillDevv12 \n\n Catch me on GitHub: https://github.com/WillDev12" )
3336
3437}
3538
3639function newQuote ( )
3740{
3841
39- var text = '<!DOCTYPE html><html><head><base target="_top"><link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"><script>function CreateQuote() {var quote = document.getElementById("quote").value;var author = document.getElementById("author").value;var pagen = document.getElementById("page").value;if (author === "") {var e = "null";google.script.run.FeedbackError(e);return;} else if (quote === "") {var e = "null";google.script.run.FeedbackError(e);return;}else if (pagen === "") {var e = "null";google.script.run.FeedbackError(e);return;}google.script.run.SendQuote(quote, author, pagen);google.script.host.close();}</script></head><body><div class="w3-card" style="margin: 20px"><div class="w3-container w3-blue"><h2>New quote</h2></div><div class="w3-container w3-light-gray"><br>Quote: (Do not include a final period) <br> <input type="text" id="quote" style="width:260px" required/><br>Authors last name: <br> <input type="text" id="author" style="width:260px" required/><br>Page #: <br> <input type="text" id="page" style="width:260px" required/><br><input type="button" value="Create" onclick="CreateQuote()" style="width:100px; margin-top: 20px; margin-bottom: 20px"/></div></div></body></html>'
40-
41- var form = HtmlService . createHtmlOutput ( text )
42+ var output = UrlFetchApp . fetch ( "https://raw.githubusercontent.com/WillDev12/MLA-Helper/main/scr/html/quote.html" ) ;
43+ var form = HtmlService . createHtmlOutput ( output . getContentText ( ) )
4244 . setWidth ( 800 )
4345 . setHeight ( 360 ) ;
4446
@@ -49,9 +51,8 @@ function newQuote()
4951function newCitation ( )
5052{
5153
52- var text = '<!DOCTYPE html><html><head><base target="_top"><link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"><script>function SendCitation() {var cont = document.getElementById("contribution1").value;var afn = document.getElementById("afn").value;var amn = document.getElementById("amn").value;var aln = document.getElementById("aln").value;var asfx = document.getElementById("asfx").value;var title = document.getElementById("title").value;var pub = document.getElementById("pub").value;var city = document.getElementById("city").value;var sn = document.getElementById("sn").value;var snum = document.getElementById("snum").value;var edition = document.getElementById("edition").value;var year = document.getElementById("year").value;google.script.run.CreateCitation(cont, afn, amn, aln, asfx, title, pub, city, sn, snum, edition, year);google.script.host.close();}</script></head><body><div class="w3-card"><div class="w3-container w3-blue"><h2>Author & Contributions</h2></div><div class="w3-container w3-light-gray" style="padding: 20px"><label for="contribution1">Choose a role:</label><select name="contribution1" id="contribution1"><option value="default">Role</option><option value="Author">Author</option><option value="Translator">Translator</option></select><br>Authors first name: <br> <input type="text" id="afn" style="width:260px" required/><br>Authors middle name: <br> <input type="text" id="amn" style="width:260px" required/><br>Authors last name: <br> <input type="text" id="aln" style="width:260px" required/><br>Suffix: <br> <input type="text" id="asfx" style="width:150px" required/><br><br></div><br><div class="w3-container w3-blue"><h2>Book Info</h2></div><div class="w3-container w3-light-gray" style="padding: 20px">Title: <br> <input type="text" id="title" style="width:260px" required/><br>Publisher: <br> <input type="text" id="pub" style="width:260px" required/><br>Year: <input type="text" id="year" style="width:150px" required/><br>Publication City: <br> <input type="text" id="city" style="width:260px" required/><br>Edition: <br> <input type="text" id="edition" style="width:260px" required/><br>Series name & number: <br> <input type="text" id="sn" style="width:100px" required/><input type="text" id="snum" style="width:100px" required/><br><input type="button" value="Create" onclick="SendCitation()" style="width:100px; margin-top: 20px"/></div></body></html>'
53-
54- var form = HtmlService . createHtmlOutput ( text )
54+ var output = UrlFetchApp . fetch ( "https://raw.githubusercontent.com/WillDev12/MLA-Helper/main/scr/html/citation.html" ) ;
55+ var form = HtmlService . createHtmlOutput ( output . getContentText ( ) )
5556 . setWidth ( 800 )
5657 . setHeight ( 700 ) ;
5758
@@ -68,6 +69,18 @@ function newHeader()
6869
6970}
7071
72+ function returnedHeading ( title , name , tname , came , day , month , year ) {
73+
74+ const monthNames = [ "January" , "February" , "March" , "April" , "May" , "June" ,
75+ "July" , "August" , "September" , "October" , "November" , "December"
76+ ] ;
77+
78+
79+ body . insertParagraph ( 0 , name + "\n" + tname + "\n" + came + "\n" + day + " " + monthNames [ month ] + " " + year + "\n\n" ) ;
80+ body . insertParagraph ( 1 , title ) . setAlignment ( DocumentApp . HorizontalAlignment . CENTER ) ;
81+
82+ }
83+
7184function timesNew ( )
7285{
7386
@@ -146,9 +159,10 @@ function SendQuote(quote, author, pagen)
146159 var surroundingText = cursor . getSurroundingText ( ) ;
147160 surroundingText . appendText ( str ) ;
148161
162+
149163}
150164
151- function CreateCitation ( cont , afn , amn , aln , asfx , title , pub , city , sn , snum , edition , year )
165+ function citeBook ( cont , afn , amn , aln , asfx , title , pub , city , sn , snum , edition , year )
152166{
153167
154168 var product = ""
@@ -188,7 +202,7 @@ function CreateCitation(cont, afn, amn, aln, asfx, title, pub, city, sn, snum, e
188202
189203 }
190204
191- if ( cont === "default " ) {
205+ if ( cont === "role " ) {
192206
193207 } else {
194208
@@ -252,19 +266,11 @@ function CreateCitation(cont, afn, amn, aln, asfx, title, pub, city, sn, snum, e
252266
253267 }
254268
255- ///////////////////////////////////////////////////////////////////////
256-
257- var cursor = DocumentApp . getActiveDocument ( ) . getCursor ( ) ;
258- var surroundingText = cursor . getSurroundingText ( ) ;
259- surroundingText . appendText ( product ) ;
260- var surroundingText = cursor . getSurroundingText ( ) ;
261- surroundingText . appendText ( italix ) ;
262- var surroundingText = cursor . getSurroundingText ( ) ;
263- surroundingText . appendText ( product2 ) ;
264- surroundingText = cursor . getSurroundingText ( ) ;
265- surroundingText . appendText ( "\n " + indent1 ) ;
266-
267- ///////////////////////////////////////////////////////////////////////
269+ var output = "<p>" + product + "<i>" + italix + "</i>" + product2 + "<br> " + indent1 ;
270+ var form = HtmlService . createHtmlOutput ( output )
271+ . setWidth ( 500 )
272+ . setHeight ( 150 ) ;
273+ ui . showModalDialog ( form , 'Output Citation' ) ;
268274
269275}
270276
@@ -273,14 +279,24 @@ function FeedbackError(e)
273279
274280 if ( e === "null" ) {
275281
276- ui . alert ( "ERROR: One or more of your input feilds are empty ." )
282+ ui . alert ( "ERROR: One or more required inputs are missing ." )
277283
278284 } else if ( e === "nullselected" ) {
279285
280286 ui . alert ( "ERROR: You must select text before running this script." )
281287
288+ } else {
289+
290+ ui . alert ( e ) ;
291+
282292 }
283293
284294}
285295
286- //Enjoy :)
296+ function launchGUI ( ) {
297+
298+ var s = UrlFetchApp . fetch ( "https://raw.githubusercontent.com/WillDev12/MLA-Helper/main/scr/html/sidebar.html" ) ;
299+ var service = HtmlService . createHtmlOutput ( s . getContentText ( ) ) . setTitle ( 'MLA Helper' ) ;
300+ DocumentApp . getUi ( ) . showSidebar ( service ) ;
301+
302+ }
0 commit comments