/
DenUlupov
/
GSMnew
Обзор
Документация
Войти
/
DenUlupov
/
GSMnew
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
SelectVideo.php
257 строк
10 KB
DenUlupov
upload_1
26 июн 2025, 11:35
26 июн 2025, 11:35
03aee7b
Код
Авторство
О чём код?
<!DOCTYPE html> <html lang="ru"> <head> <script type="text/javascript" src="modules/jquery-3.7.1.min.js"></script> <script src="modules/config.js"></script> <link rel="stylesheet" href="css/SelectVideo.css"> <META NAME="description" CONTENT="Внутренний портал ОАО Институт Гипростроймост"> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <base target="_parent"> <title>Новости</title> <style type="text/css"> @font-face { font-family: 'CenturyGothic'; src: url('fonts/gothic.eot'); src: url('fonts/gothic.eot?#iefix') format('embedded-opentype'), url('fonts/gothic.woff') format('woff'), url('fonts/gothic.ttf') format('truetype'), url('fonts/gothic.svg#gothic') format('svg'); font-weight: normal; font-style: normal; } </style> </head> <body> <div class="mySel"> <div class="labName">Видеофайл:</div> <div class="wrapName"> <div class="txtName"> <input id="txtNameSh" type="text" class="pole_name" readonly="readonly" value="<?php echo $_GET["src"] ?>"/> <input id="txtNameFull" type="text" class="txtNameFull" value="<?php echo $_GET["src"] ?>"/> </div> <div id="butChName"> <input type="file" id="butSelFile" accept=".mp4" class="inputfile noselect"> <label for="butSelFile" class=" noselect"><img src="img/image_24.png">выбрать файл</label> </div> </div> <div class="labName">Постер:</div> <div class="wrapName"> <div class="txtName"> <input id="txtNameSh2" type="text" class="pole_name" value="<?php echo $_GET["poster"] ?>"/> <input id="txtNameFull2" type="text" class="txtNameFull" value="<?php echo $_GET["poster"] ?>"/> </div> <div id="butChName"> <input type="file" id="butSelFilePost" accept="image/*" class="inputfile noselect"> <label for="butSelFilePost" class=" noselect"><img src="img/image_24.png">выбрать файл</label> </div> </div> <div class="labAlt">Описание:</div> <div class="txtAlt" title="Альтернативный текст"><input id="txtAlt" type="text" class="pole_name" value="<?php echo $_GET["title"] ?>"/></div> <div class="dimensions"> <div class="width_wrap"> <div class="labWidth">Ширина:</div> <div class="txtWidth"> <input id="txtWidth" type="text" class="pole_name" value="<?php echo $_GET["width"] ?>" title="Рекомендуемая ширина - 750px"/> </div> </div> </div> <div class="dopNastr"> <input type="checkbox" id="rec_width" name="rec_width" value="1" checked> <label for="rec_width">рекомендуемая ширина - 600 px</label> </div> </div> <?php $dirPath = "'" .htmlspecialchars($_GET["path"]) . "'"; ?> <script> // это обработчик событий! // перехватываем событие insertMyData: передаем в Тини содержимое полей и запускаем iFrameCommand //все команды описаны в плагине imageuploader (папка tinymce/plugins/imageuploader/plugin.min.js) var myPath = <?php echo $dirPath ?>; var tekWidth = $('#txtWidth').val(); var tekHeight = <?php echo $_GET["height"] ?>; var maxVidWidth = 600; var newWidth = 0; var newHeight = 0; window.addEventListener('message', function (event) { if (event.data.mceAction ==='insertMyVideo'){ var value = { name: document.getElementById('txtNameFull').value, poster: document.getElementById('txtNameFull2').value, alt: document.getElementById('txtAlt').value, width: newWidth, height: newHeight }; //console.log('name = ' + document.getElementById('txtNameFull').value); //console.log('poster = ' + document.getElementById('txtNameFull2').value); //console.log('alt = ' + document.getElementById('txtAlt').value); window.parent.postMessage({ mceAction: 'execCommand', cmd: 'iframeCommandVideo', value }, origin); window.parent.postMessage({ mceAction: 'close' }, origin); } //сюда вставить insertMyVideo //insertMyGallery }); //кнопка выбора файла $("#butSelFile").change(function(){ //console.log("tut"); if (window.FormData === undefined) { alert('В вашем браузере FormData не поддерживается') } else { //создадим виртуальную форму var formData = new FormData(); //добавим виртуальное поле file formData.append('file', $("#butSelFile")[0].files[0]); //добавим виртуальное поле directory formData.append('directory', myPath); //добавим виртуальное поле POSTER formData.append('createfolder', "yes"); //во время загрузки пользователь видит это: $('#txtNameSh').val('подождите, идет загрузка...'); $.ajax({ type: "POST", url: uploadURL, cache: false, contentType: false, processData: false, data: formData, dataType : 'json', success: function(msg){ if (msg.error == '') { //$("#js-file").hide(); $('#txtNameFull').val(msg.fullPath); $('#txtNameSh').val(msg.shPath); //$('#txtWidth').val(msg.imWidth); $("#txtWidth").prop('disabled', false); $("#txtAlt").prop('disabled', false); } else if (msg.error == 'video'){ $('#txtNameFull').val(msg.fullPath); $('#txtNameSh').val(msg.shPath); //$('#txtWidth').val(msg.imWidth); $("#txtWidth").prop('disabled', false); $("#txtAlt").prop('disabled', false); } else { $('#txtNameSh').val(msg.error); $("#txtWidth").prop('disabled', true); $("#txtAlt").prop('disabled', true); } } }); } }); //кнопка выбора файла постера $("#butSelFilePost").change(function(){ if (window.FormData === undefined) { alert('В вашем браузере FormData не поддерживается') } else { //создадим виртуальную форму var formData = new FormData(); //добавим виртуальное поле file formData.append('file', $("#butSelFilePost")[0].files[0]); //добавим виртуальное поле directory formData.append('directory', myPath); //добавим виртуальное поле POSTER formData.append('createfolder', "no"); //во время загрузки пользователь видит это: $('#txtNameSh2').val('подождите, идет загрузка...'); $.ajax({ type: "POST", url: uploadURL, cache: false, contentType: false, processData: false, data: formData, dataType : 'json', success: function(msg){ if (msg.error == '') { //$("#js-file").hide(); $('#txtNameFull2').val(msg.fullPath); $('#txtNameSh2').val(msg.shPath); $('#txtWidth').val(msg.imWidth); tekWidth = msg.imWidth; tekHeight = msg.imHeight; newWidth = tekWidth; newHeight =tekHeight; myAutoFit(); } else { $('#txtNameSh2').val(msg.error); } } }); } }); function myAutoFit() { if ($('#rec_width').is(':checked')) { if (tekWidth > maxVidWidth) { $('#txtWidth').val(maxVidWidth); var newHeight = Math.round((maxVidWidth * tekHeight) / tekWidth); newWidth = maxVidWidth; //console.log('width = ' + newWidth + ' height = ' + newHeight); } } } $('#rec_width').change(function() { var c = this.checked; if (c == false) { $('#txtWidth').val(tekWidth); $("#txtWidth").prop('disabled', false); //$('#txtHeight').val(tekHeight); } else { myAutoFit(); $("#txtWidth").prop('disabled', true); } localStorage.setItem('rec_width',c); }); $(document).ready(function() { if (localStorage.getItem('rec_width') !== null) { var ch = localStorage.rec_width; if (ch == 'true') { $('#rec_width').prop('checked', true); $("#txtWidth").prop('disabled', true); } else { $('#rec_width').prop('checked', false); } } }) $('#txtWidth').bind("keyup", function(e) { if(e.keyCode === 27) { rerurnOldVal (); return true; } var newHeight = Math.round((this.value * tekHeight) / tekWidth); newWidth = this.value; //console.log('width = ' + newWidth + ' height = ' + newHeight); }) function rerurnOldVal () { $('#txtWidth').val(tekWidth); } </script> </body> </html>