Что у меня есть - 3 файла,
- боковая панель. html (шаг 1)
- model_less_dialog. html (Шаг 2)
- сценарий на стороне сервера (.gs)
Что я хочу сделать: Я хочу отправить значения боковой панели. html и model_less_dialog. html на стороне сервера.
Мое существующее решение отлично работает с
localStorage.setItem('selectedSidebarValues', selectedData);
, передавая информацию между шаблонами и стороной сервера. Я хочу найти лучший способ передачи значений между шаблонами и сценарием на стороне сервера, кроме localStorage()
. Пользователи могут изменить localStorage()
перед отправкой в серверный скрипт (.gs), что может быть опасно
Боковая панель шага 1. html:
$("#selectBtn").on("click",function() {
-------------------
--- piece of code ---
-------------------
var selectedData = 'all selected values';
//storing step 1 selected data in local storage.
localStorage.setItem('selectedSidebarValues', selectedData);
//call the server script method to open the model less dialog box
google.script.run
.withSuccessHandler(
function(result, element) {
element.disabled = false;
})
.withFailureHandler(
function(msg, element) {
console.log(msg);
element.disabled = false;
})
.withUserObject(this)
.openModelLessDialogBox();
});
Шаг 2 model_less_dialog. html:
$("#selectBtnModelLessDialogBox").on("click",function(){
//collecting step 1 selected data from local storage.
var selectStep1 = localStorage.getItem('selectedSidebarValues');
var selectStep2 = 'all selected values';
//call the server script method
google.script.run
.withSuccessHandler(
function(result, element) {
element.disabled = false;
})
.withFailureHandler(
function(msg, element) {
console.log(msg);
element.disabled = false;
})
.withUserObject(this)
.calculatePolicy(selectStep1, selectStep2);
});
серверный скрипт (.gs):
function openModelLessDialogBox() {
var ui = SlidesApp.getUi();
var htmlOutput = HtmlService
.createHtmlOutputFromFile('model_less_dialog')
.setWidth(250)
.setHeight(300);
ui.showModelessDialog(htmlOutput, 'model less dialog');
}
function calculatePolicy(selectStep1, selectStep2) {
----- ----- ---
----- ----- ---
----- ----- ---
}
Итак, это как я передаю значения на сервер.
введите описание изображения здесь