How to use uncheck method in Cypress

Best JavaScript code snippet using cypress

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

unCheckList2.py

Source: unCheckList2.py Github

copy
1#!/usr/bin/python
2# -*- coding: UTF-8 -*-
3from __future__ import print_function
4import codecs
5import sys
6import time
7import datetime
8import os
9
10
11def read_chinese_file(filepath):
12    f = open(filepath, 'r')
13    lines = [line.strip() for line in f]
14    for index, ch in enumerate(lines):
15        lines[index] = str(ch)
16    f.close()
17    return lines
18
19
20def Findaite(message):
21    i = 0
22    for charater in message:
23        if charater == '@':
24            return i
25        i = i+1
26
27
28f = open('Check-inlist.txt', encoding='UTF-8')
29check_in_list = [line.strip() for line in f]
30for index, ch in enumerate(check_in_list):
31    check_in_list[index] = str(ch)
32f.close()
33
34# 将当天打卡名单复制到testfile.txt中,读入该文件到checked_names
35daka_f = open('testfile.txt', encoding='UTF-8')
36checked_names = [line.strip() for line in daka_f]
37
38
39for index, ch in enumerate(checked_names):
40    checked_names[index] = str(ch)
41uncheck_list = []
42
43
44for name in check_in_list:
45    # 移除开头
46    extract_name = name
47    for index, ch in enumerate(name):
48        if ch == "@":
49            extract_name = name[index+1:]
50            break
51
52    # 移除末尾空格
53    while len(extract_name) > 1 and extract_name[-1] == " ":
54        extract_name = extract_name[:-2]
55
56    found = False
57    for checked_name in checked_names:
58        if extract_name in checked_name:
59            found = True
60            break
61    if found == False:
62        uncheck_list.append(name)
63
64notification = "滴滴滴打卡提示!现在是北京时间:"
65output = ",请以下未完成打卡的姑娘尽量完成打卡哦"
66print("\n\n"+notification+time.strftime(
67    "%Y-%m-%d %H:%M:%S", time.localtime())+output)
68
69for index, uncheck_name in enumerate(uncheck_list):
70    i = Findaite(uncheck_name)
71    uncheck_list[index] = uncheck_name[i+1:]
72    print('@'+uncheck_list[index])
73
74# new here
75# 写入当天打卡记录,判断时间是否早于当天十二点,如果早于,则是前一天的打卡
76end_check_time = datetime.datetime.strptime(
77    str(datetime.datetime.now().date())+'12:00', '%Y-%m-%d%H:%M')
78
79time_now = datetime.datetime.now()
80
81if time_now < end_check_time:
82    check_day = time_now - \
83        datetime.timedelta(days=1).strftime('%Y-%m-%d')
84else:
85    check_day = time_now.strftime('%Y-%m-%d')
86
87check_log_f = open('log/'+check_day + ' checked.txt', 'w')
88for checked_name in checked_names:
89    check_log_f.write(checked_name)  # .encode('utf-8')
90    check_log_f.write('\n')
91check_log_f.close()
92
93uncheck_log_f = open('log/'+check_day + ' unchecked.txt', 'w')
94for uncheck_name in uncheck_list:
95    uncheck_log_f.write(uncheck_name)  # .encode('utf-8')
96    uncheck_log_f.write('\n')
97uncheck_log_f.close()
98
99# 输出未打卡历史记录
100uncheck_dict = {}
101path = os.getcwd()+'/log'
102files = os.listdir(path)
103for file in files:
104    if 'unchecked' in file:
105        names = read_chinese_file(path + '/' + file)
106        for name in names:
107            if name in uncheck_dict:
108                uncheck_dict[name] = uncheck_dict[name] + 1
109            else:
110                uncheck_dict[name] = 1
111
112# 按未打卡次数排序
113uncheck_thre = len(files) / 4 + 1
114sorted_pairs = sorted(uncheck_dict.items(), key=lambda kv: kv[1])
115print('\n'+"多次未打卡名单")
116for pair in sorted_pairs:
117    if pair[1] >= uncheck_thre:
118        print(pair[0], end=' ')
119        print(pair[1], end='')
120        print("次")
121
Full Screen

