lpplandatescript.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*jslint white: true, browser: true, undef: true, nomen: true, eqeqeq: true, plusplus: false, bitwise: true, regexp: true, strict: true, newcap: true, immed: true, maxerr: 14 */
  2. /*global window: false, REDIPS: true */
  3. /* enable strict mode */
  4. "use strict";
  5. // define redips_init variable
  6. var redipsInit;
  7. // redips initialization
  8. redipsInit = function () {
  9. // reference to the REDIPS.drag library and message line
  10. var rd = REDIPS.drag,
  11. msg = document.getElementById('message');
  12. // how to display disabled elements
  13. rd.style.borderDisabled = 'solid'; // border style for disabled element will not be changed (default is dotted)
  14. rd.style.opacityDisabled = 60; // disabled elements will have opacity effect
  15. // initialization
  16. rd.init();
  17. // only "smile" can be placed to the marked cell
  18. rd.mark.exception.d8 = 'smile';
  19. // prepare handlers
  20. rd.event.clicked = function () {
  21. msg.innerHTML = 'Clicked';
  22. };
  23. rd.event.dblClicked = function () {
  24. msg.innerHTML = 'Dblclicked';
  25. };
  26. rd.event.moved = function () {
  27. msg.innerHTML = 'Moved';
  28. };
  29. rd.event.notMoved = function () {
  30. msg.innerHTML = 'Not moved';
  31. };
  32. rd.event.dropped = function () {
  33. var rdValue = rd.obj.childNodes[0].nodeValue;
  34. var pos = rd.getPosition();
  35. var rowData = $("#list").jqGrid("getRowData",pos[1]);
  36. $.ajax({
  37. async: false,
  38. type: 'POST',
  39. data: "selId="+rowData.ID+"&selTimes="+rowData.selTimes+"&rdValue="+rdValue,
  40. dataType:'json', //返回类型json
  41. url: "gettimesfeedp.html",
  42. error: function(){alert("系统错误");},
  43. success: function(json){
  44. if(json.status == "success"){
  45. if(json.fcount > 0){
  46. alert("栏舍【"+rdValue+"】在当前班次中已经存在!");
  47. $("#list").setCell(pos[1],pos[2]," ");
  48. }
  49. }
  50. }
  51. });
  52. msg.innerHTML = 'Dropped';
  53. };
  54. rd.event.switched = function () {
  55. msg.innerHTML = 'Switched';
  56. };
  57. rd.event.clonedEnd1 = function () {
  58. msg.innerHTML = 'Cloned end1';
  59. };
  60. rd.event.clonedEnd2 = function () {
  61. msg.innerHTML = 'Cloned end2';
  62. };
  63. rd.event.notCloned = function () {
  64. msg.innerHTML = 'Not cloned';
  65. };
  66. rd.event.deleted = function (cloned) {
  67. // if cloned element is directly moved to the trash
  68. if (cloned) {
  69. // set id of original element (read from redips property)
  70. // var id_original = rd.obj.redips.id_original;
  71. msg.innerHTML = 'Deleted (c)';
  72. }
  73. else {
  74. msg.innerHTML = 'Deleted';
  75. }
  76. };
  77. rd.event.undeleted = function () {
  78. msg.innerHTML = 'Undeleted';
  79. };
  80. rd.event.cloned = function () {
  81. // display message
  82. msg.innerHTML = 'Cloned';
  83. // append 'd' to the element text (Clone -> Cloned)
  84. rd.obj.innerHTML += 'd';
  85. };
  86. rd.event.changed = function () {
  87. // get target and source position (method returns positions as array)
  88. var pos = rd.getPosition();
  89. // display current row and current cell
  90. msg.innerHTML = 'Changed: ' + pos[1] + ' ' + pos[2];
  91. };
  92. };
  93. // toggles trash_ask parameter defined at the top
  94. function toggleConfirm(chk) {
  95. if (chk.checked === true) {
  96. REDIPS.drag.trash.question = 'Are you sure you want to delete DIV element?';
  97. }
  98. else {
  99. REDIPS.drag.trash.question = null;
  100. }
  101. }
  102. // toggles delete_cloned parameter defined at the top
  103. function toggleDeleteCloned(chk) {
  104. REDIPS.drag.clone.drop = !chk.checked;
  105. }
  106. // enables / disables dragging
  107. function toggleDragging(chk) {
  108. REDIPS.drag.enableDrag(chk.checked);
  109. }
  110. // function sets drop_option parameter defined at the top
  111. function setMode(radioButton) {
  112. REDIPS.drag.dropMode = radioButton.value;
  113. }
  114. // show prepared content for saving
  115. function save(type) {
  116. // define table_content variable
  117. var table_content;
  118. // prepare table content of first table in JSON format or as plain query string (depends on value of "type" variable)
  119. table_content = REDIPS.drag.saveContent('table1', type);
  120. // if content doesn't exist
  121. if (!table_content) {
  122. alert('Table is empty!');
  123. }
  124. // display query string
  125. else if (type === 'json') {
  126. //window.open('/my/multiple-parameters-json.php?p=' + table_content, 'Mypop', 'width=350,height=260,scrollbars=yes');
  127. window.open('multiple-parameters-json.php?p=' + table_content, 'Mypop', 'width=350,height=260,scrollbars=yes');
  128. }
  129. else {
  130. //window.open('/my/multiple-parameters.php?' + table_content, 'Mypop', 'width=350,height=160,scrollbars=yes');
  131. window.open('multiple-parameters.php?' + table_content, 'Mypop', 'width=350,height=260,scrollbars=yes');
  132. }
  133. }
  134. // add onload event listener
  135. if (window.addEventListener) {
  136. window.addEventListener('load', redipsInit, false);
  137. }
  138. else if (window.attachEvent) {
  139. window.attachEvent('onload', redipsInit);
  140. }