jsPostToSNAP

The NextScripts: Social Networks Auto-Poster jsPostToSNAP function.

Description

jsPostToSNAP(); 

Usage

  1. if ( !function_exists( 'jsPostToSNAP' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextscripts-social-networks-auto-poster/nxs_functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = jsPostToSNAP(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/nxs_functions.php  
  1. if (!function_exists("jsPostToSNAP")) { function jsPostToSNAP() { global $nxs_snapAvNts, $nxs_plurl; ?> 
  2. <script type="text/javascript" >  
  3. function nxs_updateGetImgsX(e) { } 
  4. jQuery(document).on('change', '#content', function( e ) { nxs_updateGetImgsX( e ); }); 
  5.  
  6. function nxs_updateGetImgsXX(e) {  
  7. var targetId = e.target.id;  
  8. var text = 'Kortinko'; 
  9. switch ( targetId ) { 
  10. case 'content': 
  11. text = jQuery('#content').val();  
  12. break; 
  13. case 'tinymce': 
  14. if ( tinymce.activeEditor ) text = tinymce.activeEditor.getContent(); 
  15. break; 
  16. jQuery('.nxs_imgPrevList').html( text ); 
  17. }  
  18. function nxs_clPrvImgShow(tIdN) { jQuery("#isAutoImg-"+tIdN).trigger('click'); jQuery("#isAutoImg-"+tIdN).trigger('click'); }  
  19. function nxs_clPrvImg(id, ii) { jQuery("#imgToUse-"+ii).val(jQuery("#"+id+" img").attr('src')); jQuery(".nxs_prevIDiv"+ii+" .nxs_checkIcon").hide(); 
  20. jQuery(".nxs_prevIDiv"+ii).removeClass("nxs_chImg_selDiv"); jQuery(".nxs_prevIDiv"+ii+" img").removeClass("nxs_chImg_selImg");  
  21. jQuery("#"+id+" img").addClass("nxs_chImg_selImg"); jQuery("#"+id).addClass("nxs_chImg_selDiv"); jQuery("#"+id+" .nxs_checkIcon").show(); 
  22. }  
  23. function nxs_getOriginalWidthOfImg(img_element) { var t = new Image(); t.src = (img_element.getAttribute ? img_element.getAttribute("src") : false) || img_element.src; /* alert(t.src+" | "+t.width); */ return t.width; }  
  24. function nxs_updateGetImgs(e) {  
  25. var textOut=''; var text = ''; 
  26. var tId = e.target.id;  
  27. var tIdN = tId.replace("isAutoImg-", ""); 
  28. if ( tinymce.activeEditor ) text = tinymce.activeEditor.getContent(); 
  29. if ( text == '' ) text = jQuery('#content').val();  
  30.  
  31. jQuery('#NS_SNAP_AddPostMetaTags').append('<div id="nxs_tempDivImgs" style="display: none;"></div>'); jQuery('#nxs_tempDivImgs').append(text); 
  32. var textOutA = new Array(); var currSelImg = jQuery("#imgToUse-"+tIdN).val(); 
  33.  
  34. textOutA.push('http://cdn.gtln.us/img/nxs/noImgC.png');  
  35. //var fImg = jQuery('.attachment-post-thumbnail').attr('src'); if (fImg!='' && fImg!=undefined) { textOutA.push(fImg); if (currSelImg=='') currSelImg = fImg; }  
  36. var fImg = jQuery('#set-post-thumbnail > img').attr('src'); if (fImg!='' && fImg!=undefined) { textOutA.push(fImg); if (currSelImg=='') currSelImg = fImg; }  
  37. var fImg = jQuery('#yapbdiv img').attr('src'); if (fImg!='' && fImg!=undefined) { textOutA.push(fImg); if (currSelImg=='') currSelImg = fImg; } 
  38.  
  39. jQuery('#nxs_tempDivImgs img').each(function() { var prWidth; prWidth = nxs_getOriginalWidthOfImg(this); if (prWidth!=1) textOutA.push(jQuery(this).attr('src')); });  
  40. jQuery('#nxs_tempDivImgs').remove(); 
  41. var index; for (index = 0; index < textOutA.length; ++index) { var isSel = currSelImg == textOutA[index] ? 'nxs_chImg_selImg' : ''; var isSelDisp = currSelImg == textOutA[index] ? 'style="display:block;"' : '';  
  42. textOut = textOut + '<div class="nxs_prevIDiv'+tIdN+' nxs_prevImagesDiv" id="nxs_idiv'+tIdN+index+'" onclick="nxs_clPrvImg(\'nxs_idiv'+tIdN+index+'\', \''+tIdN+'\');"><img class="nxs_prevImages '+isSel+'" src="'+textOutA[index]+'"><div '+isSelDisp+' class="nxs_checkIcon"><div class="media-modal-icon"></div></div></div>';  
  43. jQuery('#imgPrevList-'+tIdN).html( textOut ); 
  44. if (jQuery('#'+tId).is(":checked")) jQuery('#imgPrevList-'+tIdN).hide(); else { jQuery('#nxs_'+tIdN+'_idivD').hide(); jQuery('#imgPrevList-'+tIdN).show(); } 
  45.  
  46.  
  47. jQuery(document).on('change', '.isAutoURL', function( e ) { var tId = e.target.id; var tIdN = tId.replace("isAutoURL-", ""); 
  48. if (jQuery('#'+tId).is(":checked")) { jQuery('#isAutoURLFld-'+tIdN).hide(); jQuery('#URLToUse-'+tIdN).val(''); } else { jQuery('#isAutoURLFld-'+tIdN).show(); } 
  49. });  
  50. jQuery(document).on('change', '.isAutoImg', function( e ) {  
  51. nxs_updateGetImgs( e ); 
  52. });  
  53. jQuery(document).on('change', '#wp-content-editor-container #conXXtent', function() { 
  54. nxs_updateGetImgs(); 
  55. }); 
  56. jQuery(document).on('change', '#tinXXymce', function() { 
  57. nxs_updateGetImgs(); 
  58. });  
  59. jQuery(document).ready(function($) {  
  60. <?php  
  61. foreach ($nxs_snapAvNts as $avNt) {?> 
  62. jQuery('input#rePostTo<?php echo $avNt['code']; ?>_button').click(function() { var data = { action: 'rePostTo<?php echo $avNt['code']; ?>', id: jQuery('input#post_ID').val(), nid:jQuery(this).attr('alt'), _wpnonce: jQuery('input#nxsSsPageWPN_wpnonce').val()}; callAjSNAP(data, '<?php echo $avNt['name']; ?>'); }); 
  63. <?php }  
  64. foreach ($nxs_snapAvNts as $avNt) {?> 
  65. jQuery('input#riTo<?php echo $avNt['code']; ?>_button').click(function() { var data = { action: 'rePostTo<?php echo $avNt['code']; ?>', id: jQuery('input#post_ID').val(), ri:1, nid:jQuery(this).attr('alt'), _wpnonce: jQuery('input#nxsSsPageWPN_wpnonce').val()}; callAjSNAP(data, '<?php echo $avNt['name']; ?>'); }); 
  66. <?php } ?> 
  67. function callAjSNAP(data, label) {  
  68. var style = "position: fixed; display: none; z-index: 1000; top: 50%; left: 50%; background-color: #E8E8E8; border: 1px solid #555; padding: 15px; width: 350px; min-height: 80px; margin-left: -175px; margin-top: -40px; text-align: center; vertical-align: middle;"; 
  69. jQuery('body').append("<div id='test_results' style='" + style + "'></div>"); 
  70. jQuery('#test_results').html("<p>Sending update to "+label+"</p>" + "<p><img src='<?php echo $nxs_plurl; ?>img/ajax-loader-med.gif' /></p>"); 
  71. jQuery('#test_results').show();  
  72. jQuery.post(ajaxurl, data, function(response) { if (response=='') response = 'Message Posted'; 
  73. jQuery('#test_results').html('<p> ' + response + '</p>' +'<input type="button" class="button" name="results_ok_button" id="results_ok_button" value="OK" />'); 
  74. jQuery('#results_ok_button').click(remove_results); 
  75. });  
  76. }  
  77. function remove_results() { jQuery("#results_ok_button").unbind("click");jQuery("#test_results").remove(); 
  78. if (typeof document.body.style.maxHeight == "undefined") { jQuery("body", "html").css({height: "auto", width: "auto"}); jQuery("html").css("overflow", "");} 
  79. document.onkeydown = "";document.onkeyup = ""; return false; 
  80. }); 
  81. </script>  
  82. <?php