Apps Scriptリファレンス: Apps Script Reference |障害・課題追跡: IssueTracker |Google Workspace: Status Dashboard - Summary

2023年9月24日日曜日

New line removal App using Google Apps Script


Introduction

This is a simple application for removing new lines from the input textarea to the output textarea.


Application

After typing in the input text area, if you click on the output text area, the text will be input with line breaks removed.

Sample App




Source Code


Code.gs
function doGet() {
return HtmlService.createTemplateFromFile('index')
.evaluate()
.setTitle("Title");
}

function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename).getContent();
}

index.html
<!DOCTYPE html>
<html>
<head>
<?!= include("css"); ?>
</head>
<body>
<textarea id="input"></textarea>
<br>
<textarea id="output"></textarea>
<?!= include("javascript"); ?>
</body>
</html>

css.html
<style>
textarea {
width: 90vw;
height: 40vh;
}
</style>

javascript.html
<script>
function elem(id) {
return document.getElementById(id);
}

elem("input").onchange = inputChanged;

function inputChanged() {
elem("output").value = elem("input").value.replace(/\n/g, "");
}
</script>



Latest post

Google Formsでセクションの中にタイトルと説明を追加したい(addSectionHeaderItem)

今回はセクションの中に「タイトルと説明を追加」してみます フォームの編集画面 題名と説明を書くブロックが追加されます 今回の例では以下のように入力します 題名: SectionHeader 説明: Please answer the following questions. フォ...