PageSourceSearch

https://neren.org/wp-content/plugins/uc-admin-themes/wp-admin.js

js neren.org collected 2026-10-04 14:47:09 UTC 12,847 bytes, 332 lines download raw bytes

1function onPageExist(newLink) {
2    var $ = jQuery;
3    // Actions when duplicate page is found.
4    alert("Page:  " + newLink + "\nis in the menu! No duplicate links are allowed.");
5}
6
7function onPageDuplicate(menuLinks) {
8    var $ = jQuery;
9    // Actions when duplicate page is found.
10
11    // Create duplicate link list
12    var html = "";
13    for (var i in menuLinks.duplicates.page) {
14        html += "- " + menuLinks.duplicates.page[i] + "\n";
15    }
16    for (var i in menuLinks.duplicates.custom) {
17        html += "- " + menuLinks.duplicates.custom[i] + "\n";
18    }
19    for (var i in menuLinks.duplicates.category) {
20        html += "- " + menuLinks.duplicates.category[i]  + "\n";
21    }
22    html = "Duplicate Links Detected\nEach link can only appear once in the Primary Menu. Please remove any duplicate links until there is only one instance of each of the following links:\n\n"
23        + html +
24        "\nYou will not be able to save any changes to the Primary Menu until these duplicate links have been removed.";
25
26    alert(html);
27}
28
29function validateNewPage(newlink, link_dic, link_to_menu_map) {
30    // Validate new page. 
31    if (newlink in link_dic) {
32        onPageExist(newlink, link_to_menu_map[newlink]);
33        return false;
34    }
35    return true;
36}
37
38function onAddingCheckedMenuItems(id, link_dic, link_to_menu_map) {
39    var $ = jQuery;
40    var validate_result = true;
41    $('#' + id).find('[type="checkbox"]').each(function(index, el) {
42        if (el.checked) {
43            var menu_item_url = $(el).closest("li").find(".menu-item-url");
44            if (menu_item_url != null) {
45                var newlink = menu_item_url.attr("value");
46                validate_result = validateNewPage(newlink, link_dic, link_to_menu_map);
47                if (validate_result === false) {
48                    return false;
49                }
50            }
51        }
52    });
53
54    return validate_result;
55}
56
57function updateCheckedMenuItemsStatus(page, category) {
58    var $ = jQuery;
59    $('#add-post-type-page').find('[type="checkbox"]').each(function(index, el) {
60        //console.log($(el).val());
61        var menu_item = $(el).val();
62        if (menu_item != null) {
63            if (menu_item in page) {
64                el.disabled = true;
65                el.checked = false; // Set to unchecked to prevent it from being added again.
66            } else {
67                el.disabled = false;
68            }
69        }
70    });
71    $('#add-category').find('[type="checkbox"]').each(function(index, el) {
72        var menu_item = $(el).val();
73        if (menu_item != null) {
74            if (menu_item in category) {
75                el.disabled = true;
76                el.checked = false; // Set to unchecked to prevent it from being added again.
77            } else {
78                el.disabled = false;
79            }
80        }
81    });
82}
83
84function markElement(el, is_mark) {
85    var $ = jQuery;
86    if (is_mark) {
87        $(el).css("color", "red");
88    } else {
89        $(el).css("color", "rgb(51,51,51)");
90    }
91}
92
93function retrieveMenuLinks() {
94    var $ = jQuery;
95    var page = {};
96    var custom = {};
97    var category = {};
98    var duplicates = { 'page': {}, 'custom': {}, 'category': {} };
99    $('#menu-to-edit > li').each(function(index, el) {
100        var itemType = $(el).find(".menu-item-data-object").val();
101        if (itemType == 'page') {
102            var itemId = $(el).find(".menu-item-data-object-id").val();
103            if (itemId in page) {
104                duplicates['page'][itemId] = $(el).find(".edit-menu-item-title").val();
105            }
106            else {
107                page[itemId] = true;
108            }
109        }
110        else if (itemType == 'custom') {
111            var itemURL = $(el).find(".edit-menu-item-url").val();
112            if (itemURL != '#') {
113                if (itemURL in custom) {
114                    duplicates['custom'][itemURL] = $(el).find(".edit-menu-item-title").val();
115                }
116                else {
117                    custom[itemURL] = true;
118                }
119            }
120        }
121        else if (itemType == 'category') {
122            var itemId = $(el).find(".menu-item-data-object-id").val();
123            if (itemId in category) {
124                duplicates['category'][itemId] = $(el).find(".edit-menu-item-title").val();
125            }
126            else {
127                category[itemId] = true;
128            }
129        }
130    });
131    return {
132        'page': page,
133        'custom': custom,
134        'category': category,
135        'duplicates': duplicates
136    };
137}
138
139function addMenuLink(newlink, el, link_dic, link_to_menu_map) {
140    link_dic[newlink] = 1;
141
142    // Create link to menu item entry
143    link_to_menu_map[newlink] = el;
144}
145
146function deleteMenuLink(deletedLink, link_dic, link_to_menu_map) {
147    if (--link_dic[deletedLink] == 0) {
148        delete link_dic[deletedLink];
149        // Delete link to menu item entry
150        delete link_to_menu_map[deletedLink];
151    }
152}
153
154/*
155function appendColorBoxPlugin() {
156    // Create colorbox script.
157    var colorBoxScript = document.createElement('script');
158    colorBoxScript.src = 'http://development.wordpress.uconn.edu/wp-content/plugins/uc-admin-themes/jquery.colorbox.js';
159    colorBoxScript.type = 'text/javascript';
160    
161    // Create colorbox css style.
162    var colorBoxCSS = document.createElement('link');
163    colorBoxCSS.rel = 'stylesheet';
164    colorBoxCSS.media = 'screen';
165    colorBoxCSS.type = 'text/css'
166    colorBoxCSS.href = 'http://development.wordpress.uconn.edu/wp-content/plugins/uc-admin-themes/colorbox.css';
167    
168    // Append script and css style to document.
169    document.getElementsByTagName('head')[0].appendChild(colorBoxCSS);
170    document.getElementsByTagName('head')[0].appendChild(colorBoxScript);
171}
172*/
173jQuery(document).ready(function($) {
174
175    $('.network-admin.users-php .bulkactions').append('<a class="select-inactive button" href="">Select Inactive</a> <a class="select-inactive-no-sites button" href="">Select Inactive Without Site Access</a>');
176    $('.select-inactive').click(function(event) {
177        event.preventDefault();
178        $('.column-LDAP_Active').each(function() {
179            if ($(this).html() == 'Inactive') $(this).closest('tr').find('input').prop("checked", true);
180        });
181    });
182    $('.select-inactive-no-sites').click(function(event) {
183        event.preventDefault();
184        $('.column-LDAP_Active').each(function() {
185            if ($(this).html() == 'Inactive' && ($(this).closest('tr').find('.column-blogs').html().length == 0)) $(this).closest('tr').find('input').prop("checked", true);
186        });
187    });
188
189    // Hide the manage sidebars stuff (temp)
190    /*
191    $('#menu-appearance .wp-submenu a').each(function(){
192        var href= $(this).attr('href');
193        if (href == 'themes.php?page=uc_sidebars') {
194            $(this).hide();
195            console.log(href);
196        }
197    });
198    */
199
200    //Change the UCONN AURORA link.
201    //$('#wp-admin-bar-wp-logo a').attr('href','http://aurora.uconn.edu'); //No longer needed, done in uc-admin-themes
202
203    //Append colorbox jquery plugin
204    //  appendColorBoxPlugin();
205
206    // Disallow adding duplicate pages to NAV menu.
207    var pagePath = window.location.pathname;
208    var pageName = pagePath.substring(pagePath.lastIndexOf('/') + 1);
209    if (pageName === "nav-menus.php" && $('#locations-primary').prop('checked')) {
210        // Retrieve current menu links.
211        var menuLinks = retrieveMenuLinks();
212
213        // Update all checkbox status
214        updateCheckedMenuItemsStatus(menuLinks.page, menuLinks.category);
215
216        // Capture Save Menu action to check existing duplicate links.
217        $("#update-nav-menu").find('[type="submit"]').on('click', function(event) {
218            var menuLinks = retrieveMenuLinks();
219            if (!jQuery.isEmptyObject(menuLinks.duplicates.page) || !jQuery.isEmptyObject(menuLinks.duplicates.custom) || !jQuery.isEmptyObject(menuLinks.duplicates.category)) {
220                onPageDuplicate(menuLinks);
221                return false;
222            }
223            return true;
224        });
225
226        //Prevent adding duplicate custom links
227        $('#submit-customlinkdiv').on('click', function(event) {
228            var menuLinks = retrieveMenuLinks();
229            var newLink = $('#custom-menu-item-url').val();
230            if (newLink in menuLinks.custom) {
231                onPageExist(newLink);
232                return false;
233            }
234            return true;
235        });
236
237        // Monitor adding new link event
238        $("#menu-to-edit").on('DOMNodeInserted', function(event) {
239            // Retrieve current menu links.
240            var menuLinks = retrieveMenuLinks();
241            // Update all checkbox status
242            updateCheckedMenuItemsStatus(menuLinks.page, menuLinks.category);
243        });
244
245        // Monitor deleting link event
246        $(".menu-item").on('remove', function(event) {
247            // Retrieve current menu links.
248            var menuLinks = retrieveMenuLinks();
249            var itemType = $(this).find(".menu-item-data-object").val();
250            if (itemType == 'page') {
251                var itemId = $(this).find(".menu-item-data-object-id").val();
252                if (!(itemId in menuLinks.duplicates.page)) {
253                    delete menuLinks.page[itemId];
254                }
255            }
256            else if (itemType == 'category') {
257                var itemId = $(this).find(".menu-item-data-object-id").val();
258                if (!(itemId in menuLinks.duplicates.category)) {
259                    delete menuLinks.category[itemId];
260                }
261            }
262            // Update all checkbox status
263            updateCheckedMenuItemsStatus(menuLinks.page, menuLinks.category);
264        });
265    }
266
267    if (pageName == 'options-general.php') {
268        $('p#new-admin-email-description').html('This address is used for admin purposes');
269    }
270
271    //Hide Meta Slider html tabs
272    //$('.slide.layer_slide').each(function(){
273    //	$($(this).children('.col-2').children('.tabs').children().get(3)).css('display','none');
274    //});
275    $('.slide.post_feed').each(function() {
276        $($(this).children('.col-2').children('.tabs').children().get(0)).css('display', 'none');
277        $($(this).children('.col-2').children('.tabs').children().get(1)).addClass('selected');
278        $($(this).children('.col-2').children('.tabs-content').children().get(0)).css('display', 'none');
279    });
280
281
282    //Hide empty widget areas on Widgets page
283    $('.widgets-holder-wrap').each(function() {
284        if ($(this).children().first().css('display') == 'none') {
285            $(this).css('display', 'none');
286        }
287    });
288
289    //Disable email edit field
290    $('.user-edit-php #email, .profile-php #email,.user-edit-php #first_name, .profile-php #first_name,.user-edit-php #last_name, .profile-php #last_name').attr('readonly', 'readonly');
291
292    // hide the Visual Editor on the user-edit.php page
293    $('.user-rich-editing-wrap').hide();
294
295    //
296    // Hide the 2 links on the page builder page
297    //
298    // $("body").on("click",".so-prebuilt-add",function(e) {
299    // 	$('.so-sidebar-tabs li').each(function(i,e){
300    // 		if( $(this).children('a').attr('href') == '#import'){
301    // 			$(this).next().children('a').click();
302    // 			$(this).remove();
303    // 		}
304    // 	});
305    // }); 
306    $('.widgets-php #header-widget-area .description').each(function() {
307        $(this).html($(this).html().replace('header widget area guide', '<a target="_blank" href="http://aurora.uconn.edu/2016/12/28/header-widget-area/">header widget area guide</a>'));
308    });
309
310    // Remove the advertisement from the Velvet Blues Update URLs tools page
311    $("body.tools_page_velvet-blues-update-urls div.wrap form").next('p').remove();
312
313    // Remove advertisement from WP GA Events
314    $(".ga_events_featurebox").remove();
315    $(".ga_events_sidebar").remove();
316
317    // Remove advertisement from Replace Media Upload page
318    $("div[style='background: #fff;width: 250px;min-height: 270px;border: 1px solid #ccc;float: right;padding: 15px;margin: 0 0 10px;']").remove();
319
320    // Remove advertisement from Aryo Activity Log
321    $(".aal-install-elementor").remove();
322
323    // Remove Visualizer Datatracking popup
324    $("#visualizer_logger_flag-notification").remove();
325
326    // Removing the 'Add Widget Class' from SiteOrigin settings so users cannot disable it
327    $('.panels-setting').each(function() {
328        if ($(this).find('label').html() == 'Add Widget Class') {
329            $(this).hide()
330        }
331    })
332});

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.