SHARE
TWEET

CAPC Copy Dashboard

sweenig Jan 8th, 2014 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. function WeenigCopyDashboard(pageid, dashboardMenu, menuItem, dashboardTitle){
  3. //make sure the parameters are there
  4.         if (pageid==null || pageid==""){alert("PageID cannot be blank");return false;}
  5.         if (dashboardMenu==null || dashboardMenu==""){alert("Menu to Copy to cannot be blank");return false;}
  6.         if (menuItem==null || menuItem==""){alert("New Menu Title cannot be blank");return false;}
  7.         if (dashboardTitle==null || dashboardTitle==""){alert("New Dashboard Title cannot be blank");return false;}
  8.  
  9. //get the dashboard XML
  10.         var pageid = form_name.pageid.value;
  11.         var geturl = '/pc/center/webservice/dashboards/' + pageid;
  12.         if (window.XMLHttpRequest){xhttp = new XMLHttpRequest();} else {xhttp = new ActiveXObject("Microsoft.XMLHTTP");}
  13.         xhttp.open("GET", geturl, false);xhttp.send();
  14.         xmlDoc = xhttp.responseXML;
  15.  
  16. //change the dashboard XML
  17.         x = xmlDoc.getElementsByTagName("dashboardMenu")[0].childNodes[0];
  18.         x.nodeValue = dashboardMenu;
  19.         y = xmlDoc.getElementsByTagName("menuItem")[0].childNodes[0];
  20.         y.nodeValue = menuItem;
  21.         z = xmlDoc.getElementsByTagName("dashboardTitle")[0].childNodes[0];
  22.         z.nodeValue = dashboardTitle;
  23.  
  24. //post the new dashboard URL
  25.         var posturl = '/pc/center/webservice/dashboards/import';
  26.         xhttp.open("POST",url,true);
  27.         xhttp.setRequestHeader("Content-type", "application/xml");
  28.         xhttp.setRequestHeader("Content-length", xmlDoc.length);
  29.         xhttp.setRequestHeader("Connection", "close");
  30.         xhttp.send(xmlDoc);
  31. }
  32. </script>
  33. <table border=0><tr><td>Page ID of Dashboard to Copy:</td><td><input type="text" id="pageid"></td></tr>
  34. <tr><td>New Menu Title:</td><td><input type="text" id="menuItem"></td></tr>
  35. <tr><td>New Dashboard Title:</td><td><input type="text" id="dashboardTitle"></td></tr>
  36. <tr><td>Menu to Copy to:</td><td><input type="text" id="dashboardMenu"></td></tr>
  37. <tr><td></td><td style="text-align:right;"><input type="submit" value="Copy" onClick="WeenigCopyDashboard(document.getElementById('pageid').value,document.getElementById('menuItem').value,document.getElementById('dashboardTitle').value,document.getElementById('dashboardMenu').value;"></td></tr></table>
  38. <p style="font-size:x-small;"><a href="http://stuart.weenig.com">&copy; 2014 Stuart Weenig</a></p>
RAW Paste Data
Top