admin-system-status.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. @var i string default
  3. @var l how many repeat s
  4. @var s string to repeat
  5. @var w where s should indent
  6. */
  7. jQuery.wc_strPad = function(i,l,s,w) {
  8. var o = i.toString();
  9. if (!s) { s = '0'; }
  10. while (o.length < l) {
  11. // empty
  12. if(w == 'undefined'){
  13. o = s + o;
  14. }else{
  15. o = o + s;
  16. }
  17. }
  18. return o;
  19. };
  20. jQuery('#copy-system-status' ).click( function(){
  21. var paragraphContainer = jQuery( this ).parent();
  22. var report = "";
  23. jQuery('.nf-status-table thead, .nf-status-table tbody').each(function(){
  24. if ( jQuery( this ).is('thead') ) {
  25. report = report + "\n### " + jQuery.trim( jQuery( this ).text() ) + " ###\n\n";
  26. } else {
  27. jQuery('tr', jQuery( this )).each(function(){
  28. var the_name = jQuery.wc_strPad( jQuery.trim( jQuery( this ).find('td:eq(0)').text() ), 25, ' ' );
  29. var the_value = jQuery.trim( jQuery( this ).find('td:eq(1)').text() );
  30. var value_array = the_value.split( ', ' );
  31. if ( value_array.length > 1 ){
  32. // if value have a list of plugins ','
  33. // split to add new line
  34. var output = '';
  35. var temp_line ='';
  36. jQuery.each( value_array, function(key, line){
  37. var tab = ( key == 0 )?0:25;
  38. temp_line = temp_line + jQuery.wc_strPad( '', tab, ' ', 'f' ) + line +'\n';
  39. });
  40. the_value = temp_line;
  41. }
  42. report = report +''+ the_name + the_value + "\n";
  43. });
  44. }
  45. } );
  46. try {
  47. var tmp = jQuery("<textarea>");
  48. jQuery("body").append(tmp);
  49. tmp.val( report ).select();
  50. document.execCommand("copy");
  51. tmp.remove();
  52. var myModal = new jBox( 'Modal', {
  53. content: '<i class="fa fa-clipboard" aria-hidden="true"></i> Copied!',
  54. onOpen: function() {
  55. setTimeout(function(){ myModal.close() }, 700);
  56. }
  57. } );
  58. myModal.open();
  59. return false;
  60. } catch(e) {
  61. console.log( e );
  62. }
  63. return false;
  64. });