Last active
August 31, 2016 10:53
-
-
Save kir-sf/400b93b68f19ee1fffa8b4cff0c5dc58 to your computer and use it in GitHub Desktop.
Sales.Scriptor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<base target="_top"> | |
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css"> | |
<script> | |
function turnOffButtons() { | |
for(var index=1; index<=6; index++) { | |
var b=document.getElementById("but"+index); | |
b.hidden=true; | |
b.value=""; | |
} | |
} | |
function Start(purpose) { | |
var c=document.getElementById("codeQ"); | |
var p=document.getElementById("Purpose"); | |
c.innerHTML=""; | |
if (purpose!=0) | |
p.innerHTML="Цель сценария: "+purpose | |
else | |
p.innerHTML="Цель сценария не задана"; | |
Run(); | |
} | |
function getStart() { | |
var s=document.getElementById("talkScript"); | |
var p=document.getElementById("Purpose"); | |
p.innerHTML="Идет загрузка сценария..."; | |
google.script.run.withSuccessHandler(Start).getPurpose(s.value); | |
} | |
function moveBack() { | |
var c=document.getElementById("codeQ"); | |
var cVal=c.innerHTML; | |
if (cVal.length>0) { | |
c.innerHTML=cVal.substr(0, cVal.length-1); | |
Run(); | |
} | |
} | |
function answer(val, caption) { | |
if (val=='$') { | |
var s=document.getElementById("talkScript"); | |
s.value=caption; | |
getStart(); | |
} else { | |
var c=document.getElementById("codeQ"); | |
c.innerHTML=c.innerHTML+val; | |
Run(); | |
} | |
} | |
function putQuestion(res) { | |
var q=document.getElementById("Question"); | |
var c=document.getElementById("codeQ"); | |
if (res!=0) { | |
q.innerHTML=res[0]; | |
for(var index=1; index<=6; index++) { | |
var b=document.getElementById("but"+index); | |
if ((index*2)<res.length) { | |
var codeForBut=res[index*2-1]; | |
var textForBut=res[index*2]; | |
b.hidden=false; | |
b.value=codeForBut; | |
b.innerHTML=textForBut; | |
} else { | |
b.hidden=true; | |
b.value=""; | |
} | |
} | |
} else { | |
q.innerHTML='Конец диалога, ложи трубку!'; | |
turnOffButtons(); | |
} | |
} | |
function Run() { | |
var s=document.getElementById("talkScript"); | |
var c=document.getElementById("codeQ"); | |
var t=document.getElementById("Question"); | |
t.innerHTML="Идет загрузка скрипта..."; | |
google.script.run.withSuccessHandler(putQuestion).getInfo(c.innerHTML, s.value); | |
} | |
function fillSelect(listOfScripts) { | |
var s=document.getElementById("talkScript"); | |
if (listOfScripts!=0) | |
for (var index=0; index<listOfScripts.length; index++) | |
s.options[index]=new Option(listOfScripts[index]); | |
getStart(); | |
} | |
function Init() { | |
google.script.run.withSuccessHandler(fillSelect).getListOfScripts(); | |
} | |
</script> | |
</head> | |
<body> | |
<table width=100% border=0> | |
<tr><td bgcolor="lightgray" align="center" border=2 height=60> | |
<font color="blue" size=6 face="fantasy"> | |
<b>SALES.SCRIPTOR</b> | |
</font> | |
</td></tr> | |
<tr><td height=20> | |
<div id="codeQ" hidden></div> | |
</td></tr> | |
<tr><td align="center"> | |
<button class="share" onclick="getStart()"> Начать сначала </button> | |
<label for="talkScript">Сценарий</label> | |
<select id="talkScript" onchange="getStart()"></select> | |
<button class="share" onclick="moveBack()"> << Шаг назад </button> | |
</td></tr> | |
<tr><td align="center" height=60> | |
<h3><b><span id="Purpose">Идет загрузка сценария...</span></b></h3> | |
</td></tr> | |
<tr><td align="center" height=200> | |
<h1><span id="Question">Идет загрузка скрипта...</span></h1> | |
</td></tr> | |
<tr><td align="center" height=60> | |
<button class="action" id="but1" onclick="answer(this.value, this.innerHTML)"></button> | |
<button class="action" id="but2" onclick="answer(this.value, this.innerHTML)"></button> | |
<button class="action" id="but3" onclick="answer(this.value, this.innerHTML)"></button> | |
<button class="action" id="but4" onclick="answer(this.value, this.innerHTML)"></button> | |
<button class="action" id="but5" onclick="answer(this.value, this.innerHTML)"></button> | |
<button class="action" id="but6" onclick="answer(this.value, this.innerHTML)"></button> | |
</td></tr> | |
<tr><td bgcolor="blue" align="right"> | |
<font color=#ff8c00 face="sans-serif"><b>© SP-Novosibirsk 2015</b></font> | |
</td></tr> | |
</table> | |
<script> | |
Init(); | |
</script> | |
</body> | |
</html> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SCRIPT_BOOK='1BXZ38y27aJzqMoPy1y6zLelaLBW4FIu8s_9vFX4siTo'; | |
function doGet() { | |
return HtmlService.createHtmlOutputFromFile("Page").setSandboxMode(HtmlService.SandboxMode.IFRAME); | |
} | |
function getInfo(str, sheetName) { | |
var info=[]; | |
var sh=SpreadsheetApp.open(DriveApp.getFileById(SCRIPT_BOOK)).getSheetByName(sheetName); | |
var numRows=sh.getDataRange().getNumRows(); | |
var vals=sh.getDataRange().getValues(); | |
for (var index=0; index<numRows; index++) { | |
if (str==vals[index][0]) { | |
var col=1; | |
while (col<vals[index].length&&vals[index][col]!='') { | |
info.push(vals[index][col]); | |
col++; | |
} | |
return info; | |
} | |
} | |
return 0; | |
} | |
function getListOfScripts() { | |
var listOfScripts=[]; | |
var shs=SpreadsheetApp.open(DriveApp.getFileById(SCRIPT_BOOK)).getSheets(); | |
for (var index=0; index<shs.length; index++) | |
listOfScripts.push(shs[index].getName()); | |
return listOfScripts; | |
} | |
function getPurpose(sheetName) { | |
var sh=SpreadsheetApp.open(DriveApp.getFileById(SCRIPT_BOOK)).getSheetByName(sheetName); | |
var numRows=sh.getDataRange().getNumRows(); | |
var vals=sh.getRange(1,1,numRows, 2).getValues(); | |
for (var index=0; index<numRows; index++) | |
if ("цель"==vals[index][0]) | |
return vals[index][1]; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment