123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694 |
- <html>
- <head>
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
- <link rel="stylesheet" href="../script/semantic/semantic.css">
- <script src="jquery.min.js"></script>
- <script src="../script/semantic/semantic.js"></script>
- <script src="../script/ao_module.js"></script>
- <title>FFmpeg Factory</title>
- <style>
- .FFmpegStatus{
- padding:8px;
- border-bottom:1px solid #999999;
- }
- body{
- padding-top:0px !important;
- background-color:white;
- overflow:hidden;
- }
- @supports (backdrop-filter: none) {
- body {
- background: rgba(255, 255, 255, 0.9);
- backdrop-filter: blur(8px);
- }
- }
- .topMenu{
- padding-top:0px !important;
- border-bottom: 1px solid #999999;
- height: 40px;
- overflow-x: auto;
- overflow-y: hidden;
- }
- .selectableMenuItems{
- padding: 8px;
- display:inline-block !important;
- cursor:pointer;
- border-bottom:2px solid transparent;
- }
- .selectableMenuItems.enabled:hover{
- background-color:#f0f0f0;
- }
- .convertionList{
- width:100%;
- height: 100%;
- padding-left:8px;
- border-right: 1px solid #cfcfcf;
- overflow-y:auto;
- }
- .selectable{
- cursor:pointer;
- padding-left: 22px !important;
- border:1px solid transparent;
- }
-
- .selectable.item{
- padding:8x !important;
- }
- .selectable:hover{
- background-color:#f0f0f0;
- }
- .content{
- overflow-y: auto;
- }
- .filelist{
- padding: 12px !important;
- padding-bottom:0px !important;
- margin-right:20px;
- border: 1px solid transparent !important;
- cursor: pointer;
- }
- .filelist:hover{
- background-color:#f0fbff;
- border:1px solid #48b8e5 !important;
- }
- .selectedFile{
- background-color:#e0f7ff;
- border:1px solid #48b8e5 !important;
- }
- .selectedConvertTarget{
- background-color:#f0f0f0;
- border:1px solid #999999 !important;
- }
- .status{
- display:inline;
- }
- .selectableMenuItems.disabled{
- color: #a3a3a3;
- cursor: not-allowed !important;
- }
- .converting{
- background-color:#d3e4ff;
- }
- .done{
- background-color:#d1ffd3;
- }
- .failed{
- background-color: #ffd1d1;
- }
- #settingMenu{
- position:fixed;
- left:30px;
- right:30px;
- top:30px;
- max-height:80%;
- }
- .mainArea{
- margin-top:0px !important;
- }
- .ts.progress{
- margin-bottom:18px !important;
- }
- .ts.blue.progress .bar{
- background-color: #2185d0 !important;
- }
- #convertPendingList{
- overflow-y: scroll;
- }
- </style>
- </head>
- <body>
- <div id="headerNav" class="ui secondary attached mini menu">
- <a class="item" href="../"><i class="caret left icon"></i></a>
- <div class="item">
- <img class="ui avatar image" src="./img/small_icon.png">
- <span>FFmpeg Factory</span>
- </div>
- </div>
- <div class="topMenu">
- <div id="addFileBtn" class="selectableMenuItems enabled" onClick="openFileSelection(this);"><i class="plus icon"></i>Add Files</div>
- <div class="selectableMenuItems enabled" onClick="openFileLocation(this);"><i class="folder open icon"></i>Browse File Location</div>
- <div class="selectableMenuItems enabled" onClick="startQueue(this);"><i class="play icon"></i>Start Queue</div>
- <div class="selectableMenuItems enabled" onClick="stopQueue(this);"><i class="stop icon"></i>Stop Queue</div>
- <!-- <div class="selectableMenuItems enabled" onClick="viewCommand(this);"><i class="code icon"></i>View Command</div> -->
- <div class="selectableMenuItems enabled" onClick="showSettingMenu(this);"><i class="setting icon"></i>Settings</div>
- </div>
- <div class="ui stackable grid mainArea">
- <div class="four wide column sidebar">
- <div class="convertionList" >
-
- <div class="ui fluid accordion">
- <div class="title">
- <i class="dropdown icon"></i>
- <i class="play icon"></i>
- Video
- </div>
- <div class="content fileFormatSelector">
- <div id="v2v" class="ui relaxed divided list">
- </div>
- </div>
-
- <div class="title">
- <i class="dropdown icon"></i>
- <i class="music icon"></i>
- Music
- </div>
- <div class="content fileFormatSelector">
- <div id="v2a" class="ui relaxed divided list">
- </div>
- </div>
-
- <div class="title">
- <i class="dropdown icon"></i>
- <i class="file image icon"></i>
- Pictures
- </div>
- <div class="content fileFormatSelector">
- <div id="i2i" class="ui relaxed divided list">
- </div>
- </div>
-
- <div class="title">
- <i class="dropdown icon"></i>
- <i class="exchange icon"></i>
- Others
- </div>
- <div class="content fileFormatSelector">
- <div id="other" class="ui relaxed divided list">
- </div>
- </div>
- </div>
- <br>
- </div>
- </div>
- <div class="twelve wide column" ondrop="drop(event)" ondragover="allowdrag(event)" style="padding-right:22px;">
- <div id="actionOK" class="ui positive message transition" style="display:none;">
- <div class="header">
- You are eligible for a reward
- </div>
- <p class="message"></p>
- </div>
- <div id="emptylist" class="ui secondary blue segment">
- <i class="hashtag icon"></i> No Pending Tasks. Press the <i class="add icon"></i> button to add new conversion tasks.
- </div>
- <div id="convertPendingList" class="ui relaxed divided list" style="margin-top:0px !important;">
- </div>
- <div id="askSelectDimmer" class="ui dimmer" style="margin-top:14px; margin-left:-14px;">
- <div class="content">
- <h4 class="ui inverted icon header">
- <i class="arrow left icon"></i>
- Select a Target Conversion Format <br>
- On the list over there
- </h4>
- </div>
- </div>
-
-
- </div>
-
- </div>
- <div id="settingDimmer" class="ui dimmer"></div>
- <div id="settingMenu" style="z-index:1001;">
- <div class="ui raised segment">
- <div class="ui header">
- <i class="setting icon"></i>Conversion Settings
- <div class="sub header">Please adjust the following settings according to your Host devices specification.</div>
- </div>
- <div class="ui list">
- <div class="item"><i class="caret right icon"></i>Simultaneous Conversion File Counts</div>
- <div class="item">
- <select id="simFileCount" class="ui basic tiny dropdown" onChange="updateSimFiles(this);">
- <option>1</option>
- <option>2</option>
- <option>3</option>
- <option>4</option>
- <option>8</option>
- <option>16</option>
- </select>
- </div>
- <div class="item" style="font-size: 90%;"><small>Do not use "ALL" options unless your host is a dual CPU Xeon Server</small></div>
- <div class="item"><i class="caret right icon"></i>Allow Codec Copy Options (FFmpeg Expert Only)</div>
- <div class="item" onChange="">
- <select id="allowCodecCopy" class="ui basic tiny dropdown" onChange="updateAllowCodecCopy(this);">
- <option>false</option>
- <option>true</option>
- </select>
- </div>
- <div class="item" style="font-size: 90%;"><small>Codec Copy Error might crash the system. Please use with your own risk.</small></div>
- </div>
- <br><br>
- <ins><i class="save icon"></i>All changes will be saved automatically in server database.</ins>
- <br> <br>
- <button class="ui blue button" onClick="hideSettingMenu();">Close</button>
- </div>
-
- </div>
- <br><br><br><br>
- <script>
- //Global variables
- var convertPendingFiles = []; //Files pending to be converted
- var selectFormatPending = false; //Files selected and waiting to select a target format
- var targetConversionFormat = ""; //The target conversion format
- var selectedCommand = ""; //The target selected command template
- var selectedMediaType = "";
- //Conversion related settings
- var simFileCount = 1;
- var allowCodecCopy = false;
- var queueStarted = false;
-
- isMobile = function() {
- let check = false;
- (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
- return check;
- };
- if (ao_module_virtualDesktop){
- $("#headerNav").hide();
- }
- $(document).ready(function(){
- //Check if mobile. If yes, change the UI to responsive
- if (isMobile()){
- //Create a sidebar button
- $(".topMenu").prepend(`
- <div title="Toggle Sidebar" class="ui icon button" onclick="toggleSidebar(); "><i class="content icon" style="pointer-events: none;" ></i></div>
- `);
- //Hide the sidebar
- $(".sidebar").hide();
- //Simplify the toolbar
- $(".selectableMenuItems").each(function(){
- var originalText = $(this).text();
- console.log(originalText);
- $(this).html($(this).html().replace(originalText, ""));
- $(this).attr("title", originalText);
- $(this).attr("class", "ui basic icon button")
- $(this).css({
- "padding-top": "12px"
- });
- });
- }
- $("#settingMenu").hide();
- $('.ui.dropdown').dropdown();
- //Initialize the conversion types
- //<div class="item selectable"><i class="file video outline icon"></i></div>
- $.ajax({
- url: "config/v2v.json",
- method: "GET",
- dataType: "json",
- success: function(data){
- for (var [key, value] of Object.entries(data)) {
- value = encodeURIComponent(value);
- $("#v2v").append(`<div class="item selectable" mediatype="video" conv="${key}" command="${value}" onclick="selectThis(this, event);" ondblclick="selectViaFormat(this);"><i class="file video outline icon"></i> ${key}</div>`);
- }
- $('.ui.accordion').accordion();
- initUserSettings();
- }
- });
- $.ajax({
- url: "config/v2a.json",
- method: "GET",
- dataType: "json",
- success: function(data){
- for (var [key, value] of Object.entries(data)) {
- value = encodeURIComponent(value);
- $("#v2a").append(`<div class="item selectable" mediatype="music" conv="${key}" command="${value}" onclick="selectThis(this, event);" ondblclick="selectViaFormat(this);"><i class="file video outline icon"></i> ${key}</div>`);
- }
- $('.ui.accordion').accordion();
- initUserSettings();
- }
- });
- $.ajax({
- url: "config/i2i.json",
- method: "GET",
- dataType: "json",
- success: function(data){
- for (var [key, value] of Object.entries(data)) {
- value = encodeURIComponent(value);
- $("#i2i").append(`<div class="item selectable" mediatype="image" conv="${key}" command="${value}" onclick="selectThis(this, event);" ondblclick="selectViaFormat(this);"><i class="file video outline icon"></i> ${key}</div>`);
- }
- $('.ui.accordion').accordion();
- }
- });
- $.ajax({
- url: "config/other.json",
- method: "GET",
- dataType: "json",
- success: function(data){
- for (var [key, value] of Object.entries(data)) {
- value = encodeURIComponent(value);
- $("#other").append(`<div class="item selectable" mediatype="other" conv="${key}" command="${value}" onclick="selectThis(this, event);" ondblclick="selectViaFormat(this);"><i class="file video outline icon"></i> ${key}</div>`);
- }
- $('.ui.accordion').accordion();
- }
- });
- });
- //Open files to convert
- function openFileSelection(obj){
- if ($(obj).hasClass("disabled") == false){
- //Require format selection after select
- selectFormatPending = true;
- ao_module_openFileSelector(fileSelected, "user:/Desktop", "file",true);
- }
-
- }
- function toggleSidebar(){
- $(".sidebar").toggle();
- }
- //Catch drop events on ths main area
- function drop(event){
- event.preventDefault();
- var files = ao_module_utils.getDropFileInfo(event);
- if(files.length == 0){
- return;
- }
- selectFormatPending = true;
- fileSelected(files);
- }
- function allowdrag(ev) {
- ev.preventDefault();
- return true;
- }
- //Update the number of simultanous file conversion
- function updateSimFiles(obj){
- var fileNumber = obj.value;
- saveStorage("simconv",fileNumber);
- simFileCount = fileNumber;
- }
- function updateAllowCodecCopy(obj){
- var newValue = obj.value;
- allowCodecCopy = (newValue == "true");
- saveStorage("codecCopy",newValue);
- updateCodeCopyDisableList();
- }
- function initUserSettings(){
- readStorage("simconv", function(data){
- if (data != ""){
- simFileCount = parseInt(data);
- $('#simFileCount').dropdown('set selected', data);
- }
- });
- readStorage("codecCopy", function(data){
- if (data != ""){
- allowCodecCopy = (data == "true");
- $('#allowCodecCopy').dropdown('set selected', data);
- }
- updateCodeCopyDisableList();
- });
- }
- function updateCodeCopyDisableList(){
- //console.log(allowCodecCopy);
- if (allowCodecCopy == false){
- $(".item.selectable").each(function(){
- if ($(this).text().includes("codec copy")){
- $(this).addClass("disabled");
- }
- });
- }else{
- $(".item.selectable.disabled").each(function(){
- $(this).removeClass("disabled");
- });
- }
- }
- function saveStorage(key, value, callback = undefined){
- ao_module_agirun("FFmpeg Factory/backend/writeConfig.js", {
- key: key,
- value: value
- }, callback)
- }
- function readStorage(key, callback = undefined){
- ao_module_agirun("FFmpeg Factory/backend/readConfig.js", {key: key}, callback)
- }
- function selectThisTask(obj){
- $(".selectedFile").removeClass("selectedFile");
- $(obj).addClass("selectedFile")
- }
- //File selected using openFileSelected
- function fileSelected(data){
- convertPendingFiles = data;
- if (selectFormatPending == true){
- //Format not yet selected. Ask user to choose a target format
- $("#askSelectDimmer").addClass('active');
- $(".selectableMenuItems").addClass("disabled")
- if (isMobile()){
- $(".sidebar").show();
- }
- }else{
- //format alraedy selected. Append to conversion list
- for (var i =0; i < data.length; i++){
- var thisFile = convertPendingFiles[i];
- addTaskToList(thisFile.filename, thisFile.filepath, targetConversionFormat, selectedCommand, selectedMediaType);
- }
- targetConversionFormat="";
- selectedCommand="";
- selectedMediaType="";
- }
-
- }
- function showSettingMenu(){
- $("#settingDimmer").addClass("active");
- $("#settingMenu").transition('scale');
- }
- function hideSettingMenu(){
- $("#settingDimmer").removeClass("active");
- $("#settingMenu").transition('scale');
- }
- //Remove task from the task list
- function removeTask(obj){
- var taskObject = $(obj).parent().parent().parent();
- //msgbox("Task Removed", $(taskObject).attr("filepath"));
- $(taskObject).remove();
- //Check if there are anything left. If no, add a message
- if ($(".filelist.item").length == 0){
- $("#emptylist").show();
- }
- }
- function msgbox(title, message){
- $("#actionOK").stop().finish().slideDown("fast").delay(3000).slideUp("fast");
- $("#actionOK").find(".header").text(title);
- $("#actionOK").find(".message").text(message);
- }
- function addTaskToList(filename, filepath, targetFormat, command, mtype){
- $("#emptylist").hide();
- //Get the file extension of the filename
- var srcFormat = filename.split(".").pop();
- srcFormat = srcFormat.toUpperCase();
- console.log(filename, filepath, targetFormat, command, mtype);
- $("#convertPendingList").append(`<div class="item filelist ready" mtype="${mtype}" filepath="${filepath}" command="${command}" onclick="selectThisTask(this);">
- <i class="large file outline middle aligned icon"></i>
- <div class="content">
- <div class="header">${filename} [${srcFormat} <i class="right arrow icon"></i>${targetFormat}]</div>
- <div class="description" style="margin-top:8px;"><a onclick="startTask(this, event);" class="startTaskButton"><i class="exchange icon"></i> Start Convert</a> / <a onclick="removeTask(this);"><i class="trash icon"></i> Remove</a>
- </div>
- </div>
- <div class="ui black active tiny progress" style="margin-top:8px;">
- <div class="bar" style="width:0%; min-width:0px;"></div>
- </div>
- </div>`);
- }
- function selectViaFormat(obj){
- targetConversionFormat = $(obj).attr("conv");
- selectedCommand = $(obj).attr("command");
- selectedMediaType = $(obj).attr("mediatype");
- ao_module_openFileSelector(fileSelected, "user:/Desktop", "file",true);
- }
- function selectThis(obj){
- //A format has been selected
- if (selectFormatPending){
- //Unset the blocking
- $("#askSelectDimmer").removeClass('active');
- $(".selectableMenuItems").removeClass("disabled")
- //Hide the sidebar if on mobile mode
- if (isMobile()){
- $('.sidebar').hide();
- }
- //Get the target format and command
- var format = $(obj).attr("conv");
- var command = $(obj).attr("command");
- var mtype = $(obj).attr("mediatype");
- //Append the files item to list
- for (var i =0; i < convertPendingFiles.length; i++){
- var thisFile = convertPendingFiles[i];
- addTaskToList(thisFile.filename, thisFile.filepath, format, command, mtype);
- }
- selectFormatPending = false;
- }
- }
- function openFileLocation(){
- if ($(".selectedFile").length > 0){
- var filepath = $(".selectedFile").attr("filepath");
- filepath = filepath.split("/");
- filepath.pop();
- filepath = filepath.join("/")
- ao_module_openPath(filepath);
- }
- }
- //Handle window resize events
- resizeWindowEvents()
- $(window).on("resize",function(){
- resizeWindowEvents();
- })
- function resizeWindowEvents(){
- $(".sidebar").css("height",window.innerHeight - $(".topMenu").height());
- $("#convertPendingList").css("height", window.innerHeight - 60);
- }
- //Bind the queue listening events
- setInterval(function(){
- if (queueStarted){
- //Check next queue
- if (isNaN(simFileCount)){
- simFileCount = 1;
- }
- if ($(".filelist.converting").length < simFileCount){
- //Convert next item
- console.log("Next Object")
- if ($(".filelist.ready").length > 0){
- $($(".filelist.ready")[0]).find(".startTaskButton")[0].click();
- }else{
- //Conversion finished
- console.log("Conversion finished");
- queueStarted = false;
- }
- }
- }
- }, 1000);
- function startQueue(){
- //Start the queue with the given task number on the fly
- queueStarted = true;
- }
- function stopQueue(){
- queueStarted = false;
- }
- function startTask(taskObject, event){
- event.preventDefault();
- event.stopImmediatePropagation();
- //Travel back to the task object itself
- taskObject = $(taskObject).parent().parent().parent();
-
- //Try to validate conversion type
- var mediaType = {
- "music": ["m4a","flac","mp3","wav","ogg","aac","wma"],
- "video": ["mp4","avi","webm","mkv","wmv","mov","m4v","rmvb"],
- "image": ["png","jpg","jpeg","gif","tif","tiff"]
- }
- var srcExt = $(taskObject).attr("filepath").split(".").pop();
- var targetType = $(taskObject).attr("mtype");
- var srcType = "unknown";
- //Check which type of media is src
- if (mediaType["music"].includes(srcExt)){
- srcType = "music";
- }else if (mediaType["video"].includes(srcExt)){
- srcType = "video";
- }else if (mediaType["image"].includes(srcExt)){
- srcType = "image";
- }
- //Allow video -> (video or audio), music -> music and image -> image
- var requireConversionConfirm = true;
- if (srcType == "video" && targetType == "video"){
- requireConversionConfirm = false
- }else if (srcType == "video" && targetType == "music"){
- requireConversionConfirm = false
- }else if (srcType == "music" && targetType == "music"){
- requireConversionConfirm = false
- }else if (srcType == "image" && targetType == "image"){
- requireConversionConfirm = false
- }else if (targetType == "other"){
- //Just trust the user, they know what they are doing
- requireConversionConfirm = false
- }
- if (requireConversionConfirm){
- if (!confirm("We are not sure if the conversion media type is valid. Continue anyway?")){
- return
- }
- }
- //OK! Convert this file
- var filepath = $(taskObject).attr("filepath");
- var command = $(taskObject).attr("command");
- //Update the progress bar
- $(taskObject).find(".tiny.progress").attr("class","ui blue queried indeterminate tiny progress");
- $(taskObject).find(".bar").css("width","100%");
- $(taskObject).removeClass("ready").addClass("converting");
- //Hide the control buttons
- $(taskObject).find(".description").html("<span><i class='loading spinner icon'></i> Converting...</span>");
- ao_module_agirun("FFmpeg Factory/backend/convert.js",{
- filepath: filepath,
- command: command
- },function(data){
- if (data.error !== undefined){
- //Conversion failed
- console.log(data.error);
- $(taskObject).find(".tiny.progress").attr("class","ui red tiny progress");
- $(taskObject).find(".bar").css("width","100%");
- $(taskObject).removeClass("converting").addClass("failed");
- $(taskObject).find(".description").html(`<span><i class='remove icon'></i> ${data.error}</span> / <a onclick="removeTask(this);"><i class="trash icon"></i> Remove From List</a>`);
- }else{
- $(taskObject).find(".tiny.progress").attr("class","ui green tiny progress");
- $(taskObject).find(".bar").css("width","100%");
- $(taskObject).removeClass("converting").addClass("done");
- $(taskObject).find(".description").html(`<span><i class='checkmark icon'></i> Completed</span>`);
- }
- $(taskObject).find(".description").html('<a onclick="removeTask(this);"><i class="checkmark icon"></i> Close</a>');
- }, function(){
- //Failed callback
- $(taskObject).find(".tiny.progress").attr("class","ui red tiny progress");
- $(taskObject).find(".bar").css("width","100%");
- $(taskObject).removeClass("converting").addClass("failed");
- $(taskObject).find(".description").html(`<a onclick="removeTask(this);"><i class="remove icon"></i> Remove</a>`);
- });
- }
- </script>
- </body>
- </html>
|