Qualtrics:Show All Questions

Show All Questions on Qualtrics (use in edit mode of survey)

当前为 2014-08-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Qualtrics:Show All Questions
  3. // @description Show All Questions on Qualtrics (use in edit mode of survey)
  4. // @include https://s.qualtrics.com/ControlPanel/*Edit*
  5. // @grant none
  6. // @version 0.0.1.20140807214620
  7. // @namespace https://greasyfork.org/users/4252
  8. // ==/UserScript==
  9. //Note: Only been tested in firefox
  10. function OutputQuestions() {
  11.  
  12. Questions = document.getElementsByClassName("QuestionText");
  13.  
  14. var output;
  15. output = ' <button id="button" type="button" onclick="ShowHideNAN()">Show/Hide Questions without numbers</button>';
  16. output += '<table border="1">';
  17. for (i = 0; i < Questions.length; i++) {
  18. if (!document.getElementById("TrashArea").contains(Questions[i])) //don't include questions in trash (section at end)
  19. {
  20. if (!isNaN(Questions[i].textContent.trim().substr(0, 1))) { //if it starts with a number then show automatically (and ignore whitespace and html)
  21. output += "<tr><td>" + Questions[i].innerHTML + "</td></tr>";
  22. } else //if it doesnt start with a number then hide it
  23. {
  24. output += '<tr class="hidden"><td>' + Questions[i].innerHTML + '</td></tr>';
  25. }
  26. }
  27. }
  28. output += "</table>";
  29.  
  30.  
  31. var myWindow = window.open("", "_blank", "scrollbars=yes, menubar=yes");
  32.  
  33. var newStyle = document.createElement('style');
  34. newStyle.innerHTML = ".hidden{ display:none;}";
  35. myWindow.document.head.appendChild(newStyle);
  36.  
  37. var newScript = document.createElement('script');
  38. newScript.type = 'text/javascript';
  39. newScript.innerHTML = 'function ShowHideNAN() { rule = document.styleSheets[0].cssRules[0]; if (rule.style.display == "none") rule.style.display = "inline"; else rule.style.display = "none"; }';
  40. myWindow.document.head.appendChild(newScript);
  41.  
  42. myWindow.document.body.innerHTML = output;
  43. }
  44.  
  45. window.addEventListener('load', WindowLoadedOQ, false);
  46.  
  47. function WindowLoadedOQ() {
  48.  
  49. if (document.getElementsByClassName("EditSection")[1].classList[0] == "active") //if on edit tab
  50. {
  51. var OutputQuestionsButton = document.createElement('a');
  52. OutputQuestionsButton.id = "OutputQuestionsButton";
  53. document.getElementById("StatusBarLeftContainer").appendChild(OutputQuestionsButton);
  54. ReadyButton();
  55. }
  56. }
  57.  
  58. function ReadyButton() {
  59.  
  60. OutputQuestionsButton = document.getElementById("OutputQuestionsButton");
  61. OutputQuestionsButton.innerHTML = "Output Questions";
  62. OutputQuestionsButton.className = "toggleButton";
  63. OutputQuestionsButton.onclick = OutputQuestions;
  64. }