Browse Source

fix Safari and convert ES6 to ES5 [sad]

master
Carmine De Rosa 7 years ago
parent
commit
bb94ed87a1
  1. 2
      cb_session_qr.php
  2. 5
      device/css/styles.css
  3. 4
      device/index.php
  4. 3
      device/script.js
  5. 5
      device/scss/main.scss
  6. 4
      js/scripts.js
  7. 13
      sessions.php
  8. 6
      socket/index.js
  9. 12
      socket/package-lock.json
  10. 7
      socket/package.json
  11. 29
      socket/public/control.html
  12. 63
      socket/public/control.js
  13. 147
      socket/public/css/styles.css
  14. 15278
      socket/public/css/stylesGlobal.css
  15. 28
      socket/public/device.html
  16. 134
      socket/public/device.js
  17. BIN
      socket/public/fonts/FontAwesome.otf
  18. BIN
      socket/public/fonts/fontawesome-webfont.eot
  19. 2671
      socket/public/fonts/fontawesome-webfont.svg
  20. BIN
      socket/public/fonts/fontawesome-webfont.ttf
  21. BIN
      socket/public/fonts/fontawesome-webfont.woff
  22. BIN
      socket/public/fonts/fontawesome-webfont.woff2
  23. 4
      socket/public/images/.directory
  24. BIN
      socket/public/images/photo-compare.jpg
  25. BIN
      socket/public/images/video.png
  26. 106
      socket/public/scss/main.scss
  27. 34
      socket/public/setMessage.html
  28. 45
      socket/public/setMessage.js
  29. 33
      socket/public/smartphone.html
  30. 192
      socket/public/smartphone.js

2
cb_session_qr.php

@ -4,7 +4,7 @@
$PNG_TEMP_DIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'temp'.DIRECTORY_SEPARATOR;
$PNG_WEB_DIR = 'temp/';
$SID = $BASE_URL.'/device/?sid='.$_GET['sid'];
$SID = $BASE_URL.':3001/device.html?sid='.$_GET['sid'];
include "qrcode/qrlib.php";

5
device/css/styles.css

@ -4207,3 +4207,8 @@ a:hover {
top: 50%;
transform: translateY(-50%);
}
/* line 174, main.scss */
.iframeGET {
display: none;
}

4
device/index.php

@ -19,13 +19,13 @@
<div class="content">
</div>
<audio id="notify1">
<source src="<?= $BASE_URL;?>/sounds/message.ogg" type="audio/ogg">
</audio>
<script type="text/javascript" src="<?= $BASE_URL;?>/node_modules/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="<?= $BASE_URL;?>/device/script.js"></script>
<iframe class="iframeGET" src="<?= $BASE_URL;?>:3001/getMessage.html"></iframe>
</body>
</html>

3
device/script.js

@ -112,6 +112,3 @@ $(document).ready(()=>{
});

5
device/scss/main.scss

@ -169,3 +169,8 @@ a{
transform: translateY(-50%);
}
}
.iframeGET{
display: none;
}

4
js/scripts.js

@ -30,3 +30,7 @@ $(document).ready(function(){
});
window.addEventListener("message", ()=>{$.colorbox.close();}, false);

13
sessions.php

