1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 17:59:55 +02:00
This commit is contained in:
Daniel Neto 2023-07-02 11:34:54 -03:00
parent 8819a287fa
commit 7ddce01f98

View file

@ -44,7 +44,7 @@ try {
if (!height) { if (!height) {
height = $('body').height(); height = $('body').height();
} }
parent.postMessage({height: height}, '*'); parent.postMessage({ height: height }, '*');
} else if (e.data.play) { } else if (e.data.play) {
var currentTime = e.data.play.currentTime; var currentTime = e.data.play.currentTime;
var muted = !empty(e.data.play.muted); var muted = !empty(e.data.play.muted);
@ -477,7 +477,7 @@ async function mouseEffect() {
var gif = $(this).find(".thumbsGIF"); var gif = $(this).find(".thumbsGIF");
var jpg = $(this).find(".thumbsJPG"); var jpg = $(this).find(".thumbsJPG");
try { try {
gif.lazy({effect: 'fadeIn'}); gif.lazy({ effect: 'fadeIn' });
setTimeout(function () { setTimeout(function () {
gif.height(jpg.height()); gif.height(jpg.height());
gif.width(jpg.width()); gif.width(jpg.width());
@ -591,9 +591,9 @@ async function addViewFromCookie() {
var addView_playerCurrentTime = Cookies.get('addView_playerCurrentTime'); var addView_playerCurrentTime = Cookies.get('addView_playerCurrentTime');
var addView_seconds_watching_video = Cookies.get('addView_seconds_watching_video'); var addView_seconds_watching_video = Cookies.get('addView_seconds_watching_video');
if (!addView_PHPSESSID || addView_PHPSESSID === 'false' || if (!addView_PHPSESSID || addView_PHPSESSID === 'false' ||
!addView_videos_id || addView_videos_id === 'false' || !addView_videos_id || addView_videos_id === 'false' ||
!addView_playerCurrentTime || addView_playerCurrentTime === 'false' || !addView_playerCurrentTime || addView_playerCurrentTime === 'false' ||
!addView_seconds_watching_video || addView_seconds_watching_video === 'false') { !addView_seconds_watching_video || addView_seconds_watching_video === 'false') {
return false; return false;
} }
//console.log('addViewFromCookie', addView_videos_id, addView_playerCurrentTime, addView_seconds_watching_video); //console.log('addViewFromCookie', addView_videos_id, addView_playerCurrentTime, addView_seconds_watching_video);
@ -644,7 +644,7 @@ function getPlayerButtonIndex(name) {
async function copyToClipboard(text) { async function copyToClipboard(text) {
$('body').append('<textarea id="elementToCopyAvideo" style="filter: alpha(opacity=0);-moz-opacity: 0;-khtml-opacity: 0; opacity: 0;position: absolute;z-index: -9999;top: 0;left: 0;pointer-events: none;"></textarea>'); $('body').append('<textarea id="elementToCopyAvideo" style="filter: alpha(opacity=0);-moz-opacity: 0;-khtml-opacity: 0; opacity: 0;position: absolute;z-index: -9999;top: 0;left: 0;pointer-events: none;"></textarea>');
$('#elementToCopyAvideo').css({'top': mouseY, 'left': 0}).fadeIn('slow'); $('#elementToCopyAvideo').css({ 'top': mouseY, 'left': 0 }).fadeIn('slow');
$('#elementToCopyAvideo').val(text); $('#elementToCopyAvideo').val(text);
$('#elementToCopyAvideo').focus(); $('#elementToCopyAvideo').focus();
$('#elementToCopyAvideo').select(); $('#elementToCopyAvideo').select();
@ -893,7 +893,7 @@ async function showMuteTooltip() {
$("#mainVideo .vjs-volume-panel").attr("data-toggle", "tooltip"); $("#mainVideo .vjs-volume-panel").attr("data-toggle", "tooltip");
$("#mainVideo .vjs-volume-panel").attr("data-placement", "top"); $("#mainVideo .vjs-volume-panel").attr("data-placement", "top");
$("#mainVideo .vjs-volume-panel").attr("title", "Click to activate the sound"); $("#mainVideo .vjs-volume-panel").attr("title", "Click to activate the sound");
$('#mainVideo .vjs-volume-panel[data-toggle="tooltip"]').tooltip({container: '.vjs-control-bar', html: true}); $('#mainVideo .vjs-volume-panel[data-toggle="tooltip"]').tooltip({ container: '.vjs-control-bar', html: true });
$('#mainVideo .vjs-volume-panel[data-toggle="tooltip"]').tooltip('show'); $('#mainVideo .vjs-volume-panel[data-toggle="tooltip"]').tooltip('show');
$("#mainVideo .vjs-volume-panel").click(function () { $("#mainVideo .vjs-volume-panel").click(function () {
//console.log("remove unmute tooltip"); //console.log("remove unmute tooltip");
@ -1043,9 +1043,9 @@ function formatBytes(bytes, decimals) {
if (bytes == 0) if (bytes == 0)
return '0 Bytes'; return '0 Bytes';
var k = 1024, var k = 1024,
dm = decimals <= 0 ? 0 : decimals || 2, dm = decimals <= 0 ? 0 : decimals || 2,
sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
i = Math.floor(Math.log(bytes) / Math.log(k)); i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
} }
@ -1199,31 +1199,31 @@ function isAutoplayEnabled() {
consoleLog("isAutoplayEnabled always autoplay live contents"); consoleLog("isAutoplayEnabled always autoplay live contents");
return true; return true;
} else } else
if ($("#autoplay").length) { if ($("#autoplay").length) {
autoplay = $("#autoplay").is(":checked"); autoplay = $("#autoplay").is(":checked");
consoleLog("isAutoplayEnabled #autoplay said " + ((autoplay) ? "Yes" : "No")); consoleLog("isAutoplayEnabled #autoplay said " + ((autoplay) ? "Yes" : "No"));
setAutoplay(autoplay);
return autoplay;
} else if (
typeof Cookies !== 'undefined' &&
typeof Cookies.get('autoplay') !== 'undefined'
) {
if (Cookies.get('autoplay') === 'true' || Cookies.get('autoplay') == true) {
consoleLog("isAutoplayEnabled Cookie said Yes ");
setAutoplay(true);
return true;
} else {
consoleLog("isAutoplayEnabled Cookie said No ");
setAutoplay(false);
return false;
}
} else {
if (typeof autoplay !== 'undefined') {
consoleLog("isAutoplayEnabled autoplay said " + ((autoplay) ? "Yes" : "No"));
setAutoplay(autoplay); setAutoplay(autoplay);
return autoplay; return autoplay;
} else if (
typeof Cookies !== 'undefined' &&
typeof Cookies.get('autoplay') !== 'undefined'
) {
if (Cookies.get('autoplay') === 'true' || Cookies.get('autoplay') == true) {
consoleLog("isAutoplayEnabled Cookie said Yes ");
setAutoplay(true);
return true;
} else {
consoleLog("isAutoplayEnabled Cookie said No ");
setAutoplay(false);
return false;
}
} else {
if (typeof autoplay !== 'undefined') {
consoleLog("isAutoplayEnabled autoplay said " + ((autoplay) ? "Yes" : "No"));
setAutoplay(autoplay);
return autoplay;
}
} }
}
setAutoplay(false); setAutoplay(false);
consoleLog("isAutoplayEnabled Default is No "); consoleLog("isAutoplayEnabled Default is No ");
return false; return false;
@ -1346,7 +1346,7 @@ function avideoAlertOnceForceConfirm(title, msg, type) {
} }
function _avideoToast(msg, icon) { function _avideoToast(msg, icon) {
var options = {text: msg, hideAfter: 7000}; var options = { text: msg, hideAfter: 7000 };
if (icon) { if (icon) {
options.icon = icon; options.icon = icon;
} }
@ -1540,7 +1540,7 @@ function avideoWindowIframe(url) {
html += '</div>'; html += '</div>';
html += '</div>'; html += '</div>';
$('body').append(html); $('body').append(html);
$("#draggable").draggable({handle: ".panel-heading", containment: "parent"}); $("#draggable").draggable({ handle: ".panel-heading", containment: "parent" });
//$( "div, p" ).disableSelection(); //$( "div, p" ).disableSelection();
$("#draggable").resizable(); $("#draggable").resizable();
} }
@ -1720,7 +1720,7 @@ function avideoModalIframeRemove() {
} }
} }
function json_decode(jsonString){ function json_decode(jsonString) {
if (typeof jsonString === 'string') { if (typeof jsonString === 'string') {
try { try {
return JSON.parse(jsonString); return JSON.parse(jsonString);
@ -1780,7 +1780,7 @@ function avideoTooltip(selector, text) {
$(selector).attr('title', text); $(selector).attr('title', text);
$(selector).attr('data-toggle', 'tooltip'); $(selector).attr('data-toggle', 'tooltip');
$(selector).attr('data-original-title', text); $(selector).attr('data-original-title', text);
$(selector).tooltip({html: true}); $(selector).tooltip({ html: true });
} }
function fixAdSize() { function fixAdSize() {
@ -1788,8 +1788,8 @@ function fixAdSize() {
if (ad_container.length) { if (ad_container.length) {
height = ad_container.css('height'); height = ad_container.css('height');
width = ad_container.css('width'); width = ad_container.css('width');
$($('#mainVideo_ima-ad-container div:first-child')[0]).css({'height': height}); $($('#mainVideo_ima-ad-container div:first-child')[0]).css({ 'height': height });
$($('#mainVideo_ima-ad-container div:first-child')[0]).css({'width': width}); $($('#mainVideo_ima-ad-container div:first-child')[0]).css({ 'width': width });
} }
} }
@ -1911,11 +1911,11 @@ function clearCache(showPleaseWait, FirstPage, sessionOnly) {
function validURL(str) { function validURL(str) {
var pattern = new RegExp('^(https?:\\/\\/)?' + // protocol var pattern = new RegExp('^(https?:\\/\\/)?' + // protocol
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name
'((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
'(\\:\\d+)?(\\/[-a-z\\d%_.~+:]*)*' + // port and path '(\\:\\d+)?(\\/[-a-z\\d%_.~+:]*)*' + // port and path
'(\\?[;&a-z\\d%_.~+=-]*)?' + // query string '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
'(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
return !!pattern.test(str); return !!pattern.test(str);
} }
@ -2184,11 +2184,11 @@ function removeDuplicatedGetParam(_url) {
return _url; return _url;
} }
var params = queryParam.split('&'), var params = queryParam.split('&'),
results = {}; results = {};
for (var i = 0; i < params.length; i++) { for (var i = 0; i < params.length; i++) {
var temp = params[i].split('='), var temp = params[i].split('='),
key = temp[0], key = temp[0],
val = temp[1]; val = temp[1];
results[key] = val; results[key] = val;
} }
@ -2206,11 +2206,11 @@ function removeGetParam(_url, parameter) {
return _url; return _url;
} }
var params = queryParam.split('&'), var params = queryParam.split('&'),
results = {}; results = {};
for (var i = 0; i < params.length; i++) { for (var i = 0; i < params.length; i++) {
var temp = params[i].split('='), var temp = params[i].split('='),
key = temp[0], key = temp[0],
val = temp[1]; val = temp[1];
if (key !== parameter) { if (key !== parameter) {
results[key] = val; results[key] = val;
} }
@ -2248,7 +2248,7 @@ function readFileCroppie(input, crop) {
function getCroppie(uploadCropObject, callback, width, height) { function getCroppie(uploadCropObject, callback, width, height) {
//console.log('getCroppie 1', uploadCropObject); //console.log('getCroppie 1', uploadCropObject);
var ret = uploadCropObject.croppie('result', {type: 'base64', size: {width: width, height: height}, format: 'png'}).then(function (resp) { var ret = uploadCropObject.croppie('result', { type: 'base64', size: { width: width, height: height }, format: 'png' }).then(function (resp) {
////console.log('getCroppie 2 ' + callback, resp); ////console.log('getCroppie 2 ' + callback, resp);
eval(callback + "(resp);"); eval(callback + "(resp);");
}).catch(function (err) { }).catch(function (err) {
@ -2258,31 +2258,36 @@ function getCroppie(uploadCropObject, callback, width, height) {
//console.log('getCroppie 3', ret); //console.log('getCroppie 3', ret);
} }
let tooltipTimeout = null;
async function setToolTips() { async function setToolTips() {
var selector = '[data-toggle="tooltip"]'; if (tooltipTimeout) {
if (!$(selector).not('.alreadyTooltip').length) { clearTimeout(tooltipTimeout);
return false; tooltipTimeout = null;
} }
try {
$(selector).not('.alreadyTooltip').tooltip({container: 'body', html: true}); tooltipTimeout = setTimeout(function () {
$(selector).not('.alreadyTooltip').on('click', function () { const selector = '[data-toggle="tooltip"]';
var t = this; if (!$(selector).not('.alreadyTooltip').length) {
setTimeout(function () { return false;
}
try {
$(selector).not('.alreadyTooltip').tooltip({ container: 'body', html: true });
$(selector).not('.alreadyTooltip').on('click', function () {
const t = this;
try { try {
$(t).tooltip('hide'); $(t).tooltip('hide');
} catch (e) { } catch (e) { }
});
} $(selector).addClass('alreadyTooltip');
}, 2000); } catch (e) {
}); console.log('setToolTips', e);
$(selector).addClass('alreadyTooltip'); setTimeout(function () {
} catch (e) { setToolTips();
console.log('setToolTips', e); }, 1000);
setTimeout(function () { }
setToolTips(); }, 2000);
}, 1000);
}
} }
function avideoSocketIsActive() { function avideoSocketIsActive() {
@ -2296,18 +2301,18 @@ function avideoSocketIsActive() {
function isMediaSiteURL(url) { function isMediaSiteURL(url) {
if (validURL(url)) { if (validURL(url)) {
if (url.match(/youtube/i) || if (url.match(/youtube/i) ||
url.match(/youtu\.be/i) || url.match(/youtu\.be/i) ||
url.match(/vimeo/i) || url.match(/vimeo/i) ||
url.match(/dailymotion/i) || url.match(/dailymotion/i) ||
url.match(/metacafe/i) || url.match(/metacafe/i) ||
url.match(/vid\.me/i) || url.match(/vid\.me/i) ||
url.match(/rutube\.ru/i) || url.match(/rutube\.ru/i) ||
url.match(/ok\.ru/i) || url.match(/ok\.ru/i) ||
url.match(/streamable/i) || url.match(/streamable/i) ||
url.match(/twitch/i) || url.match(/twitch/i) ||
url.match(/evideoEmbed/i) || url.match(/evideoEmbed/i) ||
url.match(/videoEmbed/i) || url.match(/videoEmbed/i) ||
url.match(/videoEmbeded/i)) { url.match(/videoEmbeded/i)) {
return true; return true;
} }
} }
@ -2324,7 +2329,7 @@ function changeVideoStatus(videos_id, status) {
modal.showPleaseWait(); modal.showPleaseWait();
$.ajax({ $.ajax({
url: webSiteRootURL + 'objects/videoStatus.json.php', url: webSiteRootURL + 'objects/videoStatus.json.php',
data: {"id": [videos_id], "status": status}, data: { "id": [videos_id], "status": status },
type: 'post', type: 'post',
success: function (response) { success: function (response) {
modal.hidePleaseWait(); modal.hidePleaseWait();
@ -2450,65 +2455,65 @@ function downloadURL(url, filename) {
var loaded = 0; var loaded = 0;
var contentLength = 0; var contentLength = 0;
fetch(url) fetch(url)
.then(response => { .then(response => {
avideoToastSuccess('Download Start'); avideoToastSuccess('Download Start');
const contentEncoding = response.headers.get('content-encoding'); const contentEncoding = response.headers.get('content-encoding');
const contentLength = response.headers.get(contentEncoding ? 'x-file-size' : 'content-length'); const contentLength = response.headers.get(contentEncoding ? 'x-file-size' : 'content-length');
if (contentLength === null) { if (contentLength === null) {
throw Error('Response size header unavailable'); throw Error('Response size header unavailable');
} }
const total = parseInt(contentLength, 10); const total = parseInt(contentLength, 10);
let loaded = 0; let loaded = 0;
return new Response( return new Response(
new ReadableStream({ new ReadableStream({
start(controller) { start(controller) {
const reader = response.body.getReader(); const reader = response.body.getReader();
read(); read();
function read() { function read() {
reader.read().then(({ done, value }) => { reader.read().then(({ done, value }) => {
if (done) { if (done) {
controller.close(); controller.close();
return; return;
}
loaded += value.byteLength;
var percentageLoaded = Math.round(loaded / total * 100);
////console.log(percentageLoaded);
downloadModal.setProgress(percentageLoaded);
downloadModal.setText('Downloading ... ' + percentageLoaded + '%');
controller.enqueue(value);
read();
}).catch(error => {
console.error(error);
controller.error(error)
})
} }
} loaded += value.byteLength;
}) var percentageLoaded = Math.round(loaded / total * 100);
); ////console.log(percentageLoaded);
}) downloadModal.setProgress(percentageLoaded);
.then(response => response.blob()) downloadModal.setText('Downloading ... ' + percentageLoaded + '%');
.then(blob => { controller.enqueue(value);
const urlFromBlob = window.URL.createObjectURL(blob); read();
console.log('downloadURL', url, filename, blob); }).catch(error => {
const a = document.createElement('a'); console.error(error);
a.style.display = 'none'; controller.error(error)
a.href = urlFromBlob; })
// the filename you want }
a.download = filename; }
document.body.appendChild(a); })
a.click(); );
window.URL.revokeObjectURL(url); })
downloadModal.hidePleaseWait(); .then(response => response.blob())
avideoToastSuccess('Download complete ' + filename); .then(blob => {
}) const urlFromBlob = window.URL.createObjectURL(blob);
.catch(function (err) { console.log('downloadURL', url, filename, blob);
//avideoAlertError('Error on download '); const a = document.createElement('a');
console.log(err); a.style.display = 'none';
addQueryStringParameter(url, 'download', 1); a.href = urlFromBlob;
addQueryStringParameter(url, 'title', filename); // the filename you want
document.location = url; a.download = filename;
}); document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
downloadModal.hidePleaseWait();
avideoToastSuccess('Download complete ' + filename);
})
.catch(function (err) {
//avideoAlertError('Error on download ');
console.log(err);
addQueryStringParameter(url, 'download', 1);
addQueryStringParameter(url, 'title', filename);
document.location = url;
});
} }
var downloadURLOrAlertErrorInterval; var downloadURLOrAlertErrorInterval;
@ -2536,9 +2541,9 @@ function downloadURLOrAlertError(jsonURL, data, filename, FFMpegProgress) {
avideoAlertInfo(response.msg); avideoAlertInfo(response.msg);
} }
if ( if (
isMobile() isMobile()
//|| /cdn.ypt.me/.test(response.url) //|| /cdn.ypt.me/.test(response.url)
) { ) {
console.log('downloadURLOrAlertError 2', response.url); console.log('downloadURLOrAlertError 2', response.url);
window.open(response.url, '_blank'); window.open(response.url, '_blank');
avideoToastInfo('Opening file'); avideoToastInfo('Opening file');
@ -2732,7 +2737,7 @@ function getCursorPos(input) {
len++; len++;
} }
rng.setEndPoint("StartToStart", input.createTextRange()); rng.setEndPoint("StartToStart", input.createTextRange());
for (var pos = {start: 0, end: len}; rng.compareEndPoints("EndToStart", rng) > 0; rng.moveEnd("character", -1)) { for (var pos = { start: 0, end: len }; rng.compareEndPoints("EndToStart", rng) > 0; rng.moveEnd("character", -1)) {
pos.start++; pos.start++;
pos.end++; pos.end++;
} }
@ -2775,10 +2780,10 @@ function addAtMention(selector) {
$(selector).on("keydown", function (event) { $(selector).on("keydown", function (event) {
if (!$(this).autocomplete("instance").menu.active) { if (!$(this).autocomplete("instance").menu.active) {
if ( if (
event.keyCode === SpaceKeyCode || event.keyCode === SpaceKeyCode ||
event.keyCode === $.ui.keyCode.TAB || event.keyCode === $.ui.keyCode.TAB ||
event.keyCode === $.ui.keyCode.ENTER || event.keyCode === $.ui.keyCode.ENTER ||
event.keyCode === $.ui.keyCode.ESCAPE) { event.keyCode === $.ui.keyCode.ESCAPE) {
$(this).autocomplete("close"); $(this).autocomplete("close");
} }
} else { } else {
@ -2787,77 +2792,77 @@ function addAtMention(selector) {
} }
} }
}) })
.autocomplete({ .autocomplete({
minLength: 2, minLength: 2,
source: function (request, response) { source: function (request, response) {
var pos = getCursorPos($(selector)[0]); var pos = getCursorPos($(selector)[0]);
stringStart = request.term.substring(0, pos.end); stringStart = request.term.substring(0, pos.end);
var term = stringStart.split(/\s+/).pop(); var term = stringStart.split(/\s+/).pop();
//console.log('autocomplete', request.term, term, AtMatcher.test(term)); //console.log('autocomplete', request.term, term, AtMatcher.test(term));
if (AtMatcher.test(term)) { if (AtMatcher.test(term)) {
$.ajax({ $.ajax({
url: webSiteRootURL + "objects/mention.json.php", url: webSiteRootURL + "objects/mention.json.php",
data: { data: {
term: term term: term
}, },
success: function (data) { success: function (data) {
response(data); response(data);
} }
}); });
} else { } else {
return false;
}
},
focus: function () {
// prevent value inserted on focus
return false; return false;
}, }
select: function (event, ui) { },
addAtMentionActive = true; focus: function () {
// prevent value inserted on focus
return false;
},
select: function (event, ui) {
addAtMentionActive = true;
setTimeout(function () {
addAtMentionActive = false;
}, 200);
if (emojioneArea) {
this.value = $(emojioneArea).data("emojioneArea").getText();
}
//console.log('addAtMention', this, this.value);
var pos = getCursorPos($(selector)[0]);
stringStart = this.value.substring(0, pos.end);
stringEnd = this.value.substring(pos.end);
var terms = stringStart.split(/\s+/);
// remove the current input
var word = terms.pop();
// add the selected item
//terms.push('@' + ui.item.value);
// add placeholder to get the comma-and-space at the end
//terms.push("");
replace = '@' + ui.item.value;
this.value = replaceLast(word, '@' + ui.item.value, stringStart) + stringEnd;
if (emojioneArea) {
$(emojioneArea).data("emojioneArea").setText(this.value);
setTimeout(function () { setTimeout(function () {
addAtMentionActive = false; contentEditableElement = document.getElementsByClassName("emojionearea-editor")[0];
}, 200); range = document.createRange();//Create a range (a range is a like the selection but invisible)
if (emojioneArea) { range.selectNodeContents(contentEditableElement);//Select the entire contents of the element with the range
this.value = $(emojioneArea).data("emojioneArea").getText(); range.collapse(false);//collapse the range to the end point. false means collapse to end rather than the start
} selection = window.getSelection();//get the selection object (allows you to change selection)
//console.log('addAtMention', this, this.value); selection.removeAllRanges();//remove any selections already made
var pos = getCursorPos($(selector)[0]); selection.addRange(range);//make the range you have just created the visible selection
stringStart = this.value.substring(0, pos.end); }, 50);
stringEnd = this.value.substring(pos.end); }
return false;
var terms = stringStart.split(/\s+/); },
// remove the current input create: function () {
var word = terms.pop(); $(this).data('ui-autocomplete')._renderItem = function (ul, item) {
// add the selected item return $('<li>' + item.label + '</li>').appendTo(ul); // customize your HTML
//terms.push('@' + ui.item.value); };
// add placeholder to get the comma-and-space at the end },
//terms.push(""); position: { collision: "flip" }
replace = '@' + ui.item.value; });
this.value = replaceLast(word, '@' + ui.item.value, stringStart) + stringEnd;
if (emojioneArea) {
$(emojioneArea).data("emojioneArea").setText(this.value);
setTimeout(function () {
contentEditableElement = document.getElementsByClassName("emojionearea-editor")[0];
range = document.createRange();//Create a range (a range is a like the selection but invisible)
range.selectNodeContents(contentEditableElement);//Select the entire contents of the element with the range
range.collapse(false);//collapse the range to the end point. false means collapse to end rather than the start
selection = window.getSelection();//get the selection object (allows you to change selection)
selection.removeAllRanges();//remove any selections already made
selection.addRange(range);//make the range you have just created the visible selection
}, 50);
}
return false;
},
create: function () {
$(this).data('ui-autocomplete')._renderItem = function (ul, item) {
return $('<li>' + item.label + '</li>').appendTo(ul); // customize your HTML
};
},
position: {collision: "flip"}
});
} }
/* /*
async function selectAElements() { async function selectAElements() {
@ -3085,7 +3090,7 @@ function cleanHTML(str, nodes) {
// Loop through each attribute // Loop through each attribute
// If it's dangerous, remove it // If it's dangerous, remove it
let atts = elem.attributes; let atts = elem.attributes;
for (let {name, value} of atts) { for (let { name, value } of atts) {
if (!isPossiblyDangerous(name, value)) if (!isPossiblyDangerous(name, value))
continue; continue;
elem.removeAttribute(name); elem.removeAttribute(name);
@ -3206,8 +3211,8 @@ function fixAdSize() {
if (ad_container.length) { if (ad_container.length) {
height = ad_container.css('height'); height = ad_container.css('height');
width = ad_container.css('width'); width = ad_container.css('width');
$($('#mainVideo_ima-ad-container div:first-child')[0]).css({'height': height}); $($('#mainVideo_ima-ad-container div:first-child')[0]).css({ 'height': height });
$($('#mainVideo_ima-ad-container div:first-child')[0]).css({'width': width}); $($('#mainVideo_ima-ad-container div:first-child')[0]).css({ 'width': width });
} }
} }
@ -3492,7 +3497,7 @@ function passStrengthCheck(selector) {
} else { } else {
strengthMsg.push('Special chars'); strengthMsg.push('Special chars');
} }
return {strength: strength, strengthMsg: strengthMsg}; return { strength: strength, strengthMsg: strengthMsg };
} }
function passStrengthCheckInput(selector) { function passStrengthCheckInput(selector) {
@ -3637,7 +3642,7 @@ async function setVideoSuggested(videos_id, isSuggested) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
$.ajax({ $.ajax({
url: webSiteRootURL + 'objects/videoSuggest.php', url: webSiteRootURL + 'objects/videoSuggest.php',
data: {"id": videos_id, "isSuggested": isSuggested}, data: { "id": videos_id, "isSuggested": isSuggested },
type: 'post', type: 'post',
success: function (data) { success: function (data) {
modal.hidePleaseWait(); modal.hidePleaseWait();
@ -3869,11 +3874,11 @@ async function sendAVideoMobileMessage(type, value) {
if (typeof window.flutter_inappwebview !== 'undefined') { if (typeof window.flutter_inappwebview !== 'undefined') {
//console.log('sendAVideoMobileMessage flutter_inappwebview', typeof window.flutter_inappwebview, window.flutter_inappwebview); //console.log('sendAVideoMobileMessage flutter_inappwebview', typeof window.flutter_inappwebview, window.flutter_inappwebview);
if (typeof window.flutter_inappwebview.callHandler == 'function') { if (typeof window.flutter_inappwebview.callHandler == 'function') {
response = await window.flutter_inappwebview.callHandler('AVideoMobileLiveStreamer3', {type: type, value: value, instanceIndex: 3}); response = await window.flutter_inappwebview.callHandler('AVideoMobileLiveStreamer3', { type: type, value: value, instanceIndex: 3 });
console.log('sendAVideoMobileMessage test', response); console.log('sendAVideoMobileMessage test', response);
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
var name = 'AVideoMobileLiveStreamer' + i; var name = 'AVideoMobileLiveStreamer' + i;
response = await window.flutter_inappwebview.callHandler(name, {type: type, value: value, instanceIndex: i}); response = await window.flutter_inappwebview.callHandler(name, { type: type, value: value, instanceIndex: i });
if (response !== null) { if (response !== null) {
console.log('sendAVideoMobileMessage executed', name, response, type, value); console.log('sendAVideoMobileMessage executed', name, response, type, value);
break; break;
@ -3889,7 +3894,7 @@ async function sendAVideoMobileMessage(type, value) {
} }
} else { } else {
//window.parent.postMessage({type: type, value: value}, '*'); //window.parent.postMessage({type: type, value: value}, '*');
window.top.postMessage({type: type, value: value}, '*'); window.top.postMessage({ type: type, value: value }, '*');
} }
} }
window.addEventListener("flutterInAppWebViewPlatformReady", function (event) { window.addEventListener("flutterInAppWebViewPlatformReady", function (event) {