简体   繁体   中英

Is it too hard to work with a minified js file? Sample code included

I'm trying to add another icon (which are used for dropdown menus) to the main navigation bar of a web interface. I don't have access to all the source files, but I think all I need to do is edit a js file and an.asp webpage template.

Anyway, a developer said that the min.js file that I need to edit is too hard to work with and needs the original unminified js file.

If all I am trying to do is replicate something already in the navigation bar ie an icon used for a dropdown menu, then doesn't it really just come down to copying/pasting some of the js code?

I have included a snippet of code from the js file. You can see that this is where you input the settings for the icons, such as which icon to use, name, section etc. This is obviously not the only part of code that you need in order to implement another dropdown menu in the navigation bar, but shouldn't adding another icon dropdown menu to the navigation bar be as simple as repeating the code that has already been used several times in the min.js file for the other dropdown menus in the navigation bar?

        L = navMiniModeThreshold,
        I = [{
            section: "UserTickets",
            permission: "tickets",
            text: "tickets",
            icon: "drafts",
            onNav: function(e) {
                return UpdateSection("UserTickets", e + "Management/Tickets/frmTickets.aspx?default=true", !0, !1), !1
            }
        }, {
            section: "UserLiveChatNew",
            permission: "chats",
            cssClass: "UserLiveChatIcon",
            text: "liveChat",
            icon: "forum",
            onNav: function(e) {
                return UpdateSection("UserLiveChatNew", e + "Management/Chat/frmClientChats.aspx", !0, !1), !1
            }
        }, {
            section: "UserCallLogs",
            permission: "callLogs",
            text: "callLogs",
            icon: "phone",
            onNav: function(e) {
                return UpdateSection("UserCallLogs", e + "Management/CallLogs/frmCallLogs.aspx?me=True&Outgoing=0", !0, !1), !1
            }
        }, {
            section: "Tasks",
            permission: "tasks",
            text: "tasks",
            icon: "book",
            onNav: function(e) {
                return UpdateSection("Tasks", e + "Management/Tasks/frmTasks.aspx?mode=0&taskstatusid=4&source=m&default=true", !0, !1), !1
```            }

```    D.fn.stTopNavBar = function(e) {
        return e = D.extend({}, t, e), this.each(function() {
            ! function(c, d) {
                var u = "stTopNavBar" + n++,
                    m = u + "_NavMenu",
                    o = u + "_NavMenuSelected",
                    i = u + "_QuickAddMenu",
                    r = u + "_DashboardMenu",
                    a = u + "_NotificationMenu",
                    s = u + "_QuickAddSelected",
                    l = u + "_AvatarMenu",
                    h = I[0],
                    p = c.attr("data-rootpath") || "/";

                function f() {
                    var e = D("<button class='hamburger'></button>");
                    return e.append("<i class='material-icons'>menu</i>"), D(window).width() < 1024 && (A = !1, e.addClass("collapsed"), D("#outer-left-panel").addClass("collapsed")), e.click(function(e) {
                        return D("body").trigger("nav:treeToggled", !A), !1
                    }), e
                }

                function v(t) {
                    var e = D("<button title='" + _.escape(d.translations[t.text]) + "' class='left-item'></button>");
                    return e.attr({
                        id: u + "_Section_" + t.section
                    }), t.cssClass && e.addClass(t.cssClass), e.click(function(e) {
                        return b(e, t)
                    }), e.append("<i class='material-icons'>" + t.icon + "</i>"), e.append("<span class='counter' style='display:none'></span>"), e
                }

                function g(e) {
                    var t = D("<button title='" + _.escape(d.translations[e.text]) + "' class='right-item'></button>").attr("id", a);
                    e.cssClass && t.addClass(e.cssClass), t.click(function() {
                        return e.onNav(p), !1
                    }), t.append("<i class='material-icons'>" + e.icon + "</i>");
                    var n = "function" == typeof e.getCounterVal ? e.getCounterVal() : 0;
                    return D("<span class='counter'></span>").toggle(0 < n).text(n).appendTo(t), t
```                }

Many tools can unminify a js, but you'll loose the variable names if you don't have the map file. Which seems to me is what your code is, an unminified file. Assuming there's no original source code, because there was no source control and original developer bailed and you only have what's in production. Then yes, small changes can be done to this version. It's harder to follow, so if your developer is not really a developer, give him some slack and either do trial and error or find a professional.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM