Add parse books feature for admin users.
This commit is contained in:
		
							parent
							
								
									9f2977d2c0
								
							
						
					
					
						commit
						e4bbfd5f60
					
				| 
						 | 
				
			
			@ -88,3 +88,17 @@ a {
 | 
			
		|||
.hide {
 | 
			
		||||
   display: none;
 | 
			
		||||
}
 | 
			
		||||
#parsebooks {
 | 
			
		||||
   right: 0;
 | 
			
		||||
   bottom: 0;
 | 
			
		||||
   position: fixed;
 | 
			
		||||
   z-index: 100;
 | 
			
		||||
   color: var(--primary-color);
 | 
			
		||||
   font-weight: bold;
 | 
			
		||||
   font-size: 16pt;
 | 
			
		||||
   cursor: pointer;
 | 
			
		||||
   padding: 0.5em;
 | 
			
		||||
   margin: 0.25em;
 | 
			
		||||
   border: 2px solid var(--box-border);
 | 
			
		||||
   border-radius: 10px;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,6 +37,9 @@ $curpath = $_SESSION['bookdir'];
 | 
			
		|||
    <input placeholder="Enter Address" name="edit_kindle" id="edit_kindle" size="40" required>
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
<div id='parsebooks' class='hide'>
 | 
			
		||||
  Parse
 | 
			
		||||
</div>
 | 
			
		||||
<script type='text/javascript' src='core/jquery-3.6.3.min.js'></script>
 | 
			
		||||
<script type='text/javascript' src='core/jquery-ui-1.14.1/jquery-ui.min.js'></script>
 | 
			
		||||
<script type='text/javascript' src='core/jquery.toast.min.js'></script>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										39
									
								
								js/books.js
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								js/books.js
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -42,6 +42,7 @@ $(document).ready(function() {
 | 
			
		|||
         getContents();
 | 
			
		||||
      }
 | 
			
		||||
   });
 | 
			
		||||
   $("#parsebooks").on("click", parseBooks);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
function showKindleMail() {
 | 
			
		||||
| 
						 | 
				
			
			@ -67,6 +68,7 @@ function getContents() {
 | 
			
		|||
      success  : function(data, stat, jqo) {
 | 
			
		||||
                    if ( data.validated == false ) redirectToLogin();
 | 
			
		||||
                    admin = data.admin;
 | 
			
		||||
                    if ( admin ) $("#parsebooks").removeClass("hide");
 | 
			
		||||
                    if ( data.kindlemail != kindlemail ) {
 | 
			
		||||
                       kindlemail = data.kindlemail;
 | 
			
		||||
                       showKindleMail();
 | 
			
		||||
| 
						 | 
				
			
			@ -159,6 +161,41 @@ function setKindleMail(email) {
 | 
			
		|||
   });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function parseBooks() {
 | 
			
		||||
   if ( !admin ) return;
 | 
			
		||||
   var myToast = $.toast({
 | 
			
		||||
      text : "<h2><strong>Parsing Books</strong></h2>",
 | 
			
		||||
      showHideTransition : 'slide',
 | 
			
		||||
      bgColor : '#033e9e',
 | 
			
		||||
      textColor : '#eee',
 | 
			
		||||
      hideAfter : false,
 | 
			
		||||
      textAlign : 'left',
 | 
			
		||||
      position : 'top-right'
 | 
			
		||||
   });
 | 
			
		||||
   $.ajax({
 | 
			
		||||
      url      : 'scripts/parsebooks.php',
 | 
			
		||||
      dataType : 'json',
 | 
			
		||||
      success  : function(data, stat, jqo) {
 | 
			
		||||
                    myToast.reset();
 | 
			
		||||
                    var message = "";
 | 
			
		||||
                    message += "<h2><strong>Books Parsed:</strong></h2>";
 | 
			
		||||
                    message += "<hr>";
 | 
			
		||||
                    message += "<h3><strong>New:</strong> " + data.new + "</h3><br />";
 | 
			
		||||
                    message += "<h3><strong>Purged:</strong> " + data.purged + "</h3><br />";
 | 
			
		||||
                    message += "<h3><strong>Total:</strong> " + data.total + "</h3><br />";
 | 
			
		||||
                    $.toast({
 | 
			
		||||
                       text : message,
 | 
			
		||||
                       showHideTransition : 'slide',
 | 
			
		||||
                       bgColor : '#137c1e',
 | 
			
		||||
                       textColor : '#eee',
 | 
			
		||||
                       hideAfter : 10000,
 | 
			
		||||
                       textAlign : 'left',
 | 
			
		||||
                       position : 'top-right'
 | 
			
		||||
                    });
 | 
			
		||||
      }
 | 
			
		||||
   });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function sendToKindle(fileid, filename) {
 | 
			
		||||
   var myToast = $.toast({
 | 
			
		||||
      text : "<h3><strong>Sending: " + filename + "</strong></h3>",
 | 
			
		||||
| 
						 | 
				
			
			@ -193,3 +230,5 @@ function sendToKindle(fileid, filename) {
 | 
			
		|||
                 }
 | 
			
		||||
   });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// vim: ts=3 sw=3 ai:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user