@ -8,10 +8,10 @@
<div class="row <?= $bgcolor;?> p-2 text-upper text-grey">
<div class="col-2 font-12">Session name</div>
<div class="col-5 font-12">QR|Session link</div>
<div class="col-4 font-12">QR|Session link</div>
<div class="col-2 font-12">Session start</div>
<div class="col-2 font-12">Session end</div>
<div class="col-1 text-right"></div>
<div class="col-2 text-right"></div>
</div>
<?php
@ -24,16 +24,19 @@
<div class="row items <?= $bgcolor;?> p-2">
<div class="col-2 font-12"><?= $r['name'];?></div>
<div class="col-5">
<div class="col-4">
<a href="/cb_session_qr.php?sid=<?= $r['link'];?>" class="cbOpenSmall text-black"><i class="fa fa-qrcode ml-2"></i></a>
<a href="<?= $BASE_URL."/device/?sid=".$r['link'];?>" target="_blank" class="text-black font-12"><?= $BASE_URL."/device/?sid=".$r['link'];?></a></div>
<!-- <a href="<?= $BASE_URL."/device/?sid=".$r['link'];?>" target="_blank" class="text-black font-12"><?= $BASE_URL."/device/?sid=".$r['link'];?></a></div> -->
<a href="<?= $BASE_URL.":3001/device.html?sid=".$r['link'];?>" target="_blank" class="text-black font-12"><?= $BASE_URL."/device/?sid=".$r['link'];?></a></div>
<div class="col-2 font-12"><?= $r['start'];?></div>
<div class="col-2 font-12"><?= $r['stop'];?></div>
<div class="col-1 text-right">
<div class="col-2 text-right">
<a href="/cb_session_action.php?id=<?= $r['id'];?>&status=<?= $r['enabled'];?>" class="cbOpenSmall">
<?= $r['enabled'] ? "<i class=\"fa fa-play text-green\"></i>" : "<i class=\"fa fa-pause text-grey\"></i>";?>
</a>
<a href="/cb_session_edit.php?id=<?= $r['id'];?>" class="cbOpen text-black"><i class="fa fa-pencil-square ml-2"></i></a>
<a href="<?= $BASE_URL.":3001/setMessage.html?sid=".$r['id'];?>" class="cbOpen text-black"><i class="fa fa-comment ml-2"></i></a>
<a href="/cb_session_delete.php?id=<?= $r['id'];?>" class="cbOpenSmall text-black"><i class="fa fa-times-circle ml-2"></i></a>
</div>
</div>

6
socket/index.js

@ -1,4 +1,3 @@
const express = require('express');
const app = express();
const http = require('http').Server(app);
@ -8,12 +7,7 @@ const port = process.env.PORT || 3001;
app.use(express.static(__dirname + '/public'));
function onConnection(socket){
socket.on('cloudIndex', (data) => socket.broadcast.emit('cloudIndex', data));
socket.on('reset', (data) => socket.broadcast.emit('reset', data));
socket.on('message', (data) => socket.broadcast.emit('message', data));
socket.on('response', (data) => socket.broadcast.emit('response', data));
socket.on('actions', (data) => socket.broadcast.emit('actions', data));
socket.on('display', (data) => socket.broadcast.emit('display', data));
}
io.on('connection', onConnection);

12
socket/package-lock.json

@ -1,6 +1,6 @@
{
"name": "coze_socket",
"version": "1.0.0",
"version": "1.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -539,6 +539,11 @@
"whatwg-fetch": "2.0.3"
}
},
"jquery": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz",
"integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg=="
},
"js-tokens": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
@ -934,6 +939,11 @@
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz",
"integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ=="
},
"tinymce": {
"version": "4.7.11",
"resolved": "https://registry.npmjs.org/tinymce/-/tinymce-4.7.11.tgz",
"integrity": "sha512-rLWAibMZa1oFaxucufQxVacbXzt5LJe0lSgsRYlLIi0YOhl6JKFIuYqxlU74UygaAliDlNUX84hlMj7Ky0QmXQ=="
},
"to-array": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz",

7
socket/package.json

@ -1,6 +1,6 @@
{
"name": "coze_socket",
"version": "1.0.0",
"version": "1.1.0",
"description": "COZe socket",
"main": "index.js",
"keywords": [
@ -9,15 +9,18 @@
"dependencies": {
"express": "latest",
"font-awesome": "latest",
"jquery": "^3.3.1",
"ms": "github:zeit/ms",
"pillarjs": "latest",
"send": "github:pillarjs/send",
"socket.io": "latest",
"tinymce": "^4.7.11",
"zeit": "latest"
},
"scripts": {
"start": "node index"
},
"author": "Dslak",
"license": "MIT"
"license": "MIT",
"devDependencies": {}
}

29
socket/public/control.html

@ -1,29 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>COZe</title>
<link rel="stylesheet" href="style.css">
</head>
<body style="text-align: center">
<div id="controls">
<select id="gotoCloud">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<button id="reset">Reset</button>
<input id="message" type="text" >
</div>
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="/control.js"></script>
</body>
</html>

63
socket/public/control.js

@ -1,63 +0,0 @@
$(document).ready(()=>{
const socket = io();
// socket.emit('cloudIndex', getURLParameter('cloud'));
if(getURLParameter('cloud')){
socket.emit('cloudIndex', getURLParameter('cloud'));
}
if(getURLParameter('message')){
socket.emit('message', getURLParameter('message'));
}
if(getURLParameter('response')){
socket.emit('response', getURLParameter('response'));
}
if(getURLParameter('actions')){
socket.emit('actions', getURLParameter('actions'));
}
if(getURLParameter('display')){
socket.emit('display', getURLParameter('display'));
}
if(getURLParameter('reset')){
socket.emit('reset', 1);
}
$('#gotoCloud').on('change', function(){
current = $(this).val();
socket.emit('cloudIndex', current);
});
$('#reset').on('click', function(){
socket.emit('reset', 1);
console.log('RESET');
});
$('#message').on('keypress', function(event){
if(event.which == 13){
socket.emit('message', $(this).val());
console.log('message', $(this).val());
}
});
});
function getURLParameter(sParam){
const sPageURL = window.location.search.substring(1);
const sURLVariables = sPageURL.split('&');
for (let i = 0; i < sURLVariables.length; i++){
const sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam){
return sParameterName[1];
}
}
}

