1jQuery(document).ready(function(){ 2 3 var ppID = jQuery('#error-notification-id').attr('class'); 4 if( ppID ) { 5 /* Thank You text - you can see it when you sent a notification */ 6 var thankYouText = jQuery('#error-notification-settings p').text(); 7 /* Background of notification DIV */ 8 var backgroundStyle = enp.barBackground; 9 /* Notification Bar Position */ 10 var barPosition = enp.barPosition; 11 /* Text color of notification DIV */ 12 var textStyle = enp.barTextColor; 13 /* Keys container */ 14 var keys = {}; 15 16 17 /* When visitor/user presses keys combination - Shift + Enter to report an error */ 18 jQuery(document).keydown(function (e) { 19 keys[e.which] = true; 20 if(keys[16] && keys[13]) { 21 sendError(backgroundStyle, barPosition, textStyle, thankYouText); 22 for (var i in keys) { 23 var item = keys[i]; 24 keys[i] = false; 25 } 26 } 27 }); 28 29 jQuery(document).keyup(function (e) { 30 delete keys[e.which]; 31 }); 32 33 /* When visitor/user clicks on a link to report an error */ 34 jQuery('a.enp-report').on('click', function(event) { 35 event.preventDefault(); 36 sendError(backgroundStyle, barPosition, textStyle, thankYouText); 37 }); 38 } 39 40}); 41 42/* Send an email to the administrator */ 43function sendError(bgColor, barPosition, textColor, thxText) { 44 if(getSelectedText() != "") { 45 46 /* get current post/page id */ 47 var ppID = jQuery('#error-notification-id').attr('class'); 48 49 /* data */ 50 data = { 51 action: 'error_notification_email', 52 pageName: jQuery.trim(jQuery('title').text()), 53 pageError: getSelectedText(), 54 pageUrl: window.location.href, 55 postPageID: ppID 56 }; 57 58 /* check if user wants to have confirmation box */ 59 if(enp.confirmation == 1) { 60 var confirmationBox = {'display': 'none', 'padding': '20px', 'width': '400px', 'background': 'black', 'position':'fixed', 'top': '50%', 'margin-top': '-100px', 'left': '50%', 'margin-left': '-150px', 'z-index' : '9999'}; 61 jQuery('body').append('<div id="notification-error-confirmation"><h4 style="text-align: center; padding:10px; background: '+bgColor+'; color: '+textColor+';">Are you sure?</h4><p style="color: #eee; padding: 10px"><span style="color:#888;"><strong>Error:</strong></span> '+getSelectedText()+'</p><p style="text-align: center; margin-top: 20px;"><a style="display: inline-block; width: 100px; padding: 10px; background: #89BA2E; text-align: center; text-decoration: none; color: #f4f4f4;" id="notification-error-cb-yes" href="#">OK</a><a style="display: inline-block; width: 100px; padding: 10px; background: #CC433E; text-align: center; text-decoration: none; color: #f4f4f4;" id="notification-error-cb-no" href="#">Cancel</a></p></div>'); 62 63 /* show confirmation box */ 64 jQuery('#notification-error-confirmation').css(confirmationBox).fadeIn(); 65 66 /* user clicked ok */ 67 jQuery('#notification-error-confirmation #notification-error-cb-yes').click(function(e) { 68 e.preventDefault(); 69 jQuery('#notification-error-confirmation').remove(); 70 71 jQuery.post(enp.ajaxurl, data, function(response) { 72 if(!response) { 73 thxText = 'Sorry something went wrong. Please try again.'; 74 } 75 }); 76 77 if(barPosition === 'top') { 78 var notificationContainer = {'width':'100%', 'display': 'none', 'background': bgColor, 'color': textColor, 'position':'fixed', 'top':'0', 'left':'0', 'text-align': 'center', 'z-index' : '9999'}; 79 } else { 80 var notificationContainer = {'width':'100%', 'display': 'none', 'background': bgColor, 'color': textColor, 'position':'fixed', 'bottom':'0', 'left':'0', 'text-align': 'center', 'z-index' : '9999'}; 81 } 82 83 /* Add bar container to document */ 84 jQuery('body').append('<div id="notification-error-plugin" class="error-notification"><p style="margin:0; padding: 10px;">'+thxText+'</p></div>'); 85 86 jQuery('#notification-error-plugin').css(notificationContainer); 87 jQuery('#notification-error-plugin').fadeIn(1000).delay(2500).fadeOut(500); 88 }); 89 90 /* user clicked cancel */ 91 jQuery('#notification-error-confirmation #notification-error-cb-no').click(function(e) { 92 e.preventDefault(); 93 jQuery('#notification-error-confirmation').remove(); 94 }); 95 96 } else { 97 jQuery.post(enp.ajaxurl, data, function(response) { 98 if(!response) { 99 thxText = 'Sorry something went wrong. Please try again.'; 100 } 101 }); 102 103 if(barPosition === 'top') { 104 var notificationContainer = {'width':'100%', 'display': 'none', 'background': bgColor, 'color': textColor, 'position':'fixed', 'top':'0', 'left':'0', 'text-align': 'center', 'z-index' : '9999'}; 105 } else { 106 var notificationContainer = {'width':'100%', 'display': 'none', 'background': bgColor, 'color': textColor, 'position':'fixed', 'bottom':'0', 'left':'0', 'text-align': 'center', 'z-index' : '9999'}; 107 } 108 109 /* Add bar container to document */ 110 jQuery('body').append('<div id="notification-error-plugin" class="error-notification"><p style="margin:0; padding: 10px;">'+thxText+'</p></div>'); 111 112 jQuery('#notification-error-plugin').css(notificationContainer); 113 jQuery('#notification-error-plugin').fadeIn(1000).delay(2500).fadeOut(500); 114 } 115 116 } else { 117 alert("Please find an error and highlight it."); 118 } 119} 120 121/* Get selected text */ 122function getSelectedText() { 123 if (window.getSelection) { 124 return window.getSelection().toString(); 125 } else if (document.getSelection) { 126 return document.getSelection(); 127 } else if (document.selection) { 128 return document.selection.createRange().text; 129 } 130}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.