Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 2502 | Rev 2504 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 2502 Rev 2503
Línea 61... Línea 61...
61
$this->headStyle()->captureEnd();
61
$this->headStyle()->captureEnd();
Línea 62... Línea 62...
62
 
62
 
63
$this->inlineScript()->captureStart();
63
$this->inlineScript()->captureStart();
Línea -... Línea 64...
-
 
64
echo <<<JS
-
 
65
 
-
 
66
const classFormGenerator = function() {
-
 
67
    this.id = 0,
-
 
68
        this.table = '',
-
 
69
        this.name = '',
-
 
70
        this.text = '',
-
 
71
        this.status = 'a',
-
 
72
        this.sections = [],
-
 
73
        this.clear = function() {
-
 
74
            this.sections = [];
-
 
75
            this.render();
-
 
76
        },
-
 
77
       
-
 
78
        /**
-
 
79
         * Add element to section array
-
 
80
         */
-
 
81
        this.addSection = function(name, text, value) {
-
 
82
            var d = new Date();
-
 
83
            var slug = 'section' + d.getTime();
-
 
84
            var position = 0;
-
 
85
            $.each(this.sections, function(index, section) {
-
 
86
                if (position < section.position) {
-
 
87
                    position = section.position;
-
 
88
                }
-
 
89
            });
-
 
90
            position++;
-
 
91
            var section = {
-
 
92
                'slug_section': slug,
-
 
93
                'name': name,
-
 
94
                'text': text,
-
 
95
                'value': value,
-
 
96
                'position': position,
-
 
97
                'questions': [],
-
 
98
                'status': 0
-
 
99
            }
-
 
100
            this.sections.push(section);
-
 
101
        },
-
 
102
         /**
-
 
103
         * Edit element to section array
-
 
104
         */
-
 
105
        this.editSection = function(slug, name, text, value) {
-
 
106
            var renderTable = false;
-
 
107
            for (i = 0; i < this.sections.length; i++) {
-
 
108
                if (slug == this.sections[i].slug_section) {
-
 
109
                    this.sections[i].name = name;
-
 
110
                    this.sections[i].text = text;
-
 
111
                    this.sections[i].value = value;
-
 
112
                    renderTable = true;
-
 
113
                    break;
-
 
114
                }
-
 
115
            }
-
 
116
            if (renderTable) {
-
 
117
                this.renderSection(slug);
-
 
118
            }
-
 
119
        },
-
 
120
         /**
-
 
121
         * Remove element to section array
-
 
122
         */
-
 
123
        this.deleteSection = function(slug) {
-
 
124
            var renderTable = false;
-
 
125
            for (i = 0; i < this.sections.length; i++) {
-
 
126
                if (slug == this.sections[i].slug_section) {
-
 
127
                    this.sections.splice(i, 1);
-
 
128
                    renderTable = true;
-
 
129
                    break;
-
 
130
                }
-
 
131
            }
-
 
132
            if (renderTable) {
-
 
133
                $('#panel' + slug).remove();
-
 
134
            }
-
 
135
        }        
64
echo <<<JS
136
}
65
 
137
 
66
    function htmlEntities(str) {
138
    function htmlEntities(str) {
Línea 67... Línea 139...
67
        return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
139
        return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');