147
socket/public/css/styles.css

@ -4051,45 +4051,45 @@ body {
margin: 0;
padding: 0;
overflow: hidden;
overflow-y: auto;
font-size: 0.75rem;
font-weight: 400;
}
/* line 20, main.scss */
/* line 23, main.scss */
p,
label {
margin: 0;
}
/* line 25, main.scss */
/* line 28, main.scss */
a {
color: white;
text-decoration: none;
transition: .4s;
outline: none;
}
/* line 30, main.scss */
/* line 33, main.scss */
a:active, a:visited, a:hover, a:focus {
outline: none;
color: white;
text-decoration: none;
}
/* line 38, main.scss */
/* line 41, main.scss */
a:hover {
color: #ccc;
}
/* line 43, main.scss */
/* line 46, main.scss */
.content {
overflow: hidden;
position: fixed;
height: 100vh;
overflow-y: scroll;
width: calc(100vw + 17px);
margin-top: 70px;
width: 100%;
text-align: center;
}
/* line 50, main.scss */
/* line 51, main.scss */
.content .cloud {
display: none;
position: relative;
width: 70%;
width: 80%;
font-size: 0.75rem;
font-weight: 500;
padding: 10px;
@ -4097,20 +4097,22 @@ a:hover {
border-radius: 8px;
line-height: 18px;
color: #2f2f2f;
text-align: left;
}
/* line 62, main.scss */
/* line 63, main.scss */
.content .cloud img {
width: 100%;
padding: 5px;
margin: 8px 0;
cursor: pointer;
border-radius: 5px;
}
/* line 68, main.scss */
/* line 70, main.scss */
.content .cloud.left {
left: 15px;
background: #f6e7ea;
border: 1px solid #c8bcbe;
}
/* line 72, main.scss */
/* line 74, main.scss */
.content .cloud.left:before {
content: '';
border: solid 8px transparent;
@ -4119,8 +4121,9 @@ a:hover {
left: 0;
top: 50%;
transform: translate(-100%, -50%);
-webkit-transform: translate(-100%, -50%);
}
/* line 81, main.scss */
/* line 84, main.scss */
.content .cloud.left:after {
content: '';
border: solid 7px transparent;
@ -4129,14 +4132,15 @@ a:hover {
left: 0;
top: 50%;
transform: translate(-100%, -50%);
-webkit-transform: translate(-100%, -50%);
}
/* line 92, main.scss */
/* line 96, main.scss */
.content .cloud.right {
left: calc(30% - 38px);
left: calc(20% - 38px);
background: #d4eeed;
border: 1px solid #b0c8c6;
}
/* line 96, main.scss */
/* line 100, main.scss */
.content .cloud.right:before {
content: '';
border: solid 8px transparent;
@ -4145,8 +4149,9 @@ a:hover {
right: 0;
top: 50%;
transform: translate(100%, -50%);
-webkit-transform: translate(100%, -50%);
}
/* line 105, main.scss */
/* line 110, main.scss */
.content .cloud.right:after {
content: '';
border: solid 7px transparent;
@ -4155,64 +4160,32 @@ a:hover {
right: 0;
top: 50%;
transform: translate(100%, -50%);
-webkit-transform: translate(100%, -50%);
}
/* line 116, main.scss */
.content .cloud.empty {
width: 100%;
text-align: center;
padding: 0;
}
/* line 125, main.scss */
.content.client {
top: 50px;
height: calc(100vh - 100px);
/* line 122, main.scss */
.content .cloud .title {
font-weight: bold;
}
/* line 129, main.scss */
.content.client .cloud.right {
left: calc(30% - 58px);
/* line 128, main.scss */
.content .cloud .long-text .toggle {
color: #ccc;
margin: 5px 0;
}
/* line 138, main.scss */
.video {
/* line 132, main.scss */
.content .cloud .long-text .text-content {
display: none;
position: fixed;
top: 0;
left: 0;
height: 100vh;
width: 100%;
background: black;
z-index: 10;
}
/* line 147, main.scss */
.video .video-close {
position: absolute;
top: 0;
right: 3px;
height: 20px;
width: 20px;
cursor: pointer;
padding: 0;
z-index: 10;
}
/* line 157, main.scss */
.video .video-close:after {
content: '\f00d';
font-family: "FontAwesome";
font-size: 1.25rem;
color: white;
}
/* line 164, main.scss */
.video video {
height: 100vh;
width: 100%;
/* line 138, main.scss */
.content .actions {
padding: 0 20vw 0 50px;
text-align: center;
}
/* line 170, main.scss */
.iframeGET {
display: none;
/* line 142, main.scss */
.content .actions .goto {
margin: 5px 10px;
}
/* line 174, main.scss */
/* line 151, main.scss */
.header {
position: fixed;
height: 50px;
@ -4220,42 +4193,28 @@ a:hover {
left: 0;
top: 0;
background: black;
z-index: 10;
}
/* line 182, main.scss */
/* line 160, main.scss */
.header .logo {
height: 25px;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
}
/* line 190, main.scss */
/* line 169, main.scss */
.header .menu {
height: 20px;
position: absolute;
left: 20px;
top: 50%;
transform: translateY(-50%);
-webkit-transform: translate(-50%);
}
/* line 199, main.scss */
.footer {
position: fixed;
height: 50px;
width: 100%;
left: 0;
bottom: 0;
background: black;
}
/* line 207, main.scss */
.footer input {
width: 95%;
height: 35px;
border-radius: 4px;
border: none;
position: absolute;
left: 50%;
top: 50%;
margin: 0;
transform: translate(-50%, -50%);
/* line 180, main.scss */
.iframeGET {
display: none;
}

15278
socket/public/css/stylesGlobal.css

File diff suppressed because it is too large

28
socket/public/device.html

@ -0,0 +1,28 @@
<!doctype html>
<html lang="en">
<head>
<title>COZe Training</title>
<meta charset="UTF-8">
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<div class="header">
<img class="menu" src="/images/menu.png">
<img class="logo" src="/images/logo.png">
</div>
<div class="content">
</div>
<audio id="notify1">
<source src="/sounds/message.ogg" type="audio/ogg">
</audio>
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="/device.js"></script>
<script src="/getMessage.js"></script>
</body>
</html>

134
socket/public/device.js

@ -0,0 +1,134 @@
$(document).ready( function(){
var socket = io();
socket.on('message', getMessage);
var baseUrl = 'http://' + window.location.hostname;
var content = $('.content');
var urlString = window.location.href;
var url = new URL(urlString);
var sid = getParameterByName("sid", urlString);
console.log('a<szdhxfg');
console.log(baseUrl);
$.getJSON( baseUrl + '/apis/getMessages.php', {
sid: sid
}).done( function(session){
console.log(session);
if(session.enabled){
$.each(session.messages, function(index,item){
if(item.timer != session.start){
var now = new Date().getTime();
var timerValue = item.timer.split(' ');
var timerDate = timerValue[0].split('-');
var timerHours = timerValue[1].split(':');
var timer = new Date(timerDate[0], timerDate[1] - 1, timerDate[2], timerHours[0], timerHours[1], timerHours[2]).getTime();
var startValue = session.start.split(' ');
var startDate = startValue[0].split('-');
var startHours = startValue[1].split(':');
var start = new Date(startDate[0], startDate[1] - 1, startDate[2], startHours[0], startHours[1], startHours[2]).getTime();
console.log(now, start, timer, timer-now);
if(now > timer){
showCloud(item.title, [item.short_text, item.long_text], item.image, item.actions, session.messages);
notify(true);
} else {
var delay = (timer - now);
setTimeout( function(){
showCloud(item.title, [item.short_text, item.long_text], item.image, item.actions, session.messages);
notify(true);
},delay);
}
}
});
}
});
function showCloud(title, text, img, actions, messages){
var image = img ? '<img src="' + img : '';
var long_text = text[1] ? '<div class="long-text"> <button class="toggle button confirm">More...</button> <div class="text-content">' + text[1] + '</div> </div>' : '';
var cloud = $('<div class="cloud left"> <div class="title">' + title + '</div> <div class="short-text">' + text[0] + '</div>' + long_text + image + '</div>');
cloud.find('.toggle').on('click', function(e){
var button = $(e.currentTarget);
var text = button.siblings('.text-content');
if(text.is(':visible')){
button.text('More...');
text.slideUp();
}else{
button.text('Less...');
text.slideDown();
}
});
content.append(cloud);
if(actions.length){
var actionsContainer = $('<div class="actions"></div>');
$.each(actions, function(index, value){
var button = $('<button class="goto button dotted" data-goto="' + value.mid + '">' + value.label + '</button>');
button.on('click', function(e){
var goto = $(e.currentTarget);
var messageId = goto.data('goto');
var fullMessage = messages.filter( function(m){m.id == messageId});
showCloud(fullMessage[0].title, [fullMessage[0].short_text, fullMessage[0].long_text], fullMessage[0].image, fullMessage[0].actions, messages);
notify(false);
});
actionsContainer.append(button);
});
content.append(actionsContainer);
}
scrollBottom();
}
function scrollBottom(){
$('html, body').stop().animate({
scrollTop: $('.cloud').last().offset().top
}, 1000);
}
function notify(vibrate){
if(vibrate){
var canVibrate = (navigator.vibrate ||
navigator.webkitVibrate ||
navigator.mozVibrate ||
navigator.msVibrate);
if(canVibrate){
navigator.vibrate(500);
}
}
$('#notify1')[0].play();
}
function getMessage(message){
showCloud(message.title, [message.short_text, message.long_text], message.image, '', '');
notify(true);
}
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
});

BIN
socket/public/fonts/FontAwesome.otf

Binary file not shown.

BIN
socket/public/fonts/fontawesome-webfont.eot

Binary file not shown.

2671
socket/public/fonts/fontawesome-webfont.svg

File diff suppressed because it is too large

Before

Width:  |  Height:  |  Size: 434 KiB

BIN
socket/public/fonts/fontawesome-webfont.ttf

Binary file not shown.

BIN
socket/public/fonts/fontawesome-webfont.woff

Binary file not shown.

BIN
socket/public/fonts/fontawesome-webfont.woff2

Binary file not shown.

4
socket/public/images/.directory

@ -1,4 +0,0 @@
[Dolphin]
PreviewsShown=true
Timestamp=2017,10,21,18,38,1
Version=4

BIN
socket/public/images/photo-compare.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 893 KiB

BIN
socket/public/images/video.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 247 KiB

106
socket/public/scss/main.scss

@ -15,6 +15,9 @@ body{
margin: 0;
padding: 0;
overflow: hidden;
overflow-y: auto;
font-size: $font-12;
font-weight: 400;
}
p,
@ -41,16 +44,13 @@ a{
}
.content{
overflow: hidden;
position: fixed;
height: 100vh;
overflow-y: scroll;
width: calc(100vw + 17px);
margin-top: 70px;
width: 100%;
text-align: center;
.cloud{
display: none;
position: relative;
width: 70%;
width: 80%;
font-size: $font-12;
font-weight: 500;
padding: 10px;
@ -58,11 +58,13 @@ a{
border-radius: 8px;
line-height: 18px;
color: $dark-grey;
text-align: left;
img{
width: 100%;
padding: 5px;
margin: 8px 0;
cursor: pointer;
border-radius: 5px;
}
&.left{
@ -77,6 +79,7 @@ a{
left: 0;
top: 50%;
transform: translate(-100%, -50%);
-webkit-transform: translate(-100%, -50%);
}
&:after{
content: '';
@ -86,11 +89,12 @@ a{
left: 0;
top: 50%;
transform: translate(-100%, -50%);
-webkit-transform: translate(-100%, -50%);
}
}
&.right{
left: calc(30% - 38px);
left: calc(20% - 38px);
background: $azure;
border: 1px solid $dark-azure;
&:before{
@ -101,6 +105,7 @@ a{
right: 0;
top: 50%;
transform: translate(100%, -50%);
-webkit-transform: translate(100%, -50%);
}
&:after{
content: '';
@ -110,67 +115,39 @@ a{
right: 0;
top: 50%;
transform: translate(100%, -50%);
-webkit-transform: translate(100%, -50%);
}
}
&.empty{
width: 100%;
text-align: center;
padding: 0;
}
.title{
font-weight: bold;
}
.long-text{
&.client{
top: 50px;
height: calc(100vh - 100px);
.cloud{
&.right{
left: calc(30% - 58px);
.toggle{
color: $grey;
margin: 5px 0;
}
.text-content{
display: none;
}
}
}
.actions{
padding: 0 20vw 0 50px;
text-align: center;
.video{
display: none;
position: fixed;
top: 0;
left:0;
height: 100vh;
width: 100%;
background: black;
z-index: 10;
.video-close{
position: absolute;
top: 0;
right: 3px;
height: 20px;
width: 20px;
cursor: pointer;
padding: 0;
z-index: 10;
&:after{
content: '\f00d';
font-family: $icon;
font-size: $font-20;
color: white;
}
}
video{
height: 100vh;
width: 100%;
.goto{
margin: 5px 10px;
}
}
.iframeGET{
display: none;
}
.header{
position: fixed;
height: 50px;
@ -178,6 +155,7 @@ a{
left: 0;
top: 0;
background: black;
z-index: 10;
.logo{
height: 25px;
@ -185,6 +163,7 @@ a{
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
}
.menu{
@ -193,26 +172,11 @@ a{
left: 20px;
top: 50%;
transform: translateY(-50%);
-webkit-transform: translate(-50%);
}
}
.footer{
position: fixed;
height: 50px;
width: 100%;
left: 0;
bottom: 0;
background: black;
input{
width: 95%;
height: 35px;
border-radius: 4px;
border: none;
position: absolute;
left: 50%;
top: 50%;
margin: 0;
transform: translate(-50%, -50%);
}
.iframeGET{
display: none;
}

34
socket/public/setMessage.html

@ -0,0 +1,34 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>COZe</title>
<link href="/css/styles.css" rel="stylesheet" type="text/css"/>
<link href="/css/stylesGlobal.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="MainContent" class="container">
<form method="post" enctype="multipart/form-data" class="send_message_form">
<div class="row">
<div class="col-12">
<span class="font-12 text-grey">Message title</span>
<input type="text" name="title" class="title">
</div>
<div class="col-12">
<span class="font-12 text-grey">Message text</span>
<textarea class="mce text" name="text"></textarea>
</div>
<div class="col-12 text-center p4 px-0">
<button type="submit" class="button big full confirm mx-0">Send message</button>
</div>
</div>
</form>
</div>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.7.11/tinymce.min.js"></script>
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript" src="/setMessage.js"></script>
</body>
</html>

45
socket/public/setMessage.js

@ -0,0 +1,45 @@
$(document).ready(()=>{
const socket = io();
const baseUrl = 'http://' + window.location.hostname;
tinymce.init({
selector: '.mce',
height: 200,
theme: 'modern',
menubar: false,
forced_root_block : '',
force_br_newlines : true,
pagebreak_separator: '%break%',
plugins: [
'advlist autolink pagebreak lists paste'
],
toolbar: 'bold italic underline | bullist numlist pagebreak | removeformat',
image_advtab: false,
content_css: [
'//fonts.googleapis.com/css?family=Montserrat:300,300i,400,400i',
]
});
const form = $('.send_message_form');
form.on('submit', function(e){
e.preventDefault();
const title = form.find('.title').val();
const text = form.find('.text').val().split('%break%');
const fullMessage = {
'title': title,
'short_text': text[0],
'long_text': text[1],
'image': '',
};
socket.emit('message', fullMessage);
parent.postMessage("cbClose", baseUrl);
});
});

33
socket/public/smartphone.html

@ -1,33 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<title>COZe</title>
<meta charset="UTF-8">
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
<div class="header">
<img class="menu" src="/images/menu.png">
<img class="logo" src="/images/logo.png">
</div>
<div class="content client">
</div>
<audio id="notify1">
<source src="../sounds/message.ogg" type="audio/ogg">
</audio>
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="/smartphone.js"></script>
<iframe class="iframeGET" src=""></iframe>
<!--
<div class="footer">
<input type="text">
</div>-->
</body>
</html>

192
socket/public/smartphone.js

@ -1,192 +0,0 @@
$(document).ready(()=>{
const socket = io();
const baseUrl = "http://coze-training.local";
const serverPath = "http://" + window.location.hostname + ":" + window.location.port + "/";// "http://coze.dev:3000/";
const canVibrate = "vibrate" in navigator || "mozVibrate" in navigator;
if (canVibrate && !("vibrate" in navigator)){navigator.vibrate = navigator.mozVibrate;}
const content = $('.content')
const urlString = window.location.href
const url = new URL(urlString);
const sid = url.searchParams.get("sid");
$.getJSON( baseUrl + "/apis/getMessages.php", {
sid: sid
}).done( (data)=> {
console.log(data);
});
/*
socket.on('cloudIndex', showCloud);
socket.on('reset', reset);
socket.on('message', showMessage);
socket.on('response', showResponse);
socket.on('actions', showActions);
socket.on('display', showHtml);
function reset(index){
cloudCount = 0
console.log('RESET:', index)
content.empty()
parent.postMessage(cloudCount, "*")
}
function showCloud(index){
console.log('RECEIVE:', index);
const thisCloud = $(clouds.get(index));
let offset = 0;
if(!thisCloud.hasClass('empty')){
notify(true);
}
thisCloud.fadeIn(400,()=>{
if(thisCloud.hasClass('scroll')){
offset = thisCloud.offset().top
content.animate({
scrollTop: offset
}, 400);
}
})
}
function showMessage(message){
let newCloud = $('<div class="cloud right">' + decodeURIComponent(message) + '</div>');
content.append(newCloud);
newCloud.fadeIn();
content.animate({
scrollTop: newCloud.offset().top
}, 400);
notify(false);
cloudCount++
parent.postMessage(cloudCount, "*")
}
function showResponse(message){
let newCloud = $('<div class="cloud left">' + decodeURIComponent(message) + '</div>');
content.append(newCloud);
newCloud.fadeIn();
content.animate({
scrollTop: newCloud.offset().top
}, 400);
notify(true);
}
function showActions(actions){
const actionsArray = decodeURIComponent(actions).split("|");
let token = "";
let buttons = "";
let text = "";
let side = "";
$.each(actionsArray, (index, val)=>{
if(index==0){
token = val;
}else{
buttons += "<button class= \"button dotted\">"+val+"</button>";
}
});
let newCloud = $('<div class="cloud empty">' + buttons + '</div>');
content.append(newCloud);
newCloud.fadeIn();
content.animate({
scrollTop: newCloud.offset().top
}, 400);
newCloud.find('button').on('click', ()=>{
$('.iframeGET').attr('src', serverPath + 'control.html?display='+token);
});
}
function showHtml(token){
switch(token){
case "plans_1":
side = "empty";
text = "<img src=\""+serverPath.replace(":3000", "")+"images/video.png\" class=\"video-opener\">";
break;
case "pull_1":
side = "left";
text = "Ricordati di non avvicinarti eccessivamente.";
break;
case "monit_1":
side = "left";
text = "<b>TEMA 3 COMPETENZE DI VENDITA - REGOLA#1<br><br>"+
"Non rispondere a domande non fatte</b><br><br>"+
"Il cliente chiede di un prodotto. È meglio limitarsi a domandare cosa il cliente voglia sapere del prodotto.<br>"+
"<b>Ad esempio, colore, materiale, taglia.</b>"+
"<img src=\""+serverPath.replace(":3000", "")+"images/photo-compare2.jpg\" width=\"100%\">";
break;
}
if(tokenOnce.indexOf(token) < 0){
let newCloud = $('<div class="cloud '+side+'">' + text + '</div>');
setTimeout( ()=>{
content.append(newCloud);
newCloud.fadeIn();
content.animate({
scrollTop: newCloud.offset().top
}, 400);
content.find('.video-opener').on('click', (e)=>{
const show = $('#video')
const video = show.find('video')
const close = show.find('.video-close')
show.fadeIn()
video.get(0).play()
close.on('click', (e)=>{
const elem = $(e.currentTarget)
const video = elem.siblings('video')
video.get(0).pause()
elem.parent().fadeOut()
})
});
notify(true);;
},1000);
tokenOnce.push(token);
}
}
function notify(vibrate){
if(vibrate){
navigator.vibrate(500);
}
$('#notify1')[0].play();
}
*/
});
Loading…
Cancel
Save