Added chat WIP
553
scripts/communityModules/chat/FloofChat.html
Normal file
|
@ -0,0 +1,553 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Title</title>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Raleway:300,400,600,700" rel="stylesheet">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
||||
<script src="toast.min.js"></script>
|
||||
|
||||
<style>
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* Style the tab */
|
||||
div.tab {
|
||||
overflow: hidden;
|
||||
border: 1px solid #ccc;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
/* Style the buttons inside the tab */
|
||||
div.tab button {
|
||||
background-color: inherit;
|
||||
float: left;
|
||||
border: none;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
padding: 14px 16px;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
/* Change background color of buttons on hover */
|
||||
div.tab button:hover {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
/* Create an active/current tablink class */
|
||||
div.tab button.active {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
|
||||
div.dockButton {
|
||||
|
||||
position: absolute; /*or fixed*/
|
||||
right: 10px;
|
||||
|
||||
|
||||
overflow: hidden;
|
||||
border: 1px solid #ccc;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
div.dockButton button {
|
||||
background-color: inherit;
|
||||
float: right;
|
||||
border: none;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
padding: 14px 16px;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
/* Change background color of buttons on hover */
|
||||
div.dockButton button:hover {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
/* Create an active/current tablink class */
|
||||
div.dockButton button.active {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
/* Style the tab content */
|
||||
.TabContent {
|
||||
display: none;
|
||||
|
||||
padding: 6px 12px;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow-x: hidden;
|
||||
overflow-y: hidden;
|
||||
margin: 0;
|
||||
font-family: 'Raleway', sans-serif;
|
||||
color: white;
|
||||
background: linear-gradient(#2b2b2b, #0f212e);
|
||||
}
|
||||
|
||||
.Content {
|
||||
min-height: 100vh;
|
||||
font-size: 20px;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.TopBar {
|
||||
height: 40px;
|
||||
background: linear-gradient(#2b2b2b, #1e1e1e);
|
||||
font-weight: bold;
|
||||
padding: 10px 10px 10px 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100vw;
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.ChatLog {
|
||||
height: calc(100vh - 169px);
|
||||
width: calc(100vw - 40px);
|
||||
padding: 20px;
|
||||
font-size: 20px;
|
||||
color: white;
|
||||
background-color: black;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.ChatLogLine {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.ChatLogLineDisplayName {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.ChatLogLineMessage {
|
||||
}
|
||||
|
||||
.LogLogLine {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.LogLogLineMessage {
|
||||
/*font-style: italic;*/
|
||||
}
|
||||
|
||||
.ChatInput {
|
||||
color: #252525;
|
||||
/*background: linear-gradient(#575757 20%, #252525 100%);*/
|
||||
height: 60px !important;
|
||||
}
|
||||
|
||||
.ChatInputText {
|
||||
padding: 5px 0px 0px 5px;
|
||||
height: 60px !important;
|
||||
width: 100vw;
|
||||
font-size: 20px !important;
|
||||
}
|
||||
|
||||
.responsive {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
<div class="Content">
|
||||
<div id="TopBar" class="TopBar">
|
||||
<div class="tab">
|
||||
<button class="tablinks" onclick="switchTab(event, 'Local')" id="defaultOpen">Local</button>
|
||||
<button class="tablinks" onclick="switchTab(event, 'Domain')">Domain</button>
|
||||
<button class="tablinks" onclick="switchTab(event, 'FluffyDev')">FluffyDev</button>
|
||||
</div>
|
||||
<div class="topBarFiller">
|
||||
</div>
|
||||
<div class="dockButton">
|
||||
<button class="dockButton_" onclick="redock()">Redock</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="Local" class="TabContent ChatLog">
|
||||
</div>
|
||||
|
||||
<div id="Domain" class="TabContent ChatLog">
|
||||
</div>
|
||||
|
||||
<div id="FluffyDev" class="TabContent ChatLog">
|
||||
</div>
|
||||
|
||||
<div class="ChatInput">
|
||||
<input type="text" class="ChatInputText" id="ChatInputText" size="256">
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
//linky function
|
||||
//$('#ChatInputText').twemojiPicker();
|
||||
(function ($) {
|
||||
|
||||
"use strict";
|
||||
|
||||
$.fn.linky = function (options) {
|
||||
return this.each(function () {
|
||||
var $el = $(this),
|
||||
linkifiedContent = _linkify($el, options);
|
||||
|
||||
$el.html(linkifiedContent);
|
||||
});
|
||||
};
|
||||
|
||||
function _linkify($el, options) {
|
||||
var links = {
|
||||
twitter: {
|
||||
baseUrl: "https://twitter.com/",
|
||||
hashtagSearchUrl: "hashtag/"
|
||||
},
|
||||
instagram: {
|
||||
baseUrl: "http://instagram.com/",
|
||||
hashtagSearchUrl: null // Doesn't look like there is one?
|
||||
},
|
||||
github: {
|
||||
baseUrl: "https://github.com/",
|
||||
hashtagSearchUrl: null
|
||||
}
|
||||
},
|
||||
defaultOptions = {
|
||||
mentions: false,
|
||||
hashtags: false,
|
||||
urls: true,
|
||||
linkTo: "twitter" // Let's default to Twitter
|
||||
},
|
||||
extendedOptions = $.extend(defaultOptions, options),
|
||||
elContent = $el.html(),
|
||||
// Regular expression courtesy of Matthew O'Riordan, see: http://goo.gl/3syEKK
|
||||
urlRegEx = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;,:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+,~%\/\.\w\-]*)?\??(?:[\-\+=&;,:%@\.\w]*)#?(?:[\.\!\/\\\w]*))?)/g,
|
||||
matches;
|
||||
|
||||
// Linkifying URLs
|
||||
if (extendedOptions.urls) {
|
||||
matches = elContent.match(urlRegEx);
|
||||
if (matches) {
|
||||
elContent = _linkifyUrls(matches, $el);
|
||||
}
|
||||
}
|
||||
|
||||
// Linkifying mentions
|
||||
if (extendedOptions.mentions) {
|
||||
elContent = _linkifyMentions(elContent, links[extendedOptions.linkTo].baseUrl);
|
||||
}
|
||||
|
||||
// Linkifying hashtags
|
||||
if (extendedOptions.hashtags) {
|
||||
elContent = _linkifyHashtags(elContent, links[extendedOptions.linkTo]);
|
||||
}
|
||||
|
||||
return elContent;
|
||||
}
|
||||
|
||||
// For any URLs present, unless they are already identified within
|
||||
// an `a` element, linkify them.
|
||||
function _linkifyUrls(matches, $el) {
|
||||
var elContent = $el.html();
|
||||
|
||||
$.each(matches, function () {
|
||||
|
||||
//var arr = [ "jpeg", "jpg", "gif", "png" ];
|
||||
var protocol = this.split('://')[0];
|
||||
var ext = this.split('.').pop();
|
||||
|
||||
switch (true) {
|
||||
case ext == "png":
|
||||
case ext == "jpg":
|
||||
case ext == "gif":
|
||||
case ext == "jpeg":
|
||||
case ext == "PNG":
|
||||
case ext == "JPG":
|
||||
case ext == "GIF":
|
||||
case ext == "JPEG":
|
||||
elContent = elContent.replace(this, "<br/><img src='" + this + "'class=\"responsive\"><br/><a href=\"javascript:gotoClipboard('" + this + "');\" target='_blank'>" + this + "</a>");
|
||||
break;
|
||||
case ext == "iframe":
|
||||
elContent = elContent.replace(this, "<br/><iframe src='" + this + "'width=\"440\" height=\"248\" frameborder=\"0\"></iframe>");
|
||||
break;
|
||||
case ext == "webm":
|
||||
elContent = elContent.replace(this, "<br/><video controls class=\"responsive\"><source src='" + this + "' type='video/" + ext + "'></video><br/><a href=\"javascript:gotoClipboard('" + this + "');\">" + this + "</a>");
|
||||
break;
|
||||
case protocol === "HIFI":
|
||||
case protocol === "hifi":
|
||||
elContent = elContent.replace(this, "<br/><a href=\"javascript:gotoHiFi('" + this + "');\">" + this + "</a>");
|
||||
break;
|
||||
case !!this.match(/^(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?(?=.*v=((\w|-){11}))(?:\S+)?$/):
|
||||
var youtubeMatch = this.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/);
|
||||
if (youtubeMatch && youtubeMatch[2].length == 11 && this.match(/^(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?(?=.*v=((\w|-){11}))(?:\S+)?$/)) {
|
||||
elContent = "<br/><iframe width='420' height='236' src='https://www.youtube.com/embed/" + youtubeMatch[2] + "' frameborder='0'></iframe><br/><a href=\"javascript:gotoURL('" + this + "');\">" + this + "</a>";
|
||||
break;
|
||||
}
|
||||
// else fall through to default
|
||||
default:
|
||||
elContent = elContent.replace(this, "<br/><a href=\"javascript:gotoURL('" + this + "');\">" + this + "</a>");
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
return elContent;
|
||||
}
|
||||
|
||||
// Find any mentions (e.g. @andrs) and turn them into links that
|
||||
// refer to the appropriate social profile (e.g. twitter or instagram).
|
||||
function _linkifyMentions(text, baseUrl) {
|
||||
return text.replace(/(^|\s|\(|>)@(\w+)/g, "$1<a href='" + baseUrl + "$2' target='_blank'>@$2</a>");
|
||||
}
|
||||
|
||||
// Find any hashtags (e.g. #linkyrocks) and turn them into links that refer
|
||||
// to the appropriate social profile.
|
||||
function _linkifyHashtags(text, links) {
|
||||
// If there is no search URL for a hashtag, there isn't much we can do
|
||||
if (links.hashtagSearchUrl === null) return text;
|
||||
return text.replace(/(^|\s|\(|>)#((\w|[\u00A1-\uFFFF])+)/g, "$1<a href='" + links.baseUrl + links.hashtagSearchUrl + "$2' target='_blank'>#$2</a>");
|
||||
}
|
||||
|
||||
}(jQuery));
|
||||
|
||||
|
||||
var appUUID;
|
||||
|
||||
function gotoHiFi(url) {
|
||||
emitWebEvent({type: "CMD", cmd: "GOTO", url: url});
|
||||
}
|
||||
|
||||
function gotoURL(url) {
|
||||
emitWebEvent({type: "CMD", cmd: "URL", url: url});
|
||||
}
|
||||
|
||||
function gotoClipboard(url) {
|
||||
var options = {
|
||||
style: {
|
||||
main: {
|
||||
background: "#9c27b0",
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
};
|
||||
iqwerty.toast.Toast('Copied URL to Clipboard',options);
|
||||
emitWebEvent({type: "CMD", cmd: "COPY", url: url});
|
||||
}
|
||||
|
||||
function emitWebEvent(obj) {
|
||||
if (window.qt) {
|
||||
obj.appUUID = appUUID; // Appends the appUUID for checking that its from the correct html/qml.
|
||||
EventBridge.emitWebEvent(JSON.stringify(obj)); // So you can just send a JSON object without having to stringify.
|
||||
}
|
||||
}
|
||||
|
||||
function rgbToHex(colour) {
|
||||
var red = Number(colour.red).toString(16);
|
||||
if (red.length < 2) {
|
||||
red = "0" + red;
|
||||
}
|
||||
var green = Number(colour.green).toString(16);
|
||||
if (green.length < 2) {
|
||||
green = "0" + green;
|
||||
}
|
||||
var blue = Number(colour.blue).toString(16);
|
||||
if (blue.length < 2) {
|
||||
blue = "0" + blue;
|
||||
}
|
||||
return "#" + red + green + blue;
|
||||
}
|
||||
|
||||
|
||||
var messageData = {}; // The data that is sent along with the message.
|
||||
var $ChatLog; // The scrolling chat log.
|
||||
var $ChatInputText; // The text field for entering text.
|
||||
var userName;
|
||||
|
||||
|
||||
function getCurrTab() {
|
||||
|
||||
var TabContent = document.getElementsByClassName("TabContent");
|
||||
for (var i = 0; i < TabContent.length; i++) {
|
||||
if (TabContent[i].style.display === "inline") {
|
||||
return TabContent[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function redock() {
|
||||
emitWebEvent({type: "CMD", cmd: "REDOCK"});
|
||||
location.reload();
|
||||
}
|
||||
|
||||
function switchTab(evt, tabName) {
|
||||
// Declare all variables
|
||||
var i, TabContent, tablinks;
|
||||
|
||||
// Get all elements with class="tabcontent" and hide them
|
||||
TabContent = document.getElementsByClassName("TabContent");
|
||||
for (i = 0; i < TabContent.length; i++) {
|
||||
TabContent[i].style.display = "none";
|
||||
}
|
||||
|
||||
// Get all elements with class="tablinks" and remove the class "active"
|
||||
tablinks = document.getElementsByClassName("tablinks");
|
||||
for (i = 0; i < tablinks.length; i++) {
|
||||
tablinks[i].className = tablinks[i].className.replace(" active", "");
|
||||
}
|
||||
|
||||
// Show the current tab, and add an "active" class to the button that opened the tab
|
||||
document.getElementById(tabName).style.display = "inline";
|
||||
evt.currentTarget.className += " active";
|
||||
scrollChatLog(tabName);
|
||||
}
|
||||
|
||||
function logMessage(userName, message, logScreen, colour) {
|
||||
var LogScreen = $("#" + logScreen);
|
||||
|
||||
/*EventBridge.emitWebEvent(
|
||||
JSON.stringify({
|
||||
type: "sendMessage",
|
||||
userName: userName,
|
||||
message: message,
|
||||
chatID: LogScreen.id
|
||||
}));*/
|
||||
|
||||
var $logLine =
|
||||
$('<div/>')
|
||||
.addClass('LogLogLine')
|
||||
.data('chat-message', message).css("color", rgbToHex(colour))
|
||||
.appendTo(LogScreen);
|
||||
var $logLineMessage =
|
||||
$('<b/>')
|
||||
.addClass('LogLogLineMessage')
|
||||
.text(userName + ": ").css("color", rgbToHex(colour))
|
||||
.appendTo(LogScreen);
|
||||
var $logLineMessage2 =
|
||||
$('<span/>')
|
||||
.addClass('LogLogLineMessage')
|
||||
.text(message).css("color", rgbToHex(colour)).linky()
|
||||
.appendTo(LogScreen);/*
|
||||
$logLineMessage2.html($logLineMessage2.html().replace(/(http:\/\/[^\s]+)/g, "<a href='$1' target='_blank'>$1</a>"));
|
||||
$logLineMessage2.html($logLineMessage2.html().replace(/(https:\/\/[^\s]+)/g, "<a href='$1' target='_blank'>$1</a>"));
|
||||
$logLineMessage2.html($logLineMessage2.html().replace(/(hifi:\/\/[^\s]+)/g, "<a href='$1' target='_blank'>$1</a>"));*/
|
||||
}
|
||||
|
||||
function scrollChatLog(chatID) {
|
||||
var $chatID = $("#" + chatID);
|
||||
$chatID.scrollTop($chatID.scrollTop() + 100000);
|
||||
}
|
||||
|
||||
function time() {
|
||||
var d = new Date();
|
||||
var h = (d.getHours()).toString();
|
||||
var m = (d.getMinutes()).toString();
|
||||
var s = (d.getSeconds()).toString();
|
||||
var h2 = ("0" + h).slice(-2);
|
||||
var m2 = ("0" + m).slice(-2);
|
||||
var s2 = ("0" + s).slice(-2);
|
||||
s2 += (d.getMilliseconds() / 1000).toFixed(2).slice(1);
|
||||
return h2 + ":" + m2 + ":" + s2;
|
||||
}
|
||||
|
||||
function main() {
|
||||
|
||||
var parsedUrl = new URL(window.location.href);
|
||||
appUUID = parsedUrl.searchParams.get("appUUID");
|
||||
|
||||
//console.log("ChatPage: main");
|
||||
|
||||
$ChatLog = $('#Local');
|
||||
$ChatInputText = $('#ChatInputText');
|
||||
|
||||
// Whenever the chat log resizes, or the input text gets or loses focus,
|
||||
// scroll the chat log to the last line.
|
||||
$ChatInputText.on('focus blur', function (event) {
|
||||
//console.log("ChatInputText focus blur", $ChatInputText, event);
|
||||
scrollChatLog(getCurrTab().id);
|
||||
});
|
||||
|
||||
// Track when the user is typing, and handle the message when the user hits return.
|
||||
$ChatInputText.on('keydown', function (event) {
|
||||
if (event.keyCode === 13) {
|
||||
var message = $ChatInputText.val().substr(0, 256);
|
||||
$ChatInputText.val('');
|
||||
if (message !== '') {
|
||||
|
||||
emitWebEvent({type: "MSG", message: message, tab: getCurrTab().id, time: time()});
|
||||
|
||||
console.log("getCurrTab: ", getCurrTab().id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Start out with the input text in focus.
|
||||
$ChatInputText.focus();
|
||||
|
||||
// Hook up a handler for events that come from hifi.
|
||||
|
||||
if (window.qt) {
|
||||
setTimeout(function () {
|
||||
console.log("connecting to eventbridge");
|
||||
EventBridge.scriptEventReceived.connect(function (message) {
|
||||
|
||||
var temp = [];
|
||||
|
||||
try {
|
||||
temp = JSON.parse(message);
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
|
||||
if (temp.length === 1) {
|
||||
var temp2 = temp[0];
|
||||
logMessage("[" + temp2[0] + "] " + temp2[2], temp2[1], temp2[4], temp2[3]);
|
||||
scrollChatLog(temp2[4]);
|
||||
} else if (temp.length > 1) {
|
||||
temp.forEach(function (msg) {
|
||||
logMessage("[" + msg[0] + "] " + msg[2], msg[1], msg[4], msg[3]);
|
||||
scrollChatLog(msg[4]);
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 100); // Delay to allow everything to settle
|
||||
}
|
||||
|
||||
// Start out with the input text in focus.
|
||||
$ChatInputText.focus();
|
||||
|
||||
if (window.qt) {
|
||||
setTimeout(function () {
|
||||
emitWebEvent({
|
||||
"type": "ready"
|
||||
});
|
||||
}, 250); // Delay to allow everything to settle
|
||||
console.log("sending ready signal!");
|
||||
}
|
||||
}
|
||||
|
||||
// Start up once the document is loaded.
|
||||
$(document).ready(main);
|
||||
|
||||
document.getElementById("defaultOpen").click();
|
||||
</script>
|
||||
|
||||
</html>
|
287
scripts/communityModules/chat/FloofChat.js
Normal file
|
@ -0,0 +1,287 @@
|
|||
/* globals OverlayWindow */
|
||||
|
||||
var ROOT = Script.resolvePath('').split("FloofChat.js")[0];
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
shutdown();
|
||||
});
|
||||
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
var button = tablet.addButton({
|
||||
icon: ROOT + "chat.png",
|
||||
text: "Chat\nHistory"
|
||||
});
|
||||
|
||||
Script.scriptEnding.connect(function () { // So if anything errors out the tablet/toolbar button gets removed!
|
||||
tablet.removeButton(button);
|
||||
});
|
||||
|
||||
var appUUID = Uuid.generate();
|
||||
|
||||
var chatBar;
|
||||
var chatHistory;
|
||||
var historyLog = [];
|
||||
|
||||
var visible = false;
|
||||
var historyVisible = false;
|
||||
|
||||
init();
|
||||
|
||||
function init() {
|
||||
Messages.subscribe("Chat");
|
||||
historyLog = [];
|
||||
try {
|
||||
historyLog = JSON.parse(Settings.getValue("HistoryLog", "[]"));
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
|
||||
setupHistoryWindow(false);
|
||||
|
||||
chatBar = new OverlayWindow({
|
||||
// source: "http://localhost:8000/fluffytest.qml",
|
||||
source: Paths.defaultScripts + '/communityModules/chat/FloofChat.qml?' + Date.now(),
|
||||
width: 360,
|
||||
height: 180
|
||||
});
|
||||
|
||||
button.clicked.connect(toggleChatHistory);
|
||||
chatBar.fromQml.connect(fromQml);
|
||||
chatBar.sendToQml(JSON.stringify({visible: false}));
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
Messages.messageReceived.connect(messageReceived);
|
||||
}
|
||||
|
||||
function setupHistoryWindow(popout) {
|
||||
if (!popout) {
|
||||
chatHistory = new OverlayWebWindow({
|
||||
title: 'Chat History',
|
||||
source: ROOT + "FloofChat2.html?appUUID=" + appUUID + "&" + Date.now(),
|
||||
width: 900,
|
||||
height: 700,
|
||||
visible: false
|
||||
});
|
||||
chatHistory.setPosition({x: 0, y: Window.innerHeight - 700});
|
||||
chatHistory.webEventReceived.connect(onWebEventReceived);
|
||||
chatHistory.closed.connect(toggleChatHistory);
|
||||
} else {
|
||||
chatHistory = Desktop.createWindow(Paths.defaultScripts + '/communityModules/chat/webview.qml?' + Date.now(), {
|
||||
title: "Chat History",
|
||||
additionalFlags: Desktop.CLOSE_BUTTON_HIDES,
|
||||
presentationMode: Desktop.PresentationMode.NATIVE,
|
||||
visible: false,
|
||||
size: {x: 900, y: 700},
|
||||
position: {x: 0, y: Window.innerHeight - 700}
|
||||
});
|
||||
chatHistory.webEventReceived.connect(onWebEventReceived);
|
||||
chatHistory.closed.connect(toggleChatHistory);
|
||||
}
|
||||
}
|
||||
|
||||
function emitScriptEvent(obj) {
|
||||
obj.appUUID = appUUID;
|
||||
tablet.emitScriptEvent(JSON.stringify(obj));
|
||||
}
|
||||
|
||||
function toggleChatHistory() {
|
||||
historyVisible = !historyVisible;
|
||||
button.editProperties({isActive: historyVisible});
|
||||
chatHistory.visible = historyVisible;
|
||||
}
|
||||
|
||||
function onWebEventReceived(event) {
|
||||
console.log("event " + event);
|
||||
event = JSON.parse(event);
|
||||
if (event.type === "ready") {
|
||||
chatHistory.emitScriptEvent(JSON.stringify(historyLog));
|
||||
}
|
||||
if (event.type === "CMD") {
|
||||
if (event.cmd === "REDOCK") {
|
||||
if(popout){
|
||||
|
||||
}else{
|
||||
chatHistory.setPosition({x: 0, y: Window.innerHeight - 700});
|
||||
}
|
||||
}
|
||||
if (event.cmd === "GOTO") {
|
||||
var result = Window.confirm("Do you want to goto " + event.url.split("/")[2] + " ?");
|
||||
if (result) {
|
||||
location = event.url;
|
||||
}
|
||||
}
|
||||
if (event.cmd === "URL") {
|
||||
new OverlayWebWindow({
|
||||
title: 'Web',
|
||||
source: event.url,
|
||||
width: 900,
|
||||
height: 700,
|
||||
visible: true
|
||||
});
|
||||
}
|
||||
if (event.cmd === "COPY") {
|
||||
Window.copyToClipboard(event.url);
|
||||
}
|
||||
}
|
||||
if (event.type === "MSG") {
|
||||
if (event.message === "") return;
|
||||
Messages.sendMessage("Chat", JSON.stringify({
|
||||
type: "TransmitChatMessage",
|
||||
position: MyAvatar.position,
|
||||
channel: event.tab,
|
||||
colour: {red: 222, green: 222, blue: 222},
|
||||
message: event.message,
|
||||
displayName: MyAvatar.displayName
|
||||
}));
|
||||
setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
function messageReceived(channel, message, sender, local) {
|
||||
if (channel === "Chat" || channel === "Support") {
|
||||
|
||||
var cmd = {FAILED: true};
|
||||
try {
|
||||
cmd = JSON.parse(message);
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
if (!cmd.FAILED) {
|
||||
if (cmd.type === "TransmitChatMessage") {
|
||||
if (!cmd.hasOwnProperty("channel")) {
|
||||
cmd.channel = "Domain";
|
||||
}
|
||||
if (!cmd.hasOwnProperty("colour")) {
|
||||
cmd.colour = {red: 222, green: 222, blue: 222};
|
||||
}
|
||||
if (cmd.channel === "Local") {
|
||||
if (Vec3.withinEpsilon(MyAvatar.position, cmd.position, 20)) {
|
||||
addToLog(cmd.message, cmd.displayName, cmd.colour, cmd.channel);
|
||||
Messages.sendLocalMessage("Floof-Notif", JSON.stringify({
|
||||
sender: "L " + cmd.displayName,
|
||||
text: cmd.message,
|
||||
colour: {text: cmd.colour}
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
addToLog(cmd.message, cmd.displayName, cmd.colour, cmd.channel);
|
||||
Messages.sendLocalMessage("Floof-Notif", JSON.stringify({
|
||||
sender: ((cmd.channel === "Domain") ? "D " : "") + cmd.displayName,
|
||||
text: cmd.message,
|
||||
colour: {text: cmd.colour}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function time() {
|
||||
var d = new Date();
|
||||
var h = (d.getHours()).toString();
|
||||
var m = (d.getMinutes()).toString();
|
||||
var s = (d.getSeconds()).toString();
|
||||
var h2 = ("0" + h).slice(-2);
|
||||
var m2 = ("0" + m).slice(-2);
|
||||
var s2 = ("0" + s).slice(-2);
|
||||
s2 += (d.getMilliseconds() / 1000).toFixed(2).slice(1);
|
||||
return h2 + ":" + m2 + ":" + s2;
|
||||
}
|
||||
|
||||
function addToLog(msg, dp, colour, tab) {
|
||||
historyLog.push([time(), msg, dp, colour, tab]);
|
||||
chatHistory.emitScriptEvent(JSON.stringify([[time(), msg, dp, colour, tab]]));
|
||||
if (historyLog.length > 500) {
|
||||
historyLog.pop();
|
||||
}
|
||||
Settings.setValue("HistoryLog", JSON.stringify(historyLog))
|
||||
}
|
||||
|
||||
function fromQml(message) {
|
||||
var cmd = {FAILED: true};
|
||||
try {
|
||||
cmd = JSON.parse(message);
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
if (!cmd.FAILED) {
|
||||
console.log(JSON.stringify(cmd.event));
|
||||
if (cmd.type === "MSG") {
|
||||
if (cmd.message !== "") {
|
||||
if (cmd.event.modifiers === 67108864) {
|
||||
Messages.sendMessage("Chat", JSON.stringify({
|
||||
type: "TransmitChatMessage", channel: "Domain", colour: {red: 222, green: 222, blue: 222},
|
||||
message: cmd.message,
|
||||
displayName: MyAvatar.displayName
|
||||
}));
|
||||
} else {
|
||||
Messages.sendMessage("Chat", JSON.stringify({
|
||||
type: "TransmitChatMessage",
|
||||
channel: "Local",
|
||||
position: MyAvatar.position,
|
||||
colour: {red: 222, green: 222, blue: 222},
|
||||
message: cmd.message,
|
||||
displayName: MyAvatar.displayName
|
||||
}));
|
||||
}
|
||||
}
|
||||
setVisible(false);
|
||||
} else if (cmd.type === "CMD") {
|
||||
if (cmd.cmd === "Clicked") {
|
||||
toggleChatHistory()
|
||||
}
|
||||
|
||||
/*
|
||||
Messages.sendLocalMessage("Floof-Notif", JSON.stringify({
|
||||
sender: "Chat",
|
||||
text: msg,
|
||||
colour: {text: {red: 200, green: 200, blue: 200}}
|
||||
}));*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setVisible(_visible) {
|
||||
if (_visible) {
|
||||
Messages.sendLocalMessage("Floof-Notif", JSON.stringify({
|
||||
type: "options",
|
||||
offset: 64
|
||||
}));
|
||||
chatBar.sendToQml(JSON.stringify({visible: true}));
|
||||
} else {
|
||||
Messages.sendLocalMessage("Floof-Notif", JSON.stringify({
|
||||
type: "options",
|
||||
offset: -1
|
||||
}));
|
||||
chatBar.sendToQml(JSON.stringify({visible: false}));
|
||||
}
|
||||
|
||||
visible = _visible;
|
||||
}
|
||||
|
||||
function keyPressEvent(event) {
|
||||
if (event.key === 72 && !event.isAutoRepeat && event.isControl) {
|
||||
toggleChatHistory()
|
||||
}
|
||||
if (event.key === 16777220 && !event.isAutoRepeat && !visible) {
|
||||
setVisible(true);
|
||||
}
|
||||
if (event.key === 16777216 && !event.isAutoRepeat && visible) {
|
||||
setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function shutdown() {
|
||||
try {
|
||||
Messages.messageReceived.disconnect(messageReceived);
|
||||
} catch (e) {
|
||||
// empty
|
||||
}
|
||||
try {
|
||||
Controller.keyPressEvent.disconnect(keyPressEvent);
|
||||
} catch (e) {
|
||||
// empty
|
||||
}
|
||||
chatBar.close();
|
||||
chatHistory.close();
|
||||
}
|
129
scripts/communityModules/chat/FloofChat.qml
Normal file
|
@ -0,0 +1,129 @@
|
|||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
//import Hifi 1.0 as Hifi
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
property var window
|
||||
|
||||
Binding { target: root; property:'window'; value: parent.parent; when: Boolean(parent.parent) }
|
||||
|
||||
Binding { target: window; property: 'shown'; value: false; when: Boolean(window) }
|
||||
Component.onDestruction: thing && thing.destroy()
|
||||
|
||||
|
||||
signal sendToScript(var message);
|
||||
color: "#00000000"
|
||||
property alias thing: thing
|
||||
|
||||
function sendMessage(text){
|
||||
sendToScript(text);
|
||||
}
|
||||
|
||||
function fromScript(message) {
|
||||
console.log("fromScript "+message);
|
||||
var data = {failed:true};
|
||||
try{
|
||||
data = JSON.parse(message);
|
||||
} catch(e){
|
||||
//
|
||||
}
|
||||
if(!data.failed){
|
||||
if(data.cmd){
|
||||
JSConsole.executeCommand(data.msg);
|
||||
}
|
||||
console.log(data.visible);
|
||||
if(data.visible){
|
||||
thing.visible = true;
|
||||
textArea.focus = true;
|
||||
} else if(!data.visible){
|
||||
thing.visible = false;
|
||||
textArea.focus = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: thing
|
||||
parent: desktop
|
||||
x: 0
|
||||
y: parent.height - height
|
||||
width: parent.width
|
||||
height: 64
|
||||
color: "#00000000"
|
||||
z: 99
|
||||
visible:true
|
||||
|
||||
TextArea {
|
||||
id: textArea
|
||||
x: 64
|
||||
width: parent.width-64
|
||||
height: parent.height
|
||||
text:""
|
||||
textColor: "#000000"
|
||||
clip: false
|
||||
font.pointSize: 20
|
||||
|
||||
function _onEnterPressed(event)
|
||||
{
|
||||
sendMessage(JSON.stringify({type:"MSG",message:text,event:event}));
|
||||
text = "";
|
||||
}
|
||||
Keys.onReturnPressed: { _onEnterPressed(event) }
|
||||
Keys.onEnterPressed: { _onEnterPressed(event) }
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.rightMargin: -1
|
||||
anchors.bottomMargin: 0
|
||||
anchors.topMargin: 0
|
||||
anchors.leftMargin: 63
|
||||
anchors.fill: parent
|
||||
propagateComposedEvents: false
|
||||
acceptedButtons: Qt.AllButtons
|
||||
enabled: false
|
||||
onPressed: {
|
||||
thing.forceActiveFocus();
|
||||
mouse.accepted = true;
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
id: button
|
||||
x: 0
|
||||
y: 0
|
||||
width: 64
|
||||
height: 64
|
||||
text: qsTr("Button")
|
||||
clip: false
|
||||
opacity: 1
|
||||
iconSource: ""
|
||||
visible: true
|
||||
|
||||
Image {
|
||||
id: image
|
||||
x: 0
|
||||
y: 0
|
||||
width: 64
|
||||
height: 64
|
||||
visible: true
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: "chat.png"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: button
|
||||
onClicked:
|
||||
sendMessage(JSON.stringify({type:"CMD",cmd:"Clicked"}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*##^## Designer {
|
||||
D{i:0;autoSize:true;height:480;width:640}
|
||||
}
|
||||
##^##*/
|
503
scripts/communityModules/chat/FloofChat2.html
Normal file
|
@ -0,0 +1,503 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Title</title>
|
||||
|
||||
<!--Import Google Icon Font-->
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<!--Import materialize.css-->
|
||||
<link type="text/css" rel="stylesheet" href="css/materialize.css" media="screen,projection"/>
|
||||
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Raleway:300,400,600,700" rel="stylesheet">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
||||
<script src="toast.min.js"></script>
|
||||
|
||||
<style>
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
|
||||
div.dockButton {
|
||||
|
||||
position: absolute; /*or fixed*/
|
||||
right: 10px;
|
||||
|
||||
|
||||
overflow: hidden;
|
||||
border: 1px solid #ccc;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
div.dockButton button {
|
||||
background-color: inherit;
|
||||
float: right;
|
||||
border: none;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
padding: 14px 16px;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
/* Change background color of buttons on hover */
|
||||
div.dockButton button:hover {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
/* Create an active/current tablink class */
|
||||
div.dockButton button.active {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
/* Style the tab content */
|
||||
.TabContent {
|
||||
display: none;
|
||||
|
||||
padding: 6px 12px;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow-x: hidden;
|
||||
overflow-y: hidden;
|
||||
margin: 0;
|
||||
font-family: 'Raleway', sans-serif;
|
||||
color: white;
|
||||
background: linear-gradient(#2b2b2b, #0f212e);
|
||||
}
|
||||
|
||||
.Content {
|
||||
min-height: 100vh;
|
||||
font-size: 20px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
|
||||
.ChatLog {
|
||||
height: calc(100vh - 128px);
|
||||
/*height: calc(100vh - 103px);
|
||||
width: calc(100vw - 40px);*/
|
||||
padding: 20px !important;
|
||||
font-size: 20px;
|
||||
color: white;
|
||||
background-color: black;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.ChatLogLine {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.ChatLogLineDisplayName {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.ChatLogLineMessage {
|
||||
}
|
||||
|
||||
.LogLogLine {
|
||||
margin-bottom: 15px;
|
||||
padding: 10px !important;
|
||||
}
|
||||
|
||||
.LogLogLineMessage {
|
||||
/*font-style: italic;*/
|
||||
}
|
||||
|
||||
.ChatInput {
|
||||
color: #252525;
|
||||
background: #252525;
|
||||
height: 60px !important;
|
||||
}
|
||||
|
||||
.ChatInputText {
|
||||
padding: 5px !important;
|
||||
height: 50px !important;
|
||||
width: 100vw;
|
||||
font-size: 20px !important;
|
||||
background-color: white !important;
|
||||
border: white !important;
|
||||
}
|
||||
|
||||
.responsive {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.row .col {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
<div class="Content row">
|
||||
|
||||
<div class="col s12 valign-wrapper" style="padding: 10px ">
|
||||
<ul class="tabs tabs-fixed-width z-depth-2 col s6" id="tabs">
|
||||
<li class="tab col s2"><a class="black-text active" href="#Local">Local</a></li>
|
||||
<li class="tab col s2"><a class="black-text" href="#Domain">Domain</a></li>
|
||||
<li class="tab col s2"><a class="black-text" href="#FluffyDev">FluffyDev</a></li>
|
||||
</ul>
|
||||
<span class="col s4"></span>
|
||||
<a class="waves-effect waves-light btn col s2" onclick="redock()">Redock</a>
|
||||
</div>
|
||||
<div id="Local" class="ChatLog col s12">Test 1</div>
|
||||
<div id="Domain" class="col s12 ChatLog">Test 2</div>
|
||||
<div id="FluffyDev" class="col s12 ChatLog">Test 3</div>
|
||||
<input type="text" class="ChatInputText col s12" id="ChatInputText" size="256">
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
<script>
|
||||
var instance;
|
||||
|
||||
//linky function
|
||||
//$('#ChatInputText').twemojiPicker();
|
||||
(function ($) {
|
||||
|
||||
"use strict";
|
||||
|
||||
$.fn.linky = function (options) {
|
||||
return this.each(function () {
|
||||
var $el = $(this),
|
||||
linkifiedContent = _linkify($el, options);
|
||||
|
||||
$el.html(linkifiedContent);
|
||||
});
|
||||
};
|
||||
|
||||
function _linkify($el, options) {
|
||||
var links = {
|
||||
twitter: {
|
||||
baseUrl: "https://twitter.com/",
|
||||
hashtagSearchUrl: "hashtag/"
|
||||
},
|
||||
instagram: {
|
||||
baseUrl: "http://instagram.com/",
|
||||
hashtagSearchUrl: null // Doesn't look like there is one?
|
||||
},
|
||||
github: {
|
||||
baseUrl: "https://github.com/",
|
||||
hashtagSearchUrl: null
|
||||
}
|
||||
},
|
||||
defaultOptions = {
|
||||
mentions: false,
|
||||
hashtags: false,
|
||||
urls: true,
|
||||
linkTo: "twitter" // Let's default to Twitter
|
||||
},
|
||||
extendedOptions = $.extend(defaultOptions, options),
|
||||
elContent = $el.html(),
|
||||
// Regular expression courtesy of Matthew O'Riordan, see: http://goo.gl/3syEKK
|
||||
urlRegEx = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;,:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+,~%\/\.\w\-]*)?\??(?:[\-\+=&;,:%@\.\w]*)#?(?:[\.\!\/\\\w]*))?)/g,
|
||||
matches;
|
||||
|
||||
// Linkifying URLs
|
||||
if (extendedOptions.urls) {
|
||||
matches = elContent.match(urlRegEx);
|
||||
if (matches) {
|
||||
elContent = _linkifyUrls(matches, $el);
|
||||
}
|
||||
}
|
||||
|
||||
// Linkifying mentions
|
||||
if (extendedOptions.mentions) {
|
||||
elContent = _linkifyMentions(elContent, links[extendedOptions.linkTo].baseUrl);
|
||||
}
|
||||
|
||||
// Linkifying hashtags
|
||||
if (extendedOptions.hashtags) {
|
||||
elContent = _linkifyHashtags(elContent, links[extendedOptions.linkTo]);
|
||||
}
|
||||
|
||||
return elContent;
|
||||
}
|
||||
|
||||
// For any URLs present, unless they are already identified within
|
||||
// an `a` element, linkify them.
|
||||
function _linkifyUrls(matches, $el) {
|
||||
var elContent = $el.html();
|
||||
|
||||
$.each(matches, function () {
|
||||
|
||||
//var arr = [ "jpeg", "jpg", "gif", "png" ];
|
||||
var protocol = this.split('://')[0];
|
||||
var ext = this.split('.').pop();
|
||||
|
||||
switch (true) {
|
||||
case ext == "png":
|
||||
case ext == "jpg":
|
||||
case ext == "gif":
|
||||
case ext == "jpeg":
|
||||
case ext == "PNG":
|
||||
case ext == "JPG":
|
||||
case ext == "GIF":
|
||||
case ext == "JPEG":
|
||||
elContent = elContent.replace(this, "<br/><img src='" + this + "'class=\"responsive z-depth-2\"><br/><a href=\"javascript:gotoClipboard('" + this + "');\" target='_blank'>" + this + "</a>");
|
||||
break;
|
||||
case ext == "iframe":
|
||||
elContent = elContent.replace(this, "<br/><iframe class=\"z-depth-2\" src='" + this + "'width=\"440\" height=\"248\" frameborder=\"0\"></iframe>");
|
||||
break;
|
||||
case ext == "webm":
|
||||
elContent = elContent.replace(this, "<br/><video controls class=\"z-depth-2 responsive\"><source src='" + this + "' type='video/" + ext + "'></video><br/><a href=\"javascript:gotoClipboard('" + this + "');\">" + this + "</a>");
|
||||
break;
|
||||
case protocol === "HIFI":
|
||||
case protocol === "hifi":
|
||||
elContent = elContent.replace(this, "<br/><a href=\"javascript:gotoHiFi('" + this + "');\">" + this + "</a>");
|
||||
break;
|
||||
case !!this.match(/^(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?(?=.*v=((\w|-){11}))(?:\S+)?$/):
|
||||
var youtubeMatch = this.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/);
|
||||
if (youtubeMatch && youtubeMatch[2].length == 11 && this.match(/^(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?(?=.*v=((\w|-){11}))(?:\S+)?$/)) {
|
||||
elContent = "<br/><iframe class=\"z-depth-2\" width='420' height='236' src='https://www.youtube.com/embed/" + youtubeMatch[2] + "' frameborder='0'></iframe><br/><a href=\"javascript:gotoURL('" + this + "');\">" + this + "</a>";
|
||||
break;
|
||||
}
|
||||
// else fall through to default
|
||||
default:
|
||||
elContent = elContent.replace(this, "<br/><a href=\"javascript:gotoURL('" + this + "');\">" + this + "</a>");
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
return elContent;
|
||||
}
|
||||
|
||||
// Find any mentions (e.g. @andrs) and turn them into links that
|
||||
// refer to the appropriate social profile (e.g. twitter or instagram).
|
||||
function _linkifyMentions(text, baseUrl) {
|
||||
return text.replace(/(^|\s|\(|>)@(\w+)/g, "$1<a href='" + baseUrl + "$2' target='_blank'>@$2</a>");
|
||||
}
|
||||
|
||||
// Find any hashtags (e.g. #linkyrocks) and turn them into links that refer
|
||||
// to the appropriate social profile.
|
||||
function _linkifyHashtags(text, links) {
|
||||
// If there is no search URL for a hashtag, there isn't much we can do
|
||||
if (links.hashtagSearchUrl === null) return text;
|
||||
return text.replace(/(^|\s|\(|>)#((\w|[\u00A1-\uFFFF])+)/g, "$1<a href='" + links.baseUrl + links.hashtagSearchUrl + "$2' target='_blank'>#$2</a>");
|
||||
}
|
||||
|
||||
}(jQuery));
|
||||
|
||||
|
||||
var appUUID;
|
||||
|
||||
function gotoHiFi(url) {
|
||||
emitWebEvent({type: "CMD", cmd: "GOTO", url: url});
|
||||
}
|
||||
|
||||
function gotoURL(url) {
|
||||
emitWebEvent({type: "CMD", cmd: "URL", url: url});
|
||||
}
|
||||
|
||||
function gotoClipboard(url) {
|
||||
var options = {
|
||||
style: {
|
||||
main: {
|
||||
background: "#9c27b0",
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
};
|
||||
M.toast({html: 'Copied URL to Clipboard', classes: 'rounded pink white-text'});
|
||||
//iqwerty.toast.Toast('Copied URL to Clipboard', options);
|
||||
emitWebEvent({type: "CMD", cmd: "COPY", url: url});
|
||||
}
|
||||
|
||||
function emitWebEvent(obj) {
|
||||
if (window.qt) {
|
||||
obj.appUUID = appUUID; // Appends the appUUID for checking that its from the correct html/qml.
|
||||
EventBridge.emitWebEvent(JSON.stringify(obj)); // So you can just send a JSON object without having to stringify.
|
||||
}
|
||||
}
|
||||
|
||||
function rgbToHex(colour) {
|
||||
var red = Number(colour.red).toString(16);
|
||||
if (red.length < 2) {
|
||||
red = "0" + red;
|
||||
}
|
||||
var green = Number(colour.green).toString(16);
|
||||
if (green.length < 2) {
|
||||
green = "0" + green;
|
||||
}
|
||||
var blue = Number(colour.blue).toString(16);
|
||||
if (blue.length < 2) {
|
||||
blue = "0" + blue;
|
||||
}
|
||||
return "#" + red + green + blue;
|
||||
}
|
||||
|
||||
|
||||
var messageData = {}; // The data that is sent along with the message.
|
||||
var $ChatLog; // The scrolling chat log.
|
||||
var $ChatInputText; // The text field for entering text.
|
||||
var userName;
|
||||
|
||||
|
||||
function getCurrTab() {
|
||||
return instance.$activeTabLink.html();
|
||||
}
|
||||
|
||||
function redock() {
|
||||
emitWebEvent({type: "CMD", cmd: "REDOCK"});
|
||||
location.reload();
|
||||
}
|
||||
|
||||
function logMessage(userName, message, logScreen, colour) {
|
||||
var LogScreen = $("#" + logScreen);
|
||||
|
||||
/*EventBridge.emitWebEvent(
|
||||
JSON.stringify({
|
||||
type: "sendMessage",
|
||||
userName: userName,
|
||||
message: message,
|
||||
chatID: LogScreen.id
|
||||
}));*/
|
||||
|
||||
var $logLine =
|
||||
$('<div/>')
|
||||
.addClass('LogLogLine')
|
||||
.addClass('card-panel')
|
||||
.addClass('blue-grey')
|
||||
.addClass('darken-4')
|
||||
.addClass('z-depth-2')
|
||||
.data('chat-message', message).css("color", rgbToHex(colour))
|
||||
.appendTo(LogScreen);
|
||||
var $logLineMessage =
|
||||
$('<b/>')
|
||||
.addClass('LogLogLineMessage')
|
||||
.text(userName + ": ").css("color", rgbToHex(colour))
|
||||
.appendTo($logLine);
|
||||
var $logLineMessage2 =
|
||||
$('<span/>')
|
||||
.addClass('LogLogLineMessage')
|
||||
.text(message).css("color", rgbToHex(colour)).linky()
|
||||
.appendTo($logLine);/*
|
||||
$logLineMessage2.html($logLineMessage2.html().replace(/(http:\/\/[^\s]+)/g, "<a href='$1' target='_blank'>$1</a>"));
|
||||
$logLineMessage2.html($logLineMessage2.html().replace(/(https:\/\/[^\s]+)/g, "<a href='$1' target='_blank'>$1</a>"));
|
||||
$logLineMessage2.html($logLineMessage2.html().replace(/(hifi:\/\/[^\s]+)/g, "<a href='$1' target='_blank'>$1</a>"));*/
|
||||
}
|
||||
|
||||
function scrollChatLog(chatID) {
|
||||
var $chatID = $("#" + chatID);
|
||||
$chatID.scrollTop($chatID.scrollTop() + 100000);
|
||||
}
|
||||
|
||||
function time() {
|
||||
var d = new Date();
|
||||
var h = (d.getHours()).toString();
|
||||
var m = (d.getMinutes()).toString();
|
||||
var s = (d.getSeconds()).toString();
|
||||
var h2 = ("0" + h).slice(-2);
|
||||
var m2 = ("0" + m).slice(-2);
|
||||
var s2 = ("0" + s).slice(-2);
|
||||
s2 += (d.getMilliseconds() / 1000).toFixed(2).slice(1);
|
||||
return h2 + ":" + m2 + ":" + s2;
|
||||
}
|
||||
|
||||
function main() {
|
||||
|
||||
instance = M.Tabs.init(document.getElementById("tabs"), {
|
||||
"onShow": function (e) {
|
||||
scrollChatLog(getCurrTab());
|
||||
}
|
||||
});
|
||||
instance.select("Local");
|
||||
|
||||
var parsedUrl = new URL(window.location.href);
|
||||
appUUID = parsedUrl.searchParams.get("appUUID");
|
||||
|
||||
//console.log("ChatPage: main");
|
||||
|
||||
$ChatLog = $('#Local');
|
||||
$ChatInputText = $('#ChatInputText');
|
||||
|
||||
// Whenever the chat log resizes, or the input text gets or loses focus,
|
||||
// scroll the chat log to the last line.
|
||||
$ChatInputText.on('focus', function (event) {
|
||||
//console.log("ChatInputText focus blur", $ChatInputText, event);
|
||||
scrollChatLog(getCurrTab());
|
||||
});
|
||||
|
||||
// Track when the user is typing, and handle the message when the user hits return.
|
||||
$ChatInputText.on('keydown', function (event) {
|
||||
if (event.keyCode === 13) {
|
||||
var message = $ChatInputText.val().substr(0, 256);
|
||||
$ChatInputText.val('');
|
||||
if (message !== '') {
|
||||
|
||||
emitWebEvent({type: "MSG", message: message, tab: getCurrTab(), time: time()});
|
||||
|
||||
console.log("getCurrTab: ", getCurrTab());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Start out with the input text in focus.
|
||||
$ChatInputText.focus();
|
||||
|
||||
// Hook up a handler for events that come from hifi.
|
||||
|
||||
if (window.qt) {
|
||||
setTimeout(function () {
|
||||
console.log("connecting to eventbridge");
|
||||
EventBridge.scriptEventReceived.connect(function (message) {
|
||||
|
||||
var temp = [];
|
||||
|
||||
try {
|
||||
temp = JSON.parse(message);
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
|
||||
if (temp.length === 1) {
|
||||
var temp2 = temp[0];
|
||||
logMessage("[" + temp2[0] + "] " + temp2[2], temp2[1], temp2[4], temp2[3]);
|
||||
scrollChatLog(temp2[4]);
|
||||
} else if (temp.length > 1) {
|
||||
temp.forEach(function (msg) {
|
||||
logMessage("[" + msg[0] + "] " + msg[2], msg[1], msg[4], msg[3]);
|
||||
scrollChatLog(msg[4]);
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 100); // Delay to allow everything to settle
|
||||
}
|
||||
|
||||
// Start out with the input text in focus.
|
||||
$ChatInputText.focus();
|
||||
|
||||
if (window.qt) {
|
||||
setTimeout(function () {
|
||||
emitWebEvent({
|
||||
"type": "ready"
|
||||
});
|
||||
}, 250); // Delay to allow everything to settle
|
||||
console.log("sending ready signal!");
|
||||
}
|
||||
}
|
||||
|
||||
// Start up once the document is loaded.
|
||||
$(document).ready(main);
|
||||
|
||||
//document.getElementById("defaultOpen").click();
|
||||
</script>
|
||||
<script type="text/javascript" src="js/materialize.min.js"></script>
|
||||
|
||||
</html>
|
BIN
scripts/communityModules/chat/chat.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
9086
scripts/communityModules/chat/css/materialize.css
vendored
Normal file
13
scripts/communityModules/chat/css/materialize.min.css
vendored
Normal file
67
scripts/communityModules/chat/emoticons/COPYING
Normal file
|
@ -0,0 +1,67 @@
|
|||
Creative Commons Attribution-ShareAlike 2.5 License Agreement
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM ITS USE.
|
||||
|
||||
License
|
||||
|
||||
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
||||
|
||||
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
|
||||
|
||||
1. Definitions
|
||||
|
||||
1. "Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with a number of other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License.
|
||||
2. "Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this License.
|
||||
3. "Licensor" means the individual or entity that offers the Work under the terms of this License.
|
||||
4. "Original Author" means the individual or entity who created the Work.
|
||||
5. "Work" means the copyrightable work of authorship offered under the terms of this License.
|
||||
6. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
|
||||
7. "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike.
|
||||
|
||||
2. Fair Use Rights. Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws.
|
||||
|
||||
3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:
|
||||
|
||||
1. to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works;
|
||||
2. to create and reproduce Derivative Works;
|
||||
3. to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works;
|
||||
4. to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission Derivative Works.
|
||||
5.
|
||||
|
||||
For the avoidance of doubt, where the work is a musical composition:
|
||||
1. Performance Royalties Under Blanket Licenses. Licensor waives the exclusive right to collect, whether individually or via a performance rights society (e.g. ASCAP, BMI, SESAC), royalties for the public performance or public digital performance (e.g. webcast) of the Work.
|
||||
2. Mechanical Rights and Statutory Royalties. Licensor waives the exclusive right to collect, whether individually or via a music rights society or designated agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from the Work ("cover version") and distribute, subject to the compulsory license created by 17 USC Section 115 of the US Copyright Act (or the equivalent in other jurisdictions).
|
||||
6. Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where the Work is a sound recording, Licensor waives the exclusive right to collect, whether individually or via a performance-rights society (e.g. SoundExchange), royalties for the public digital performance (e.g. webcast) of the Work, subject to the compulsory license created by 17 USC Section 114 of the US Copyright Act (or the equivalent in other jurisdictions).
|
||||
|
||||
The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by Licensor are hereby reserved.
|
||||
|
||||
4. Restrictions.The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:
|
||||
|
||||
1. You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any credit as required by clause 4(c), as requested. If You create a Derivative Work, upon notice from any Licensor You must, to the extent practicable, remove from the Derivative Work any credit as required by clause 4(c), as requested.
|
||||
2. You may distribute, publicly display, publicly perform, or publicly digitally perform a Derivative Work only under the terms of this License, a later version of this License with the same License Elements as this License, or a Creative Commons iCommons license that contains the same License Elements as this License (e.g. Attribution-ShareAlike 2.5 Japan). You must include a copy of, or the Uniform Resource Identifier for, this License or other license specified in the previous sentence with every copy or phonorecord of each Derivative Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Derivative Works that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder, and You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Derivative Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Derivative Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Derivative Work itself to be made subject to the terms of this License.
|
||||
3. If you distribute, publicly display, publicly perform, or publicly digitally perform the Work or any Derivative Works or Collective Works, You must keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or (ii) if the Original Author and/or Licensor designate another party or parties (e.g. a sponsor institute, publishing entity, journal) for attribution in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; the title of the Work if supplied; to the extent reasonably practicable, the Uniform Resource Identifier, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and in the case of a Derivative Work, a credit identifying the use of the Work in the Derivative Work (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). Such credit may be implemented in any reasonable manner; provided, however, that in the case of a Derivative Work or Collective Work, at a minimum such credit will appear where any other comparable authorship credit appears and in a manner at least as prominent as such other comparable authorship credit.
|
||||
|
||||
5. Representations, Warranties and Disclaimer
|
||||
|
||||
UNLESS OTHERWISE AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE MATERIALS, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
|
||||
|
||||
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
7. Termination
|
||||
|
||||
1. This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Derivative Works or Collective Works from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
|
||||
2. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.
|
||||
|
||||
8. Miscellaneous
|
||||
|
||||
1. Each time You distribute or publicly digitally perform the Work or a Collective Work, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
|
||||
2. Each time You distribute or publicly digitally perform a Derivative Work, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
|
||||
3. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
|
||||
4. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
|
||||
5. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.
|
||||
|
||||
Creative Commons is not a party to this License, and makes no warranty whatsoever in connection with the Work. Creative Commons will not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding the foregoing two (2) sentences, if Creative Commons has expressly identified itself as the Licensor hereunder, it shall have all rights and obligations of Licensor.
|
||||
|
||||
Except for the limited purpose of indicating to the public that the Work is licensed under the CCPL, neither party will use the trademark "Creative Commons" or any related trademark or logo of Creative Commons without the prior written consent of Creative Commons. Any permitted use will be in compliance with Creative Commons' then-current trademark usage guidelines, as may be published on its website or otherwise made available upon request from time to time.
|
||||
|
||||
Creative Commons may be contacted at http://creativecommons.org/.
|
12
scripts/communityModules/chat/emoticons/README
Normal file
|
@ -0,0 +1,12 @@
|
|||
Tango Icon Theme
|
||||
----------------
|
||||
|
||||
This is an icon theme that follows the Tango visual guidelines [1]. Currently
|
||||
it depends on Imagemagick for creation of 24x24 bitmaps by adding a 1px padding
|
||||
around the 22x22px version. For GNOME and KDE you will also need
|
||||
icon-naming-utils that allow the theme to work in these environments before
|
||||
they follow the new naming scheme [2].
|
||||
|
||||
|
||||
[1] http://tango-project.org/Tango_Icon_Theme_Guidelines
|
||||
[2] http://tango-project.org/Standard_Icon_Naming_Specification
|
BIN
scripts/communityModules/chat/emoticons/face-angel.png
Normal file
After Width: | Height: | Size: 992 B |
BIN
scripts/communityModules/chat/emoticons/face-crying.png
Normal file
After Width: | Height: | Size: 936 B |
BIN
scripts/communityModules/chat/emoticons/face-devilish.png
Normal file
After Width: | Height: | Size: 855 B |
BIN
scripts/communityModules/chat/emoticons/face-glasses.png
Normal file
After Width: | Height: | Size: 949 B |
BIN
scripts/communityModules/chat/emoticons/face-grin.png
Normal file
After Width: | Height: | Size: 905 B |
BIN
scripts/communityModules/chat/emoticons/face-kiss.png
Normal file
After Width: | Height: | Size: 919 B |
BIN
scripts/communityModules/chat/emoticons/face-monkey.png
Normal file
After Width: | Height: | Size: 784 B |
BIN
scripts/communityModules/chat/emoticons/face-plain.png
Normal file
After Width: | Height: | Size: 894 B |
BIN
scripts/communityModules/chat/emoticons/face-sad.png
Normal file
After Width: | Height: | Size: 918 B |
BIN
scripts/communityModules/chat/emoticons/face-smile-big.png
Normal file
After Width: | Height: | Size: 896 B |
BIN
scripts/communityModules/chat/emoticons/face-smile.png
Normal file
After Width: | Height: | Size: 919 B |
BIN
scripts/communityModules/chat/emoticons/face-surprise.png
Normal file
After Width: | Height: | Size: 917 B |
BIN
scripts/communityModules/chat/emoticons/face-wink.png
Normal file
After Width: | Height: | Size: 914 B |
12374
scripts/communityModules/chat/js/materialize.js
vendored
Normal file
6
scripts/communityModules/chat/js/materialize.min.js
vendored
Normal file
52
scripts/communityModules/chat/webview.qml
Normal file
|
@ -0,0 +1,52 @@
|
|||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.2
|
||||
import QtWebChannel 1.0
|
||||
import controls 1.0
|
||||
import hifi.toolbars 1.0
|
||||
import QtGraphicalEffects 1.0
|
||||
import controlsUit 1.0 as HifiControls
|
||||
import stylesUit 1.0
|
||||
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
|
||||
signal sendToScript(var message);
|
||||
color: "#00000000"
|
||||
property alias thing: thing
|
||||
|
||||
function sendMessage(text){
|
||||
sendToScript(text);
|
||||
}
|
||||
|
||||
function fromScript(message) {
|
||||
console.log("fromScript "+message);
|
||||
var data = {failed:true};
|
||||
try{
|
||||
data = JSON.parse(message);
|
||||
} catch(e){
|
||||
//
|
||||
}
|
||||
if(!data.failed){
|
||||
if(data.cmd){
|
||||
JSConsole.executeCommand(data.msg);
|
||||
}
|
||||
console.log(data.visible);
|
||||
if(data.visible){
|
||||
thing.visible = true;
|
||||
textArea.focus = true;
|
||||
} else if(!data.visible){
|
||||
thing.visible = false;
|
||||
textArea.focus = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebView {
|
||||
id: overlayWindow
|
||||
url: Qt.resolvedUrl("FloofChat2.html?appUUID="+QUrlQuery::queryItemValue()
|
||||
enabled: true
|
||||
blurOnCtrlShift: false
|
||||
}
|
||||
}
|