unCheckList.py

Source: unCheckList.py Github

copy
1#!/usr/bin/python
2# -*- coding: UTF-8 -*-
3from __future__ import print_function
4import codecs
5import sys
6import time
7import datetime
8import os
9from datetime import timedelta, datetime
10
11
12def read_chinese_file(filepath):
13    f = open(filepath, 'r')
14    lines = [line.strip() for line in f]
15    for index, ch in enumerate(lines):
16        lines[index] = str(ch).decode('utf-8')
17    f.close()
18    return lines
19
20
21check_in_list = read_chinese_file('Check-inlist.txt')
22
23checked_names = sys.stdin.readlines()
24for index, ch in enumerate(checked_names):
25    checked_names[index] = str(ch).decode('utf-8')
26
27uncheck_list = []
28for name in check_in_list:
29    # 移除开头
30    extract_name = name
31    for index, ch in enumerate(name):
32        if ch == " ":
33            extract_name = name[index+1:]
34            break
35
36    # 移除末尾空格
37    while len(extract_name) > 1 and extract_name[-1] == " ":
38        extract_name = extract_name[:-2]
39
40    found = False
41    for checked_name in checked_names:
42        if extract_name in checked_name:
43            found = True
44            break
45    if found == False:
46        uncheck_list.append(extract_name)
47
48notification = "滴滴滴打卡提示!现在是北京时间:"
49output = ",请以下未完成打卡的姑娘尽量完成打卡哦"
50print("\n\n"+notification.decode('utf-8')+time.strftime(
51    "%Y-%m-%d %H:%M:%S", time.localtime())+output.decode('utf-8'))
52
53for uncheck_name in uncheck_list:
54    print('@'+uncheck_name)
55
56# 写入当天打卡记录,判断时间是否早于当天下午四点,如果早于,则是前一天的打卡
57end_check_time = datetime.strptime(
58    str(datetime.now().date())+'16:00', '%Y-%m-%d%H:%M')
59
60time_now = datetime.now()
61
62if time_now < end_check_time:
63    check_day = (datetime.today() + timedelta(-1)).strftime('%Y-%m-%d')
64else:
65    check_day = time_now.strftime('%Y-%m-%d')
66
67check_log_f = open('log/'+check_day + ' checked.txt', 'w')
68for checked_name in checked_names:
69    check_log_f.write(checked_name.encode('utf-8'))
70check_log_f.close()
71
72uncheck_log_f = open('log/'+check_day + ' unchecked.txt', 'w')
73for uncheck_name in uncheck_list:
74    uncheck_log_f.write(uncheck_name.encode('utf-8'))
75    uncheck_log_f.write('\n')
76uncheck_log_f.close()
77
78# 输出未打卡历史记录
79uncheck_dict = {}
80path = os.getcwd()+'/log'
81files = os.listdir(path)
82for file in files:
83    if 'unchecked' in file:
84        names = read_chinese_file(path + '/' + file)
85        for name in names:
86            if name in uncheck_dict:
87                uncheck_dict[name] = uncheck_dict[name] + 1
88            else:
89                uncheck_dict[name] = 1
90
91# 按未打卡次数排序
92uncheck_thre = len(files)/4 + 1
93sorted_pairs = sorted(uncheck_dict.items(), key=lambda kv: kv[1])
94print('\n'+"多次未打卡名单".decode('utf-8'))
95for pair in sorted_pairs:
96    if pair[1] >= uncheck_thre:
97        print(pair[0], end=' ')
98        print(pair[1], end='')
99        print("次".decode('utf-8'))
100
Full Screen

compare.py

Source: compare.py Github

