You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
3.1 KiB

  1. /*
  2. GNU Liscense - Pau and Arnau
  3. usage:
  4. ------------------------------------------
  5. function SetValueToVar(arrayreturned){
  6. object.arrayofvalues=arrayreturned;
  7. }
  8. mPrompt(parametersQuantity, promptTitle, promptDescription, arrayparametersnames, originalValues, SetValueToVar);
  9. ------------------------------------------
  10. parametersQuantity: how many parameters will the mPrompt ask for
  11. promptTitle: main title for the mPrompt
  12. promptDescription: description for the mPrompt
  13. arrayparametersnames: an array with the name of the parameters. If send empty (""), it will display 'parameter'
  14. originalValues: original values of the parameters, inside an array, if no values, send empty string ("")
  15. SetValueToVar: function declared to set the values to the variable. Puts the values into an array
  16. */
  17. function mPrompt(quantity, procname, description, arrayparametersnames, returnplace, funcgiv){
  18. if(document.getElementById('idprompt')==null)
  19. {
  20. var bgpanel = document.createElement('div');
  21. arraycontent=returnplace;
  22. bgpanel.id = 'idbgpanel';
  23. bgpanel.className = 'backgroundpanel';
  24. document.getElementsByTagName('body')[0].appendChild(bgpanel);
  25. prompt = document.createElement('div');
  26. prompt.id = 'idprompt';
  27. prompt.className = 'caixaPrompt';
  28. prompt.quantity=quantity;
  29. prompt.descr=description;
  30. document.getElementsByTagName('body')[0].appendChild(prompt);
  31. cont="";
  32. cont+="<div class='Xshortcutbox' onclick='ClosemPrompt();'><b>X</b></div>";
  33. cont+="<b>"+procname+" parameters</b><hr>";
  34. cont+="<p>" + description +"</p>";
  35. for(var i=0; i<quantity; i++)
  36. {
  37. if(arrayparametersnames=="")
  38. {
  39. arrayparametersnames=["parameter"];
  40. for(ipar=0; ipar<quantity-1; ipar++)
  41. {
  42. arrayparametersnames.push("parameter");
  43. }
  44. }
  45. if(arraycontent=="")
  46. {
  47. arraycontent=[""];
  48. for(ipar=0; ipar<quantity-1; ipar++)
  49. {
  50. arraycontent.push("");
  51. }
  52. }
  53. cont+= arrayparametersnames[i] + ": <input type='text' name='fname' id='input"+i+"' value='" + arraycontent[i] + "'><br>";
  54. }
  55. cont+="<div class='submitbtn' onclick='SubmitmPrompt("+funcgiv+")'>OK</div>";
  56. idprompt.innerHTML= cont;
  57. jsPlumb.ready(function() {
  58. jsPlumb.draggable("idprompt", {
  59. });
  60. });
  61. }
  62. }
  63. function SubmitmPrompt(afuncgiv){
  64. prompt=document.getElementById('idprompt');
  65. var arrayresponse="";
  66. arrayresponse=[document.getElementById("input"+0).value];
  67. for(var i=1; i<prompt.quantity; i++)
  68. {
  69. arrayresponse.push(document.getElementById("input"+i).value);
  70. }
  71. afuncgiv(arrayresponse);
  72. ClosemPrompt();
  73. }
  74. function ClosemPrompt(){
  75. returned= RemoveById('idprompt');
  76. returned= RemoveById('idbgpanel');
  77. }
  78. function RemoveById(id) {
  79. return (elem=document.getElementById(id)).parentNode.removeChild(elem);
  80. }