Learning Google Apps Script by Ramalingam Ganapathy

Learning Google Apps Script by Ramalingam Ganapathy

Author:Ramalingam Ganapathy [Ganapathy, Ramalingam]
Language: eng
Format: epub, pdf
Publisher: Packt Publishing
Published: 2016-03-17T23:00:00+00:00


Create a new HTML file named Sidebar.html and put the following code in it:

<!DOCTYPE html> <html> <head> <base target="_top"> <link rel="stylesheet" href="https://ssl.gstatic.com/docs/script /css/add-ons1.css" /> <script src="//ajax.googleapis.com/ajax/libs/jquery/ 1.9.1/jquery.min.js"> </script> </head> <body> <input type="text" id="txt" /> <button class="green" id="btn">Search</button> </body> <script> // On document load, assign click handler to the search // button. $(function() { $('#btn').click(listFiles); }); function listFiles() { this.disabled = true; $('#error,#success').remove(); google.script.run .withSuccessHandler(function(msg,elm){ elm.disabled = false; }) .withFailureHandler(function(err,elm){ elm.disabled = false; showError(err,elm); }) .withUserObject(this) .listDriveFiles($('#txt').val()); } /** * Inserts a div that contains success message after a given * element. * * @param {string} msg - The message to display. * @param {object} element - The element after which to * display the message. * */ function showSuccess(msg,element) { var div = $('<div id="success"><font color="green">' + msg + '</font></div>'); $(element).after(div); } /** * Inserts a div that contains error message after a given * element. * * @param {string} msg - The error message to display. * @param {object} element - The element after which to * display the error. * */ function showError(msg, element) { var div = $('<div id="error" class="error">' + msg + '</div>'); $(element).after(div); } </script> </html>



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.