copy
1#!/usr/bin/env python
2# -*- encoding: utf-8 -*-
3'''
4@File    :   compare.py
5@Author  :   Billy Zhou
6@Time    :   2021/08/22
7@Desc    :   None
8'''
9
10
11import sys
12from pathlib import Path
13cwdPath = Path(__file__).parents[2]
14sys.path.append(str(cwdPath))
15
16from src.manager.Logger import logger
17log = logger.get_logger(__name__)
18
19import copy
20from collections.abc import Mapping
21from src.basic.input_check import input_checking_YN
22
23
24def dict_compare(
25        dict_uncheck: dict, dict_refer: dict,
26        dict_checked: dict = {}, suffix: str = '[]', lv: int = 0, diff_autoadd=True):
27    """Compare two dict and merge the missing part."""
28    if not dict_checked:
29        log.debug('dict_checked init')
30        dict_checked = copy.deepcopy(dict_uncheck)
31    sub_lv = lv + 1
32    suffix = '[]' if lv == 0 else suffix
33    if not dict_uncheck:
34        # missing part
35        if diff_autoadd:
36            dict_checked = dict_refer
37        else:
38            selection = input_checking_YN('dict_uncheck is blank. Fill it with dict_refer?')
39            if selection == 'Y':
40                print('Filled.')
41                dict_checked = dict_refer
42            else:
43                print('Canceled.')
44    else:
45        log.debug('dict_checked: {0}'.format(dict_checked))
46        # diff with dict_refer base on dict_refer.items()
47        for key, value_refer in dict_refer.items():
48            suffix_ = "[" + str(key) + "]"
49            log.debug("sub_lv: %s", sub_lv)
50            log.debug("suffix: %s", suffix)
51            log.debug("suffix_: %s", suffix_)
52            if not dict_uncheck.get(key):
53                # dict_uncheck missing part in dict_refer
54                if diff_autoadd:
55                    dict_checked[key] = dict_refer[key]
56                else:
57                    sub_suffix = suffix + suffix_ if suffix != '[]' else suffix_
58                    tip_words = 'dict_uncheck{0} is missing. Add it with dict_refer{0}?'.format(sub_suffix)
59                    selection = input_checking_YN(tip_words)
60                    if selection == 'Y':
61                        print('Added.')
62                        dict_checked[key] = dict_refer[key]
63                    else:
64                        print('Canceled.')
65            else:
66                sub_suffix = suffix + suffix_ if suffix != '[]' else suffix_
67                if isinstance(value_refer, Mapping):
68                    # check deeper for dict type of value_refer
69                    # value_refer equal to dict_refer[key]
70                    log.debug("sub_suffix: %s", sub_suffix)
71                    dict_compare(
72                        dict_uncheck[key], value_refer, dict_checked[key],
73                        sub_suffix, sub_lv, diff_autoadd)
74                else:
75                    # check diff part of values between dict_uncheck and dict_refer
76                    if str(dict_uncheck[key]) != str(dict_refer[key]):
77                        print('Values diff between dict_uncheck{0} and dict_refer{0}.'.format(sub_suffix))
78                        print('Value of dict_uncheck{0}: {1}'.format(sub_suffix, dict_uncheck[key]))
79                        print('Value of dict_refer{0}: {1}'.format(sub_suffix, value_refer))
80                        tip_words = 'Replace the value of dict_uncheck{0} with dict_refer{0}?'.format(sub_suffix)
81                        selection = input_checking_YN(tip_words)
82                        if selection == 'Y':
83                            print('Replaced.')
84                            dict_checked[key] = dict_refer[key]
85                        else:
86                            print('Canceled.')
87    return dict_checked
88
89
90if __name__ == '__main__':
91    d1 = {
92        1: {
93            2: {
94                7: [9]
95            },
96            6: [7, 8]
97        },
98        4: [7, 8]
99    }
100    d2 = {
101        1: {
102            2: {
103                9: [10]
104            },
105            3: [7, 8]
106        },
107        2: {
108            1: {},
109        },
110        3: [7, 8],
111        4: [5, 6],
112    }
113
114    print(dict_compare(d1, d2, diff_autoadd=False))
115    print("d1: {0}".format(d1))
116    print("d2: {0}".format(d2))
117
Full Screen

