Guest User

Untitled

a guest
Oct 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. <apex:page controller="ChangesetCheckerController">
  2.  
  3. <head>
  4. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  5. </head>
  6. <html>
  7. <h3> Enter Change Set URL below</h3>
  8. <div id="paraContainer" style="display:none">
  9. <p id="para">
  10. Checking on the changeset. Please wait...
  11. </p>
  12. </div>
  13. <form>
  14. <input id="urlInput" />
  15. <input id="submitbtn" type="button" value="Check Now" />
  16. </form>
  17. <script type="text/javascript">
  18. $("#submitbtn").click(function() {
  19. $("#paraContainer").css("display", "inline");
  20. checkChg();
  21. });
  22.  
  23. function checkChg()
  24. {
  25. var newURL = $("#urlInput").val();
  26. try
  27. {
  28. Visualforce.remoting.Manager.invokeAction
  29. (
  30. '{!$RemoteAction.ChangesetCheckerController.checkChg}',
  31. newURL,
  32. function(result, event)
  33. {
  34. var foundin = '';
  35. if (event.status)
  36. {
  37. console.log('success');
  38. console.log(result);
  39. $("#para").html(result);
  40. foundin = $('p:contains("Change Set Unavailable")');
  41. if (result == '')
  42. {
  43. check();
  44. }
  45. else if (foundin.length == 0)
  46. {
  47. foundin = $('p:contains("PackageUnavailableException")');
  48. if (foundin.length == 0)
  49. {
  50. $("#para").empty();
  51. alert('Change Set Ready');
  52. window.open(newURL, "_blank");
  53. }
  54. else
  55. {
  56. check();
  57. }
  58. }
  59. }
  60. else if (event.type === 'exception')
  61. {
  62. console.log(event.message + " " + event.where);
  63. }
  64. else
  65. {
  66. console.log(event.message);
  67. }
  68. },
  69. {
  70. escape: true
  71. }
  72. );
  73. }
  74. catch (err)
  75. {
  76. check();
  77. }
  78. }
  79. function check()
  80. {
  81. $("#para").text("Will check in 2 seconds again.. waiting..");
  82. setTimeout(function() {
  83. $("#para").text("Checking on the changeset. Please wait...");
  84. checkChg();
  85. }, 2000);
  86. }
  87. </script>
  88.  
  89. </html>
  90.  
  91. public class ChangesetCheckerController
  92. {
  93. @RemoteAction
  94. public static String checkChg(String url)
  95. {
  96. String html = '';
  97. try
  98. {
  99. PageReference page = new PageReference(url);
  100. Blob b = page.getContent();
  101. html = String.valueof(b);
  102. system.debug(html);
  103. }
  104. catch(Exception e)
  105. {
  106. }
  107. return html;
  108. }
  109. }
Add Comment
Please, Sign In to add comment