Skip to content

Commit

Permalink
add auto play
Browse files Browse the repository at this point in the history
  • Loading branch information
kenakamu committed Nov 20, 2018
1 parent 991510d commit c9bf464
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 36 deletions.
25 changes: 0 additions & 25 deletions createinstaller.js

This file was deleted.

6 changes: 1 addition & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ gulp.task('copy-img', () => {
.pipe(cache('img'))
.pipe(gulp.dest('./dist/img'));
});
gulp.task('copy-data', () => {
return gulp.src('./src/data')
.pipe(gulp.dest('./dist'));
});
gulp.task('copy-model', () => {
return gulp.src('./src/models/*')
.pipe(cache('models'))
Expand All @@ -64,7 +60,7 @@ gulp.task('copy-temp', () => {
.pipe(gulp.dest('./dist/temp'));
});

gulp.task('copy', ['copy-css', 'copy-html', 'copy-img', 'copy-data', 'copy-model', 'copy-temp']);
gulp.task('copy', ['copy-css', 'copy-html', 'copy-img', 'copy-model', 'copy-temp']);

gulp.task('watch', () => {
gulp.watch('./src/**/*.ts', ['typescript']);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "linesimulator",
"version": "2.0.0",
"version": "2.0.1",
"description": "LINE Bot Simulator",
"main": "dist/main.js",
"scripts": {
Expand Down
26 changes: 26 additions & 0 deletions src/css/simulator.css
Original file line number Diff line number Diff line change
Expand Up @@ -516,3 +516,29 @@ body{
width: 100%;
}
/*#endregion more menu*/

/*#region auto play*/
.auto-play {
background: black;
border-color: lightgray;
border-radius: 20px;
border-style: solid;
border-width: 2px;
bottom: 0;
box-shadow: 15px 15px 15px rgba(80,80,80,.5);
color: white;
float: left;
padding: 12px;
position: relative;
width: 400px;
}
.auto-play .inputs{
background-color: black;
border-width: 0px;
color:white;
font-size: 13px;
overflow-y: hidden;
width: 370px;
word-wrap: break-word;
}
/*#endregion auto play*/
18 changes: 17 additions & 1 deletion src/html/simulator.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
<span>richmenu</span>
</i>
</div>
<div>
<i class="fas fa-play-circle fa-inverse fa-2x" onclick="toggleAutoplay();">
<span>auto play</span>
</i>
</div>
<div>
<i class="fas fa-download fa-inverse fa-2x" onclick="saveChat();">
<span>Save Chat Data</span>
Expand All @@ -73,6 +78,7 @@
</div>
</div>
</div>

<!-- LINE client simulator -->
<div class="simulator-wrap">
<div class="simulator" style="-webkit-app-region: drag">
Expand Down Expand Up @@ -148,6 +154,15 @@
</div>
</div>

<!-- auto-play -->
<div class="auto-play hide">
<p>Enter inputs and click play to auto play</p>
<div>
<textarea rows=10 class="inputs"></textarea>
</div>
<a class="col-xs-12 btn btn-sm btn-success" onclick="autoPlay()">Play</a>
</div>

<!-- Send media, location, sticker, etc. -->
<div class="moreMenu hide">
<h4>Send media, location, system event, etc</h4>
Expand Down Expand Up @@ -293,7 +308,7 @@ <h4>[Send message as bot. POC only]</h4>
</div>
<a class="col-md-2 btn btn-sm btn-success" onclick="sendStickerFromBot()">Send</a>
</div>
<!-- Send Sticker -->
<!-- Send Address -->
<div role="tabpanel" class="tab-pane bot-chat-box" id="location">
<div class="col-md-10">
<div class="col-md-3 row">Title: </div>
Expand Down Expand Up @@ -702,6 +717,7 @@ <h4>[Send message as bot. POC only]</h4>
<script type="text/javascript" src="./../js/poc.js"></script>
<script type="text/javascript" src="./../js/raw.js"></script>
<script type="text/javascript" src="./../js/simulator.js"></script>
<script type="text/javascript" src="./../js/autoplay.js"></script>
<script>if (window.module) module = window.module;</script>
</body>

Expand Down
17 changes: 17 additions & 0 deletions src/js/autoplay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
function autoPlay(){
autoPlayMode = true;
let inputs = $('.inputs').val().toString().split('\n');

if(inputs.length != autoPlayIndex){
sendTextMessage(inputs[autoPlayIndex]);
autoPlayIndex++;
}
else{
autoPlayMode = false;
autoPlayIndex = 0;
}
}
let autoPlayIndex = 0;
var autoPlayMode = false;
}
20 changes: 17 additions & 3 deletions src/js/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
let moreMenu = $('.moreMenu');
let settings = $('.settings');
let chatRaw = $('.chat-raw');

let autoPlay = $('.auto-play');
function toggleKeyboard() {
chatthread.removeClass('richmenu');
richmenu.removeClass('visible');
Expand Down Expand Up @@ -168,6 +168,20 @@
chatRaw.addClass("hide");
}
}
function toggleAutoplay() {
if (autoPlay.hasClass("hide")) {
if (!pocMode) {
window.resizeTo(window.innerWidth + 400, window.innerHeight);
}
autoPlay.removeClass("hide");
}
else {
if (!pocMode) {
window.resizeTo(window.innerWidth - 400, window.innerHeight);
}
autoPlay.addClass("hide");
}
}
var numOfSim = 1;
function addSimulator() {
var newSimulator = $('.simulator:first').clone();
Expand Down Expand Up @@ -200,7 +214,7 @@
var reader = new FileReader();
reader.onload = function (event) {

let data = JSON.parse(window.atob(event.target.result.split(',')[1]));
let data = JSON.parse(new Buffer(event.target.result.split(',')[1],'base64').toString('utf8'));
data.forEach(function (jsonData) {
// Check replyToken to see if this is from bot or user.
if (jsonData.replyToken == null) {
Expand All @@ -224,5 +238,5 @@
// Read in the image file as a data URL.
reader.readAsDataURL((<HTMLInputElement>$('#loadJsonFile')[0]).files[0]);
}
//#endregion
//#endregion
}
4 changes: 3 additions & 1 deletion src/js/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ var messageId: string = "";
var li = parseDataAndReturnListItem(data.messages[i]);
// append the reply.
appendBotReplyToThread(li);
if(autoPlayMode){
autoPlay();
}
}
}
// Update time
Expand Down Expand Up @@ -82,7 +85,6 @@ var messageId: string = "";
setInterval(updateTime, 60000);
// Setup key pressdown event.
bindHandlers();

// Reset to default size.
function resetSize() {
screenHeigt = screen.availHeight;
Expand Down

0 comments on commit c9bf464

Please sign in to comment.