jquery.treecheckbox.js

Source: jquery.treecheckbox.js Github

copy
1/*!
2 * Tree - jQuery Tree Widget - checkbox component
3 * @author Valerio Galano <[email protected]>
4 */
5$.widget("daredevel.treecheckbox", {
6
7    /**
8     * Check if all descendant of passed node are checked
9     *
10     * @private
11     * @param li node
12     * @return true if all descendant checked
13     */
14    _allDescendantChecked:function (li) {
15        return (li.find('li input:checkbox:not(:checked)').length == 0);
16    },
17
18    /**
19     * Check ancestors on passed node
20     *
21     * Don't use check() method because we won't trigger onCheck events
22     *
23     * @private
24     * @param li node
25     */
26    _checkAncestors:function (li) {
27        li.parentsUntil(this.options.core.widgetBaseClass).filter('li').find('input:checkbox:first:not(:checked)').prop('checked', true).change();
28    },
29
30    /**
31     * Check descendants on passed node
32     *
33     * Don't use check() method because we won't trigger onCheck events
34     *
35     * @private
36     * @param li node
37     */
38    _checkDescendants:function (li) {
39        li.find('li input:checkbox:not(:checked)').prop('checked', true).change();
40    },
41
42    /**
43     * Check nodes that are neither ancestors or descendants of passed node
44     *
45     * Don't use check() method because we won't trigger onCheck events
46     *
47     * @private
48     * @param li node
49     */
50    _checkOthers:function (li) {
51        var t = this;
52        li.addClass('exclude');
53        li.parents('li').addClass('exclude');
54        li.find('li').addClass('exclude');
55        $(this.element).find('li').each(function () {
56            if (!$(this).hasClass('exclude')) {
57                $(this).find('input:checkbox:first:not(:checked)').prop('checked', true).change();
58            }
59        });
60        $(this.element).find('li').removeClass('exclude');
61    },
62
63    /**
64     * Initialize plugin.
65     *
66     * @private
67     */
68    _createCheckbox:function () {
69
70        var t = this;
71
72        // bind node uncheck event
73        this.element.find('input:checkbox:not(:checked)').live('click', function () {
74            t.uncheck(t.options.core.parentNode($(this)));
75        });
76
77        // bind node check event
78        this.element.find('input:checkbox:checked').live('click', function () {
79            t.check(t.options.core.parentNode($(this)));
80        });
81
82        // bind collapse on uncheck event
83        if (this.options.onUncheck.node == 'collapse') {
84            this.element.find('input:checkbox:not(:checked)').live("click", function () {
85                t.options.core.collapse(t.options.core.parentNode($(this)));
86            });
87        } else
88
89        // bind expand on uncheck event
90        if (this.options.onUncheck.node == 'expand') {
91            this.element.find('input:checkbox:not(:checked)').live("click", function () {
92                t.options.core.expand(t.options.core.parentNode($(this)));
93            });
94        }
95
96        // bind collapse on check event
97        if (this.options.onCheck.node == 'collapse') {
98            this.element.find('input:checkbox:checked').live("click", function () {
99                t.options.core.collapse(t.options.core.parentNode($(this)));
100            });
101        } else
102
103        // bind expand on check event
104        if (this.options.onCheck.node == 'expand') {
105            this.element.find('input:checkbox:checked').live("click", function () {
106                t.options.core.expand(t.options.core.parentNode($(this)));
107            });
108        }
109
110        // add public methods to core component
111        this.options.core.check = function (li) {
112            t.check(li);
113        };
114        this.options.core.checkAll = function () {
115            t.checkAll();
116        };
117        this.options.core.uncheck = function (li) {
118            t.uncheck(li);
119        };
120        this.options.core.uncheckAll = function () {
121            t.uncheckAll();
122        };
123
124        // add private methods to core component
125        this.options.core._treecheckboxInitializeNode = function (li) {
126            t._initializeNode(li);
127        };
128    },
129
130    /**
131     * Initialize passed node
132     *
133     * @private
134     * @param li node to initialize
135     */
136    _initializeCheckboxNode:function (li) {
137
138    },
139
140    /**
141     * Uncheck ancestors of passed node
142     *
143     * Don't use uncheck() method because we won't trigger onUncheck events
144     *
145     * @private
146     * @param li node
147     */
148    _uncheckAncestors:function (li) {
149        li.parentsUntil(this.options.core.widgetBaseClass).filter('li').find('input:checkbox:first:checked').prop('checked', false).change();
150    },
151
152    /**
153     * Uncheck descendants of passed node
154     *
155     * Don't use uncheck() method because we won't trigger onUncheck events
156     *
157     * @private
158     * @param li node
159     */
160    _uncheckDescendants:function (li) {
161        li.find('li input:checkbox:checked').prop('checked', false).change();
162    },
163
164    /**
165     * Uncheck nodes that are neither ancestors or descendants of passed node
166     *
167     * Don't use uncheck() method because we won't trigger onUncheck events
168     *
169     * @private
170     * @param li node
171     */
172    _uncheckOthers:function (li) {
173        var t = this;
174        li.addClass('exclude');
175        li.parents('li').addClass('exclude');
176        li.find('li').addClass('exclude');
177        $(this.element).find('li').each(function () {
178            if (!$(this).hasClass('exclude')) {
179                $(this).find('input:checkbox:first:checked').prop('checked', false).change();
180            }
181        });
182        $(this.element).find('li').removeClass('exclude');
183    },
184
185    /**
186     * Check node
187     *
188     * @public
189     * @param li node to check
190     */
191    check:function (li) {
192
193        li = $(li);
194
195        li.find('input:checkbox:first:not(:checked)').prop('checked', true).change();
196
197        // handle others
198        if (this.options.onCheck.others == 'check') {
199            this._checkOthers(li);
200        } else
201
202        if (this.options.onCheck.others == 'uncheck') {
203            this._uncheckOthers(li);
204        }
205
206        // handle descendants
207        if (this.options.onCheck.descendants == 'check') {
208            this._checkDescendants(li);
209        } else
210
211        if (this.options.onCheck.descendants == 'uncheck') {
212            this._uncheckDescendants(li);
213        }
214
215        // handle ancestors
216        if (this.options.onCheck.ancestors == 'check') {
217            this._checkAncestors(li);
218        } else
219
220        if (this.options.onCheck.ancestors == 'uncheck') {
221            this._uncheckAncestors(li);
222        } else
223
224        if (this.options.onCheck.ancestors == 'checkIfFull') {
225            var isRoot = this.options.core.isRoot(li);
226            var allDescendantChecked = this._allDescendantChecked(this.options.core.parentNode(li));
227            if (!isRoot && allDescendantChecked) {
228                this.check(this.options.core.parentNode(li));
229            }
230        }
231    },
232
233    /**
234     * Check all tree elements
235     *
236     * Don't use check() method so it won't trigger onCheck events
237     *
238     * @public
239     */
240    checkAll:function () {
241        $(this.element).find('input:checkbox:not(:checked)').prop('checked', true).change();
242    },
243
244    /**
245     * Uncheck node
246     *
247     * @public
248     * @param li node to uncheck
249     */
250    uncheck:function (li) {
251
252        li = $(li);
253
254        li.find('input:checkbox:first:checked').prop('checked', false).change();
255
256        // handle others
257        if (this.options.onUncheck.others == 'check') {
258            this._checkOthers(li);
259        } else
260
261        if (this.options.onUncheck.others == 'uncheck') {
262            this._uncheckOthers(li);
263        }
264
265        // handle descendants
266        if (this.options.onUncheck.descendants == 'check') {
267            this._checkDescendants(li);
268        } else
269
270        if (this.options.onUncheck.descendants == 'uncheck') {
271            this._uncheckDescendants(li);
272        }
273
274        // handle ancestors
275        if (this.options.onUncheck.ancestors == 'check') {
276            this._checkAncestors(li);
277        } else
278
279        if (this.options.onUncheck.ancestors == 'uncheck') {
280            this._uncheckAncestors(li);
281        }
282
283    },
284
285    /**
286     * Uncheck all tree elements
287     *
288     * Don't use uncheck() method so it won't trigger onUncheck events
289     *
290     * @public
291     */
292    uncheckAll:function () {
293        $(this.element).find('input:checkbox:checked').prop('checked', false).change();
294    },
295
296    /**
297     * Default options values.
298     */
299    options:{
300
301        /**
302         * Defines if tree nodes will have a checkbox field
303         */
304        checkbox: true,
305
306        /**
307         * Defines which actions trigger when a node is checked.
308         * Actions are triggered in the following order:
309         * 1) others
310         * 2) descendants
311         * 3) ancestors
312         */
313        onCheck:{
314
315            /**
316             * Available values: null, 'check', 'uncheck', 'checkIfFull'.
317             */
318            ancestors:'check',
319
320            /**
321             * Available values: null, 'check', 'uncheck'.
322             */
323            descendants:'check',
324
325            /**
326             * Available values: null, 'collapse', 'expand'.
327             */
328            node:'', //@todo missing order
329
330            /**
331             * Available values: null, 'check', 'uncheck'.
332             */
333            others:''
334        },
335
336        /**
337         * Defines which actions trigger when a node is unchecked.
338         * Actions are triggered in the following order:
339         * 1) others
340         * 2) descendants
341         * 3) ancestors
342         */
343        onUncheck:{
344
345            /**
346             * Available values: null, 'check', 'uncheck'.
347             */
348            ancestors:'',
349
350            /**
351             * Available values: null, 'check', 'uncheck'.
352             */
353            descendants:'uncheck',
354
355            /**
356             * Available values: null, 'collapse', 'expand'.
357             */
358            node:'', //@todo missing order
359
360            /**
361             * Available values: null, 'check', 'uncheck'.
362             */
363            others:''
364        }
365
366    }
367});
Full Screen

