4 * Copyright 2014,2016, Franck Villaume - TrivialDev
5 * http://fusionforge.org
7 * This file is part of FusionForge. FusionForge is free software;
8 * you can redistribute it and/or modify it under the terms of the
9 * GNU General Public License as published by the Free Software
10 * Foundation; either version 2 of the Licence, or (at your option)
13 * FusionForge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 FRSController = function() {};
25 FRSController.prototype =
27 toggleConfirmBox: function(params) {
29 jQuery('#'+this.params.idconfirmbox).dialog({
31 height: this.params.height,
32 width: this.params.width,
36 click: jQuery.proxy(function() {
37 jQuery('#'+this.params.idconfirmbox).dialog('close');
38 jQuery.getJSON(this.params.action+'&sure=1&really_sure=1', jQuery.proxy(function(data) {
39 jQuery('#maindiv > .feedback').remove();
40 jQuery('#maindiv > .error').remove();
41 jQuery('#maindiv > .warning_msg').remove();
42 if (data.format == 'multi') {
43 var arrayLength = Object.keys(data).length;
44 for (var i = 0; i < arrayLength; i++) {
45 if (typeof data[i].html != 'undefined') {
46 jQuery('#maindiv').prepend(data[i].html);
48 if (typeof data[i].deletedom != 'undefined') {
49 jQuery('#'+data[i].deletedom).remove();
53 if (typeof data.html != 'undefined') {
54 jQuery('#maindiv').prepend(data.html);
56 if (typeof data.deletedom != 'undefined') {
57 jQuery('#'+data.deletedom).remove();
64 text: this.params.cancel,
65 click: function() { jQuery(this).dialog('close'); }
70 doAction: function(params) {
72 jQuery.getJSON(this.params.action, jQuery.proxy(function(data){
73 jQuery('#maindiv > .feedback').remove();
74 jQuery('#maindiv > .error').remove();
75 jQuery('#maindiv > .warning_msg').remove();
76 if (data.format == 'multi') {
77 var arrayLength = Object.keys(data).length;
78 for (var i = 0; i < arrayLength; i++) {
79 if (typeof data[i].html != 'undefined') {
80 jQuery('#maindiv').prepend(data[i].html);
82 if (typeof data[i].action != 'undefined') {
83 jQuery('#'+this.params.id).attr(data[i].property, data[i].action);
85 if (typeof data[i].img != 'undefined') {
86 jQuery('#'+this.params.id+' img').remove();
87 jQuery('#'+this.params.id).append(data[i].img);
91 if (typeof data.html != 'undefined') {
92 jQuery('#maindiv').prepend(data.html);
94 if (typeof data.action != 'undefined') {
95 jQuery('#'+this.params.id).attr(data.property, data.action);
97 if (typeof data.img != 'undefined') {
98 jQuery('#'+this.params.id+' img').remove();
99 jQuery('#'+this.params.id).append(data.img);
105 updatePackage: function(params) {
106 this.params = params;
107 var td = jQuery(this.params.rowid).children();
108 var select = jQuery(td[3].children).children();
109 jQuery.getJSON(this.params.action, {package_name: td[1].children.package_name.value, notes: td[2].children.notes.value, status_id: select[0].value }, function(data){
110 jQuery('#maindiv > .feedback').remove();
111 jQuery('#maindiv > .error').remove();
112 jQuery('#maindiv > .warning_msg').remove();
113 if (typeof data.html != 'undefined') {
114 jQuery('#maindiv').prepend(data.html);
119 /*! build list of id, comma separated
121 buildUrlByCheckbox: function(id) {
122 var CheckedBoxes = new Array();
123 for (var h = 0; h < jQuery('input:checked').length; h++) {
124 if (typeof(jQuery('input:checked')[h].className) != 'undefined' && jQuery('input:checked')[h].className.match('checkedrelid'+id)) {
125 CheckedBoxes.push(jQuery('input:checked')[h].value);
131 checkAll: function(id, type) {
132 if (jQuery('#checkall'+type).is(':checked')) {
133 jQuery('.'+id).each(function() {
134 jQuery(this).prop('checked', true);
136 jQuery('#massaction'+type).show();
138 jQuery('.'+id).each(function() {
139 jQuery(this).prop('checked', false);
141 jQuery('#massaction'+type).hide();
145 checkgeneral: function(id) {
146 if (jQuery(this).attr('checked', false)) {
147 jQuery('#checkall'+id).prop('checked', false);
148 jQuery('#massaction'+id).hide();
150 for (var h = 0; h < jQuery('input:checked').length; h++) {
151 if (typeof(jQuery('input:checked')[h].className) != 'undefined' && jQuery('input:checked')[h].className.match('checkedrelid'+id)) {
152 jQuery('#massaction'+id).show();