OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
html
/
inc
Server IP: 10.0.0.4
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
03/15/2024 04:24:02 PM
rwxr-xr-x
📁
PHPMailer
-
03/15/2024 04:06:04 PM
rwxr-xr-x
📄
common.js
29.58 KB
03/15/2024 04:24:02 PM
rw-r--r--
📄
config.php
2.26 KB
03/15/2024 04:28:21 PM
rw-r--r--
📁
fontawesome
-
03/15/2024 04:06:04 PM
rwxr-xr-x
📄
jquery-3.7.1.min.js
85.48 KB
03/15/2024 04:24:02 PM
rw-r--r--
📄
moment.min.js
52.07 KB
03/15/2024 04:24:02 PM
rw-r--r--
📄
style.css
5.02 KB
03/15/2024 04:24:02 PM
rw-r--r--
Editing: common.js
Close
/***************************************************** * Common Javascript functions *****************************************************/ let apiURL = '/process/'; let chkFilterEmail = /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/; var gUser = {}; gUser.type = ''; gUser.login = ''; gUser.firstName = ''; gUser.lastName = ''; gUser.loginAction = ''; function np() { return void(0); } function initHome() { let user = sessionStorage.getItem('user'); if (user == null) { } else { let resData = JSON.parse(user); gUser.type = resData.type; gUser.login = resData.login; gUser.firstName = resData.firstName; gUser.lastName = resData.lastName; $('.txtLoginName').html('Welcome, ' + gUser.firstName + ' ' + gUser.lastName); $('#panelTopDefault').hide(); $('#panelTopLogged_' + gUser.type).show(); } } function initDashboard() { let user = sessionStorage.getItem('user'); if (user == null) { window.location.replace('index.htm'); } else { let resData = JSON.parse(user); gUser.type = resData.type; gUser.login = resData.login; gUser.firstName = resData.firstName; gUser.lastName = resData.lastName; $('.txtLoginName').html('Welcome, ' + gUser.firstName + ' ' + gUser.lastName); $('#panelTopDefault').hide(); $('#panelTopLogged_' + gUser.type).show(); } } function initVerify() { var params = window.location.search; if (params == '') { $('.txtTagSearch').html('There was an error activating your account!'); return false; } else { params = params.replace('?', ''); $.ajax({ url: apiURL + 'verify.php', data: {data: params}, dataType: 'json', error: function (error) { alert('ERROR: There was an error activating your account!'); } }) .done(function(res) { if (res.status == 200) { $('.txtTagSearch').html('Your account has been activated!'); } }); } } function goHome() { $('.contentBox').hide(); $('#contentHome').show(); } function goUploadPaper() { $('#frmUploadPaper').trigger('reset'); $('#contentUpload #panelAuthors').html(''); $('#contentUpload #numAuthors').val('1'); $('.contentBox').hide(); $('#contentUpload').show(); } function goEditPaper(wchPaperId) { $('#contentEdit #panelAuthors').html(''); $('#contentEdit #numAuthors').val('1'); $('.contentBox').hide(); $('#contentLoader').show(); $.ajax({ url: apiURL + 'article.php?id=' + wchPaperId, dataType: 'json' }) .done(function(res) { $('#contentLoader').hide(); if (res.status == 200) { var resData = res.data; $('#contentEdit #uploadPaperId').val(resData.id); $('#contentEdit #uploadCategoryId').val(resData.categoryId); $('#contentEdit #uploadYear').val(resData.yearPublished); $('#contentEdit #uploadTitle').val(resData.title); $('#contentEdit #uploadDOI').val(resData.doi); $('#contentEdit #uploadSummary').val(resData.summary); $('#contentEdit #uploadAuthorId1').val(resData.author[0].id); $('#contentEdit #uploadAuthorSalutation1').val(resData.author[0].salutation); $('#contentEdit #uploadAuthorFirstName1').val(resData.author[0].firstName); $('#contentEdit #uploadAuthorLastName1').val(resData.author[0].lastName); var htmlAuthor = ''; var numAuthors = resData.author.length; if (numAuthors > 1) { for (var i = 2; i <= numAuthors; i++) { let authorId = resData.author[i-1].id; let authorSalutation = resData.author[i-1].salutation; let authorFirstName = resData.author[i-1].firstName; let authorLastName = resData.author[i-1].lastName; htmlAuthor += ' <div class="form-row">'; htmlAuthor += ' <div class="col-md-2 mt-0 pt-0 mt-md-4 pt-md-1">'; htmlAuthor += ' <span class="txtMed badge badge-primary p-2">Author ' + i + '</span>'; htmlAuthor += ' </div>'; htmlAuthor += ' <div class="col-md-2 mb-3">'; htmlAuthor += ' <label for="uploadAuthorSalutation' + i + '">Salutation</label>'; htmlAuthor += ' <select id="uploadAuthorSalutation' + i + '" name="uploadAuthorSalutation' + i + '" class="form-control">'; htmlAuthor += ' <option>Mr.'; if (authorSalutation == 'Ms.') { htmlAuthor += ' <option SELECTED>Ms.'; } else { htmlAuthor += ' <option>Ms.'; } if (authorSalutation == 'Dr.') { htmlAuthor += ' <option SELECTED>Dr.'; } else { htmlAuthor += ' <option>Dr.'; } if (authorSalutation == 'Prof.') { htmlAuthor += ' <option SELECTED>Prof.'; } else { htmlAuthor += ' <option>Prof.'; } htmlAuthor += ' </select>'; htmlAuthor += ' </div>'; htmlAuthor += ' <div class="col-md-4 mb-3">'; htmlAuthor += ' <label for="uploadAuthorFirstName' + i + '">First name</label>'; htmlAuthor += ' <input type="text" class="form-control" id="uploadAuthorFirstName' + i + '" name="uploadAuthorFirstName' + i + '" value="' + authorFirstName + '" maxlength="100" />'; htmlAuthor += ' </div>'; htmlAuthor += ' <div class="col-md-4 mb-3">'; htmlAuthor += ' <label for="uploadAuthorLastName' + i + '">Last name</label>'; htmlAuthor += ' <input type="text" class="form-control" id="uploadAuthorLastName' + i + '" name="uploadAuthorLastName' + i + '" value="' + authorLastName + '" maxlength="100" />'; htmlAuthor += ' </div>'; htmlAuthor += ' <input type="hidden" id="uploadAuthorId' + i + '" name="uploadAuthorId' + i + '" value="' + authorId + '" />'; htmlAuthor += ' </div>'; } $('#contentEdit #panelAuthors').append(htmlAuthor); } $('#contentEdit #numAuthors').val(numAuthors); $('#contentEdit').show(); } else { $('.contentBox').hide(); $('#contentDashboard').show(); alert('ERROR: ' + res.message); } }); } function goCreateAccount() { $('#panelSplash').show(); $('#panelCreateAccount').show(); } function goLogin() { $('#linkHeaderLogin').click(); } function goLogout() { $('.txtLoginName').html(''); $('.panelTopLogged').hide(); $('#panelTopDefault').show(); sessionStorage.removeItem('user'); alert('You have successfully logged out from OPAL'); window.location.replace('index.htm'); } function cancelDashboard() { $('.contentBox').hide(); $('#contentDashboard').show(); } function closeSplash() { $('#panelSplash').hide(); $('.panelAlert').hide(); } function chkLogin() { let loginRole = $('#loginRole').val(); let loginEmail = $('#loginEmail').val(); let loginPwd = $('#loginPwd').val(); if (loginRole == '' || loginEmail == '' || loginPwd == '') { alert('Role, Login and Password are required!'); return false; } $.ajax({ url: apiURL + 'login.php', data: {type: loginRole, login: loginEmail, pwd: loginPwd}, dataType: 'json', method: 'POST', error: function (error) { alert('ERROR: User or Password is incorrect!'); } }) .done(function(res) { if (res.status == 200) { let resData = res.data; gUser.type = resData.type; gUser.login = loginEmail; gUser.firstName = resData.firstName; gUser.lastName = resData.lastName; sessionStorage.setItem('user', JSON.stringify(gUser)); $('.txtLoginName').html('Welcome, ' + gUser.firstName + ' ' + gUser.lastName); $('#panelTopDefault').hide(); $('#panelTopLogged_' + gUser.type).show(); $('#modalLogin').modal('hide'); if (gUser.loginAction != '') { getDownloadFile(gUser.loginAction); gUser.loginAction = ''; } } else { alert('ERROR: ' + res.message); } }); } function getDownloadFile(fileId) { $.ajax({ url: apiURL + 'article.php?id=' + fileId + '&session=' + gUser.session, dataType: 'json' }) .done(function(res) { if (res.status == 200) { window.open('../uploads/pdf/' + res.data.filePdf); } }); } function chkCreateAccount() { let accountSalutation = $('#accountSalutation').val(); let accountFirstName = $('#accountFirstName').val(); let accountLastName = $('#accountLastName').val(); let accountAffiliation = $('#accountAffiliation').val(); let accountCity = $('#accountCity').val(); let accountCountry = $('#accountCountry').val(); let accountEmail = $('#accountEmail').val(); let accountPwd = $('#accountPwd').val(); let accountPwdRetype = $('#accountPwdRetype').val(); if (accountFirstName == '' || accountLastName == '' || accountAffiliation == '' || accountCity == '' || accountCountry == '' || accountEmail == '' || accountPwd == '') { alert('All fields are compulsory to create your account!'); return false; } if (!(chkFilterEmail.test(accountEmail))) { alert('Invalid email address is entered. Please try again!'); return false; } if (accountPwd != accountPwdRetype) { alert('Passwords do not match. Please try again!'); return false; } $.ajax({ url: apiURL + 'register.php', data: {type: 'user', firstName: accountFirstName, lastName: accountLastName, salutation: accountSalutation, email: accountEmail, pwd: accountPwd, affiliation: accountAffiliation, city: accountCity, country: accountCountry}, dataType: 'json', method: 'POST', error: function (error) { alert('ERROR: Could not create account!'); } }) .done(function(res) { if (res.status == 200) { $('#panelCreateAccountForm').hide(); $('.panelCreateAccountButton').hide(); $('#panelCreateAccountMessage').show(); } else { alert('ERROR: ' + res.message); } }); } function chkCreateAccountEditor() { let accountSalutation = $('#accountSalutation').val(); let accountFirstName = $('#accountFirstName').val(); let accountLastName = $('#accountLastName').val(); let accountAffiliation = $('#accountAffiliation').val(); let accountCity = $('#accountCity').val(); let accountCountry = $('#accountCountry').val(); let accountEmail = $('#accountEmail').val(); let accountPwd = $('#accountPwd').val(); let accountPwdRetype = $('#accountPwdRetype').val(); if (accountFirstName == '' || accountLastName == '' || accountAffiliation == '' || accountCity == '' || accountCountry == '' || accountEmail == '' || accountPwd == '') { alert('All fields are compulsory to create your account!'); return false; } if (!(chkFilterEmail.test(accountEmail))) { alert('Invalid email address is entered. Please try again!'); return false; } if (accountPwd != accountPwdRetype) { alert('Passwords do not match. Please try again!'); return false; } $.ajax({ url: apiURL + 'register.php', data: {type: 'editor', firstName: accountFirstName, lastName: accountLastName, salutation: accountSalutation, email: accountEmail, pwd: accountPwd, affiliation: accountAffiliation, city: accountCity, country: accountCountry}, dataType: 'json', method: 'POST', error: function (error) { alert('ERROR: Could not create account!'); } }) .done(function(res) { if (res.status == 200) { $('#panelCreateAccountForm').hide(); $('#panelCreateAccountMessage').show(); } else { alert('ERROR: ' + res.message); } }); } function chkSearch() { let keyword = $('#srchKeyword').val(); let srchType = $('#srchType').val(); if (keyword == '') { alert('No keyword entered!'); return false; } $('.contentBox').hide(); $('#contentLoader').show(); $.ajax({ url: apiURL + 'search.php', data: {session: gUser.session, type: srchType, val: keyword}, dataType: 'json', method: 'POST', error: function (error) { $('#bodySearchResults').html('<div style="margin-bottom:20px">No Results found!</div>'); $('.contentBox').hide(); $('#contentSearchResults').show(); } }) .done(function(res) { if (res.status == 200) { if (res.data.length == 0) { $('#contentLoader').hide(); $('#contentHome').show(); alert('No Search Results found!'); } else { processSearchResults(res.data); } } else { $('.contentBox').show(); $('#contentLoader').hide(); alert('ERROR: ' + res.message); } }); } function getFeaturedArticles() { var htmlArticle = ''; $('#bodyFeaturedArticles').html($('#contentLoader').html()); $.ajax({ url: apiURL + 'featured.articles.php', dataType: 'json', error: function (error) { htmlArticle = '<div class="col mt-2">Could not get Featured Articles!</div>'; $('#bodyFeaturedArticles').html(htmlArticle); } }) .done(function(res) { if (res.status == 200) { if (res.data.length == 0) { htmlArticle = '<div class="col mt-2">There are no Featured Articles!</div>'; } else { $.each(res.data, function(key, value) { if (key < 3) { var itemArticle = value; var itemImg = itemArticle.fileImg; htmlArticle += ' <div class="col-lg-4 mt-3 mt-lg-0">'; htmlArticle += ' <div class="boxArticle">'; if (itemImg != '') { itemImg = '../uploads/img/' + itemImg; htmlArticle += ' <div class="backCover cursorH" onclick="getArticleDetails(' + itemArticle.id + ')" style="height:200px;background-image:url(' + itemImg + ')"></div>'; } else { htmlArticle += ' <div class="backCover cursorH" onclick="getArticleDetails(' + itemArticle.id + ')" style="height:200px"></div>'; } htmlArticle += ' <div class="padding15">'; htmlArticle += ' <h1><a href="javascript:np()" onclick="getArticleDetails(' + itemArticle.id + ')">' + itemArticle.title + '</a></h1>'; if (itemArticle.summary !== null) htmlArticle += itemArticle.summary.substring(0,150) + '...'; htmlArticle += ' </div>'; htmlArticle += ' </div>'; htmlArticle += ' </div>'; } }); } } else { htmlArticle = '<div class="col mt-2">There are no Featured Articles!</div>'; } $('#bodyFeaturedArticles').html(htmlArticle); }); } function getUploads() { $('.contentBox').hide(); $('#contentDashboard').show(); $('#bodyUploads').html($('#contentLoader').html()); $.ajax({ url: apiURL + 'user.articles.php', data: {userLogin: gUser.login}, dataType: 'json', method: 'POST', }) .done(function(res) { var htmlArticle = ''; if (res.status == 200) { if (res.data.length == 0) { $('#txtUploadCount').html('You have not uploaded any papers.'); } else { htmlArticle += ' <table class="table table-striped">'; htmlArticle += ' <thead>'; htmlArticle += ' <tr>'; htmlArticle += ' <th scope="col">#</th>'; htmlArticle += ' <th scope="col">Title</th>'; htmlArticle += ' <th scope="col">Author(s)</th>'; htmlArticle += ' <th scope="col"></th>'; htmlArticle += ' <th scope="col"></th>'; htmlArticle += ' </tr>'; htmlArticle += ' </thead>'; htmlArticle += ' <tbody>'; $.each(res.data, function(key, value) { var itemArticle = value; var author = itemArticle.author; var fullAuthor = ''; for (var i = 0; i < author.length; i++) { fullAuthor += author[i].salutation + ' ' + author[i].firstName + ' ' + author[i].lastName + ', '; } fullAuthor = fullAuthor.slice(0, -2); htmlArticle += ' <tr>'; htmlArticle += ' <td>' + (key+1) + '.</td>'; htmlArticle += ' <td>' + itemArticle.title + '</td>'; htmlArticle += ' <td>' + fullAuthor + '</td>'; if (itemArticle.isPublished == 1) { htmlArticle += ' <td><div class="alert alert-success p-2 text-center">Published</div></td>'; } else { htmlArticle += ' <td><div class="alert alert-warning p-2 text-center">Draft</div></td>'; } htmlArticle += ' <td align="right">'; htmlArticle += ' <input type="button" class="btn btn-sm btn-secondary" onclick="downloadArticle(this)" data-file="' + itemArticle.filePdf + '" value="View" />'; htmlArticle += ' <input type="button" class="btn btn-sm btn-secondary" onclick="goEditPaper(' + itemArticle.id + ')" value="Edit" />'; if (itemArticle.isPublished == 1) { htmlArticle += ' <input type="button" class="btn btn-sm btn-secondary" onclick="setPaper(' + itemArticle.id + ',0)" value="Move to Draft" />'; } else { htmlArticle += ' <input type="button" class="btn btn-sm btn-secondary" onclick="setPaper(' + itemArticle.id + ',1)" value="Publish" />'; } htmlArticle += ' </td>'; htmlArticle += ' </tr>'; }); htmlArticle += ' </tbody>'; htmlArticle += ' </table>'; } } else { htmlArticle = '<div class="col">Could not get your uploaded papers!</div>'; } $('#bodyUploads').html(htmlArticle); }); } function getArticleDetails(wchArticle) { $('.contentBox').hide(); $('#contentLoader').show(); $.ajax({ url: apiURL + 'article.php?id=' + wchArticle, dataType: 'json' }) .done(function(res) { $('#contentLoader').hide(); if (res.status == 200) { var resData = res.data; var author = resData.author; var fullAuthor = ''; for (var i = 0; i < author.length; i++) { fullAuthor += author[i].salutation + ' ' + author[i].firstName + ' ' + author[i].lastName + ', '; } fullAuthor = fullAuthor.slice(0, -2); $('#txtArticleDetail_title').html(resData.title); $('#txtArticleDetail_author').html(fullAuthor !== '' ? fullAuthor : 'NA'); $('#txtArticleDetail_published').html((resData.yearPublished !== null && resData.yearPublished !== '') ? resData.yearPublished : 'NA'); $('#txtArticleDetail_doi').html((resData.doi !== null && resData.doi !== '') ? resData.doi : 'NA'); $('#txtArticleDetail_summary').html(resData.summary); $('#txtDownloadFile').data('id', resData.id); $('#txtDownloadFile').data('file', resData.fileURL); $('#contentArticleDetails').show(); } else { $('.contentBox').hide(); $('#contentHome').show(); alert('ERROR: ' + res.message); } }); } function downloadArticle(elm) { var downloadId = $(elm).data('id'); if (gUser.login == '') { gUser.loginAction = downloadId; goLogin(); } else { var downloadFile = $(elm).data('file'); if (downloadFile == '') { getDownloadFile(downloadId); } else { window.open('/uploads/pdf/' + downloadFile); } } } function processSearchResults(res) { var htmlSearch = ''; $.each(res, function(key, value) { var itemSearch = value; htmlSearch += '<div style="margin-bottom:40px">'; htmlSearch += ' <div class="fl" style="width:30px;margin-top:5px;">' + (key+1) + '.</div>'; htmlSearch += ' <div class="fl" style="width:calc(100% - 30px)">'; htmlSearch += ' <div class="txtMedium txtGrey">' + itemSearch.title + '</div>'; htmlSearch += ' <div style="border-bottom:2px #fdb813 solid;margin-bottom:10px;padding-bottom:10px;">'; htmlSearch += ' <div class="txtSmall txtGrey">'; var author = itemSearch.author; var fullAuthor = ''; for (var i = 0; i < author.length; i++) { fullAuthor += author[i].salutation + ' ' + author[i].firstName + ' ' + author[i].lastName + ', '; } fullAuthor = fullAuthor.slice(0, -2); htmlSearch += ' <b>Author:</b> ' + (fullAuthor !== '' ? fullAuthor : 'NA') + ' | '; htmlSearch += ' <b>Published:</b> ' + (itemSearch.yearPublished !== null ? itemSearch.yearPublished : 'NA') + ' | '; htmlSearch += ' <b>DOI:</b> ' + (itemSearch.doi !== null ? itemSearch.doi : 'NA'); htmlSearch += ' </div>'; htmlSearch += ' </div>'; htmlSearch += ' <div style="width:calc(100% - 30px)" class="fl boxAbstract">' + itemSearch.summary + '</div>'; htmlSearch += ' <div class="fr">'; if (gUser.login == '') { htmlSearch += ' <a href="javascript:np()" id="txtDownloadFile" data-id="' + itemSearch.id + '" data-file="" onclick="downloadArticle(this)" title="Download PDF"><i class="far fa-file-pdf fa-lg"></i></a>'; } else { htmlSearch += ' <a href="javascript:np()" id="txtDownloadFile" data-id="" data-file="' + itemSearch.filePdf + '" onclick="downloadArticle(this)" title="Download PDF"><i class="far fa-file-pdf fa-lg"></i></a>'; } htmlSearch += ' </div>'; htmlSearch += ' </div>'; htmlSearch += ' <div class="cleaner"></div>'; htmlSearch += '</div>'; }); $('.contentBox').hide(); $('#bodySearchResults').html(htmlSearch); $('#contentSearchResults').show(); } function chkUploadPaper() { var uploadCategoryId = $('#contentUpload #uploadCategoryId').val(); var uploadYear = $('#contentUpload #uploadYear').val(); var uploadTitle = $('#contentUpload #uploadTitle').val(); var uploadDOI = $('#contentUpload #uploadDOI').val(); var uploadSummary = $('#contentUpload #uploadSummary').val(); var uploadPdf = $('#contentUpload #uploadPdf').val(); var uploadAuthorFirstName = $('#contentUpload #uploadAuthorFirstName1').val(); var uploadAuthorLastName = $('#contentUpload #uploadAuthorLastName1').val(); if (uploadCategoryId == '') { alert('No Category selected!'); return false; } if (uploadTitle == '') { alert('No Paper Title entered!'); return false; } if (uploadSummary == '') { alert('No Paper Summary entered!'); return false; } if (uploadPdf == '') { alert('No PDF selected to upload!'); return false; } if (uploadAuthorFirstName == '') { alert('No Author First name entered!'); return false; } if (uploadAuthorLastName == '') { alert('No Author Last name entered!'); return false; } var combinedAuthors = []; var numAuthors = parseInt($('#contentUpload #numAuthors').val()); for (var i = 1; i <= numAuthors; i++) { var authorSalutation = $('#contentUpload #uploadAuthorSalutation' + i).val(); var authorFirstName = $('#contentUpload #uploadAuthorFirstName' + i).val(); var authorLastName = $('#contentUpload #uploadAuthorLastName' + i).val(); if (authorFirstName != '' && authorLastName != '') { var author = {}; author.salutation = authorSalutation; author.firstName = authorFirstName; author.lastName = authorLastName; combinedAuthors.push(author); } } var formData = new FormData(); formData.append('type', 'add'); formData.append('userId', gUser.login); formData.append('categoryId', uploadCategoryId); formData.append('yearPublished', uploadYear); formData.append('author', JSON.stringify(combinedAuthors)); formData.append('title', uploadTitle); formData.append('doi', uploadDOI); formData.append('summary', uploadSummary); formData.append('fileImg', $('#contentUpload #uploadImg')[0].files[0]); formData.append('filePdf', $('#contentUpload #uploadPdf')[0].files[0]); $.ajax({ method: 'POST', url: apiURL + 'add.edit.paper.php', data: formData, processData: false, contentType: false, enctype: 'multipart/form-data', error: function (error) { alert('ERROR: There was an error processing your request!'); } }) .done(function(res) { let resData = JSON.parse(res); if (resData.status == 200) { getUploads(); alert('Paper has been uploaded!'); } else { alert('ERROR: ' + resData.message); } }); } function chkEditPaper() { let uploadPaperId = $('#contentEdit #uploadPaperId').val(); let uploadCategoryId = $('#contentEdit #uploadCategoryId').val(); let uploadYear = $('#contentEdit #uploadYear').val(); let uploadTitle = $('#contentEdit #uploadTitle').val(); let uploadDOI = $('#contentEdit #uploadDOI').val(); let uploadSummary = $('#contentEdit #uploadSummary').val(); let uploadAuthorFirstName = $('#contentEdit #uploadAuthorFirstName1').val(); let uploadAuthorLastName = $('#contentEdit #uploadAuthorLastName1').val(); if (uploadCategoryId == '') { alert('No Category selected!'); return false; } if (uploadTitle == '') { alert('No Paper Title entered!'); return false; } if (uploadSummary == '') { alert('No Paper Summary entered!'); return false; } if (uploadAuthorFirstName == '') { alert('No Author First name entered!'); return false; } if (uploadAuthorLastName == '') { alert('No Author Last name entered!'); return false; } var combinedAuthors = []; var numAuthors = parseInt($('#contentEdit #numAuthors').val()); for (var i = 1; i <= numAuthors; i++) { let authorId = $('#contentEdit #uploadAuthorId' + i).val(); let authorSalutation = $('#contentEdit #uploadAuthorSalutation' + i).val(); let authorFirstName = $('#contentEdit #uploadAuthorFirstName' + i).val(); let authorLastName = $('#contentEdit #uploadAuthorLastName' + i).val(); var author = {}; author.id = authorId; author.salutation = authorSalutation; author.firstName = authorFirstName; author.lastName = authorLastName; combinedAuthors.push(author); } var formData = new FormData(); formData.append('type', 'edit'); formData.append('userId', gUser.login); formData.append('paperId', uploadPaperId); formData.append('categoryId', uploadCategoryId); formData.append('yearPublished', uploadYear); formData.append('author', JSON.stringify(combinedAuthors)); formData.append('title', uploadTitle); formData.append('doi', uploadDOI); formData.append('summary', uploadSummary); formData.append('fileImg', $('#contentEdit #uploadImg')[0].files[0]); $.ajax({ method: 'POST', url: apiURL + 'add.edit.paper.php', data: formData, processData: false, contentType: false, enctype: 'multipart/form-data', error: function (error) { alert('ERROR: There was an error processing your request!'); } }) .done(function(res) { let resData = JSON.parse(res); if (resData.status == 200) { getUploads(); alert('Paper has been edited!'); } else { alert('ERROR: ' + resData.message); } }); } function setPaper(wchPaperId, isPublished) { $.ajax({ url: apiURL + 'add.edit.paper.php', data: {type: 'status', userId: gUser.login, paperId: wchPaperId, status: isPublished}, dataType: 'json', method: 'POST', error: function (error) { alert('ERROR: There was an error processing your request!'); } }) .done(function(res) { if (res.status == 200) { getUploads(); } else { alert('ERROR: ' + res.message); } }); } function addMoreAuthorsUpload() { var numAuthors = parseInt($('#contentUpload #numAuthors').val()) + 1; $('#contentUpload #numAuthors').val(numAuthors); var htmlAuthor = ''; htmlAuthor += '<div class="form-row">'; htmlAuthor += ' <div class="col-md-2 mt-0 pt-0 mt-md-4 pt-md-1">'; htmlAuthor += ' <span class="txtMed badge badge-primary p-2">Author ' + numAuthors + '</span>'; htmlAuthor += ' </div>'; htmlAuthor += ' <div class="col-md-2 mb-3">'; htmlAuthor += ' <label for="uploadAuthorSalutation' + numAuthors + '">Salutation</label>'; htmlAuthor += ' <select id="uploadAuthorSalutation' + numAuthors + '" name="uploadAuthorSalutation' + numAuthors + '" class="form-control">'; htmlAuthor += ' <option>Mr.'; htmlAuthor += ' <option>Ms.'; htmlAuthor += ' <option>Dr.'; htmlAuthor += ' <option>Prof.'; htmlAuthor += ' </select>'; htmlAuthor += ' </div>'; htmlAuthor += ' <div class="col-md-4 mb-3">'; htmlAuthor += ' <label for="uploadAuthorFirstName' + numAuthors + '">First name</label>'; htmlAuthor += ' <input type="text" class="form-control" id="uploadAuthorFirstName' + numAuthors + '" name="uploadAuthorFirstName' + numAuthors + '" placeholder="First name" maxlength="100" />'; htmlAuthor += ' </div>'; htmlAuthor += ' <div class="col-md-4 mb-3">'; htmlAuthor += ' <label for="uploadAuthorLastName' + numAuthors + '">Last name</label>'; htmlAuthor += ' <input type="text" class="form-control" id="uploadAuthorLastName' + numAuthors + '" name="uploadAuthorLastName' + numAuthors + '" placeholder="Last name" maxlength="100" />'; htmlAuthor += ' </div>'; htmlAuthor += ' <input type="hidden" id="uploadAuthorId' + numAuthors + '" name="uploadAuthorId' + numAuthors + '" />'; htmlAuthor += '</div>'; $('#contentUpload #panelAuthors').append(htmlAuthor); } function addMoreAuthorsEdit() { var numAuthors = parseInt($('#contentEdit #numAuthors').val()) + 1; $('#contentEdit #numAuthors').val(numAuthors); var htmlAuthor = ''; htmlAuthor += '<div class="form-row">'; htmlAuthor += ' <div class="col-md-2 mt-0 pt-0 mt-md-4 pt-md-1">'; htmlAuthor += ' <span class="txtMed badge badge-primary p-2">Author ' + numAuthors + '</span>'; htmlAuthor += ' </div>'; htmlAuthor += ' <div class="col-md-2 mb-3">'; htmlAuthor += ' <label for="uploadAuthorSalutation' + numAuthors + '">Salutation</label>'; htmlAuthor += ' <select id="uploadAuthorSalutation' + numAuthors + '" name="uploadAuthorSalutation' + numAuthors + '" class="form-control">'; htmlAuthor += ' <option>Mr.'; htmlAuthor += ' <option>Ms.'; htmlAuthor += ' <option>Dr.'; htmlAuthor += ' <option>Prof.'; htmlAuthor += ' </select>'; htmlAuthor += ' </div>'; htmlAuthor += ' <div class="col-md-4 mb-3">'; htmlAuthor += ' <label for="uploadAuthorFirstName' + numAuthors + '">First name</label>'; htmlAuthor += ' <input type="text" class="form-control" id="uploadAuthorFirstName' + numAuthors + '" name="uploadAuthorFirstName' + numAuthors + '" placeholder="First name" maxlength="100" />'; htmlAuthor += ' </div>'; htmlAuthor += ' <div class="col-md-4 mb-3">'; htmlAuthor += ' <label for="uploadAuthorLastName' + numAuthors + '">Last name</label>'; htmlAuthor += ' <input type="text" class="form-control" id="uploadAuthorLastName' + numAuthors + '" name="uploadAuthorLastName' + numAuthors + '" placeholder="Last name" maxlength="100" />'; htmlAuthor += ' </div>'; htmlAuthor += ' <input type="hidden" id="uploadAuthorId' + numAuthors + '" name="uploadAuthorId' + numAuthors + '" />'; htmlAuthor += '</div>'; $('#contentEdit #panelAuthors').append(htmlAuthor); } function resetAccountLink() { $('#frmCreateAccount').trigger('reset'); $('#panelCreateAccountForm').show(); $('.panelCreateAccountButton').show(); $('#panelCreateAccountMessage').hide(); }