student_profile_widgets.js

Source: student_profile_widgets.js Github

copy
1$(document).ready(function(){
2    $("#id_looking_for").multiselect({
3        noneSelectedText: 'select job types',
4        checkAllText: multiselectCheckAllText,
5        uncheckAllText: multiselectUncheckAllText,
6        minWidth:multiselectMinWidth,
7        height:'auto',
8        checkAll: function(){
9            $("#id_looking_for").trigger("change");
10        },
11        uncheckAll: function(){
12            $("#id_looking_for").trigger("change");
13        }
14    }).multiselectfilter();  
15    
16    $("#id_industries_of_interest").multiselect({
17        noneSelectedText: 'select industries',
18        classes: 'interested_in_multiselect',
19        uncheckAllText: multiselectUncheckAllText,
20        minWidth:multiselectMinWidth,
21        height:220,
22        beforeclose: function() {
23            $(".warning").remove();
24        },
25        click: function(e) {
26            $(".warning").remove();
27            if( $(this).multiselect("widget").find("input:checked").length > INDUSTRIES_OF_INTEREST_MAX ) {
28                place_multiselect_warning_table($("#id_industries_of_interest"), MAX_INDUSTRIES_OF_INTEREST_EXCEEDED);
29                return false;
30            }
31        },
32        uncheckAll: function(){
33            $("#id_industries_of_interest").trigger("change");
34        }
35    }).multiselectfilter();
36
37    $("#id_previous_employers").multiselect({
38        noneSelectedText: 'select employers',
39        classes: 'previous_employers_multiselect',
40        uncheckAllText: multiselectUncheckAllText,
41        minWidth:multiselectMinWidth,
42        height:220,
43        beforeclose: function() {
44            $(".warning").remove();
45        },
46        click: function(e) {
47            $(".warning").remove();
48            if( $(this).multiselect("widget").find("input:checked").length > PREVIOUS_EMPLOYERS_MAX ) {
49                place_multiselect_warning_table($("#id_previous_employers"), MAX_PREVIOUS_EMPLOYERS_EXCEEDED);
50                return false;
51            }
52        },
53        uncheckAll: function(){
54            $("#id_previous_employers").trigger("change");
55        }
56    }).multiselectfilter();
57
58    $("#id_campus_involvement").multiselect({
59        noneSelectedText: 'select campus organizations',
60        classes: 'campus_involvement_multiselect',
61        uncheckAllText: multiselectUncheckAllText,
62        height:220,
63        beforeoptgrouptoggle: function(e, ui){
64            $(".warning").remove();
65            if( ui.inputs.length - $(ui.inputs).filter(':checked').length + $(this).multiselect("widget").find("input:checked").length > CAMPUS_INVOLVEMENT_MAX ) {
66                place_multiselect_warning_table($("#id_campus_involvement"), MAX_CAMPUS_INVOLVEMENT_EXCEEDED);
67                return false;
68            }
69        },
70        minWidth:multiselectMinWidth,
71        beforeclose: function() {
72            $(".warning").remove();
73        },
74        click: function(e, ui) {
75            $(".warning").remove();
76            if( ui.checked && $(this).multiselect("widget").find("input:checked").length > CAMPUS_INVOLVEMENT_MAX ) {
77                place_multiselect_warning_table($("#id_campus_involvement"), MAX_CAMPUS_INVOLVEMENT_EXCEEDED);
78                return false;
79            }
80        },
81        uncheckAll: function(){
82            $("#id_campus_involvement").trigger("change");
83        }
84    }).multiselectfilter();
85    
86    $("#id_languages").multiselect({
87        noneSelectedText: 'select languages',
88        classes: 'languages_multiselect',
89        uncheckAllText: multiselectUncheckAllText,
90        minWidth:multiselectMinWidth,
91        height:220,
92        beforeclose: function() {
93            $(".warning").remove();
94        },
95        click: function(event, ui) {
96            $(".warning").remove();
97            if( $(this).multiselect("widget").find("input:checked").length > LANGUAGES_MAX ) {
98                place_multiselect_warning_table($("#id_languages"), MAX_LANGUAGES_EXCEEDED);
99                return false;
100            }
101            var num = $(this).multiselect("widget").find("input:checked").filter(function(){
102                 if(this.title.split(' (')[0] == ui.text.split(' (')[0])
103                     return true;
104               }).length;
105               if (num > 1){
106                   place_table_form_field_error($("<label class='warning' for'" + $("#id_languages").attr("id") + "'>" + ONE_LANGUAGE_DIFFICULTY + "</label>"), $("#id_languages"));
107                   return false;
108               }
109        },
110        uncheckAll: function(){
111            $("#id_languages").trigger("change");
112        }
113    }).multiselectfilter();
114
115    $("#id_countries_of_citizenship").multiselect({
116        noneSelectedText: "select countries",
117        classes: 'countries_of_citizenship_multiselect',
118        uncheckAllText: multiselectUncheckAllText,
119        height:220,
120        minWidth:multiselectMinWidth,
121        selectedList: 1,
122        beforeclose: function() {
123            $(".warning").remove();
124        },
125        click: function(e) {
126            $(".warning").remove();
127            if( $(this).multiselect("widget").find("input:checked").length > COUNTRIES_OF_CITIZENSHIP_MAX ) {
128                place_multiselect_warning_table($("#id_countries_of_citizenship"), MAX_COUNTRIES_OF_CITIZENSHIP_EXCEEDED);
129                return false;
130            }
131        },
132        uncheckAll: function(){
133            $("#id_countries_of_citizenship").trigger("change");
134        }
135    }).multiselectfilter();
136    
137    /* Need all widgets to load before anything is hidden.
138     * Therefore accordion is loaded on event trigger */
139    $(document).trigger('widgetsLoaded');
140});
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Cypress on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)