PageSourceSearch

https://www.informaticashop.com.br/js/webforms/logic.js

js informaticashop.com.br collected 2026-09-26 06:05:03 UTC 6,588 bytes, 171 lines download raw bytes

1/* WebForms Logic */
2
3function JsWebFormsLogicRuleCheck(logic, uid) {
4    var flag = false;
5    var field = $$(GetFormContainerId(uid) + ' [name="field[' + logic["field_id"] + ']"]');
6    var field_type = 'select';
7    var selected = 'selected';
8    if (typeof(field[0]) != 'object') {
9        input = $$(GetFormContainerId(uid) + ' [name="field[' + logic['field_id'] + '][]"]');
10        field_type = 'checkbox';
11        selected = 'checked';
12    } else {
13        if (field[0].type == 'radio') {
14            field_type = 'radio';
15            input = field;
16            selected = 'checked';
17        }
18    }
19    var value;
20    if (field_type == 'select') {
21        var input = {'option': {'value': field[0].getValue(), selected: true}};
22    }
23    if (logic['aggregation'] == 'any' || (logic['aggregation'] == 'all' && logic['logic_condition'] == 'notequal')) {
24        if (logic['logic_condition'] == 'equal') {
25            for (var k in input) {
26                if (typeof(input[k]) == 'object' && input[k]) {
27                    if (input[k][selected]) {
28                        for (var j in logic['value']) {
29                            FieldIsVisible(logic["field_id"], uid) ? value = input[k].value : value = false;
30                            if (value == logic['value'][j]) flag = true;
31                        }
32                    }
33                }
34            }
35        } else {
36            flag = true;
37            var checked = false;
38            for (var k in logic['value']) {
39                for (var j in input) {
40                    if (typeof(input[j]) == 'object' && input[j])
41                        if (input[j][selected]) {
42                            checked = true;
43                            FieldIsVisible(logic["field_id"], uid) ? value = input[j].value : value = false;
44                            if (value == logic['value'][k])
45                                flag = false;
46                        }
47                }
48            }
49            if (!checked) flag = false;
50        }
51    } else {
52        flag = true;
53        for (var k in logic['value']) {
54            for (var j in input) {
55                if (typeof(input[j]) == 'object' && input[j])
56                    FieldIsVisible(logic["field_id"], uid) ? value = input[j].value : value = false;
57                if (!input[j][selected] && value == logic['value'][k])
58                    flag = false;
59            }
60        }
61    }
62    return flag;
63}
64
65function JsWebFormsLogicTargetCheck(target, logicRules, fieldMap, uid) {
66    if (typeof(target) != 'object') return false;
67    var flag = false;
68    for (var i in logicRules) {
69        if (typeof(logicRules[i]) == 'object')
70            for (var j in logicRules[i]['target']) {
71                if (typeof(target) == 'object')
72                    if (target["id"] == logicRules[i]['target'][j]) {
73                        if (JsWebFormsLogicRuleCheck(logicRules[i], uid)) {
74                            flag = true;
75                            var config = logicRules[i];
76                            break;
77                        }
78                    }
79
80            }
81    }
82    var initState = "none";
83    if (target["logic_visibility"] == 'visible')
84        initState = "block";
85    var changeState = "block";
86    var display = initState;
87    if (flag) {
88        if (config['action'] == "hide") {
89            changeState = "none";
90        }
91        display = changeState;
92    }
93    if ($(target["id"]) !== null && $(target["id"]).style !== undefined)
94        $(target["id"]).style.display = display;
95
96    if ($(target["id"] + '_row') !== null && $(target["id"] + '_row').style !== undefined)
97        $(target["id"] + '_row').style.display = display;
98
99    if (flag)
100        for (var i in logicRules) {
101            if (typeof(logicRules[i]) == 'object' && logicRules[i] != config)
102                if (typeof(target) == 'object')
103                    if (target["id"] == 'field_' + logicRules[i]['field_id'] || FieldInFieldset(logicRules[i]['field_id'], target["id"], fieldMap)) {
104                        for (var j in logicRules[i]['target']) {
105                            var visibility;
106                            if (logicRules[i]['action'] == 'show') visibility = 'hidden';
107                            if (logicRules[i]['action'] == 'hide') visibility = 'visible';
108                            if (typeof(logicRules[i]['target'][j]) == 'string') {
109                                var newTarget = {
110                                    'id': logicRules[i]['target'][j],
111                                    'logic_visibility': visibility
112                                };
113                                JsWebFormsLogicTargetCheck(newTarget, logicRules, fieldMap, uid);
114                            }
115                        }
116                    }
117        }
118
119    return flag;
120}
121
122function JSWebFormsLogic(targets, logicRules, fieldMap, uid) {
123    for (var n in logicRules) {
124        var config = logicRules[n];
125        if (typeof(config) == 'object') {
126            var input = $$(GetFormContainerId(uid) + ' [name="field[' + config["field_id"] + ']"]');
127            var trigger_function = 'onchange';
128            if (typeof(input[0]) != 'object') {
129                input = $$(GetFormContainerId(uid) + ' [name="field[' + config['field_id'] + '][]"]');
130                trigger_function = 'onclick';
131            } else {
132                if (input[0].type == 'radio') {
133                    trigger_function = 'onclick';
134                }
135            }
136            for (var i in input) {
137                if (trigger_function == 'onchange')
138                    input[i].onchange = function () {
139                        for (var k in targets)
140                            JsWebFormsLogicTargetCheck(targets[k], logicRules, fieldMap, uid);
141                    }
142                else
143                    input[i].onclick = function () {
144                        for (var k in targets)
145                            JsWebFormsLogicTargetCheck(targets[k], logicRules, fieldMap, uid);
146                    }
147            }
148        }
149    }
150}
151function GetFormContainerId(uid){
152    if(uid){
153        return '#webform_' + uid;
154    }
155    return '';
156}
157
158function FieldIsVisible(fieldId, uid) {
159    var el = $('field_' + uid + fieldId);
160    if (el !== null) {
161        if (el.offsetWidth == 0 || el.offsetWidth == undefined) return false;
162    } else {
163        return false;
164    }
165    return true;
166}
167
168function FieldInFieldset(fieldId, fieldsetId, fieldMap) {
169    if (typeof fieldsetId != 'number') return false;
170    return fieldMap['fieldset_' + fieldsetId].include(fieldId);
171}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.