PageSourceSearch

https://estudiosavanzados.net/wp-content/mu-plugins/M4P_core/assets/js/toolsInterface.js?ver=4.6.1

js estudiosavanzados.net collected 2026-10-07 00:01:01 UTC 9,133 bytes, 279 lines download raw bytes

1/* 
2 Created on : Oct 24, 2015, 1:44:09 PM
3 Author     : rocknroll
4 */
5var $ = jQuery;
6var $tools_interface;
7var ajaxurl;
8var wpCookies;
9var instances = [];
10var instancesCount = [];
11var viewerMarkup;
12var runnerMarkup;
13var openWindow = function (instanceDiv) {
14    $(".instance").removeClass('active');
15    $(".instance .content").addClass('hide');
16    instanceDiv.addClass('active');
17    instanceDiv.find('.content').removeClass('hide');
18    instanceDiv.find('.content  .interface').show();
19    $('body').css('overflow', 'hidden');
20};
21var closeWindow = function (instanceDiv) {
22    instanceDiv.removeClass('active');
23    instanceDiv.find('.content').addClass('hide');
24    instanceDiv.find('.content .interface').hide();
25    $('body').css('overflow', 'auto');
26};
27var getInstance = function (instanceDiv, instanceObj) {
28    tool = instanceDiv.attr('data-tool');
29    count = instanceDiv.attr('data-count');
30    intstanceObj = [];
31    intstanceObj[0] = instances[tool][count];
32    return intstanceObj;
33};
34var createInstance = function (instanceDiv) {
35    title = instanceDiv.attr('data-title');
36    subtitle = instanceDiv.attr('data-subtitle');
37    tool = instanceDiv.attr('data-tool');
38    version = instanceDiv.attr('data-version');
39    params = instanceDiv.parent().find('.params-val').val();
40    viewer = instanceDiv.attr('data-viewer');
41    count = getCount(tool);
42    initInstanceType(tool, count);
43    instances[tool][count]['title'] = title;
44    instances[tool][count]['subtitle'] = subtitle;
45    instances[tool][count]['params'] = params;
46    inst = getInstanceMarkup(title, subtitle, tool, version, count, viewer);
47    $tools_interface.append(inst);
48    runInstance(tool, count, viewer);
49};
50
51var getInstanceMarkup = function (title, subtitle, tool, version, count, viewer) {
52    if (viewer === '1') {
53        instances[tool][count]['viewer'] = true;
54        markup = viewerMarkup;
55    }
56    else {
57        markup = runnerMarkup;
58    }
59    inst = markup
60            .replace(/{title}/g, title)
61            .replace(/{subtitle}/g, subtitle)
62            .replace(/{tool}/g, tool)
63            .replace(/{version}/g, version)
64            .replace(/{count}/g, count);
65    return inst;
66};
67var initInstanceType = function (tool, count) {
68    if (typeof instances[tool] === "undefined") {
69        instances[tool] = [];
70    }
71    if (typeof instances[tool][count] === "undefined") {
72        instances[tool][count] = [];
73    }
74};
75var getCount = function (tool) {
76    if (typeof params === 'undefined') {
77        params = '';
78    }
79    if (typeof instancesCount[tool] === "undefined") {
80        instancesCount[tool] = 1;
81    }
82    else {
83        instancesCount[tool]++;
84    }
85    count = instancesCount[tool];
86    return count;
87};
88var updateTrace = function (tool, count, $trace) {
89    if (typeof instances[tool][count]['updates'] !== 'undefined') {
90        updates = instances[tool][count]['updates'];
91        $.each(updates, function (i, event) {
92            $trace.html(event.currentTarget.response);
93            $($trace).animate({
94                scrollTop: $($trace).delay(50).outerHeight()
95            }, 10);
96        });
97    }
98
99
100};
101
102var ajaxCall = function (tool, count, params, $loadImg, $trace, instance, viewer) {
103    instances[tool][count]['updates'] = [];
104    return $.ajax({
105        url: ajaxurl + '?action=' + tool + '&i=' + count + params,
106        type: "POST",
107        beforeSend: function (response) {
108            $loadImg.css('display', 'inline-block');
109        },
110        xhrFields: {
111            onprogress: function (event)
112            {
113                upLenght = instances[tool][count]['updates'].lenght;
114                if (typeof upLenght === 'undefined') {
115                    upLenght = 0;
116                }
117                instances[tool][count]['updates'][upLenght] = event;
118                if (typeof instances[tool][count]['defer'] === 'undefined') {
119                    instances[tool][count]['defer'] = $.when(updateTrace(tool, count, $trace));
120
121                }
122                instances[tool][count]['defer'].done(function () {
123                    instances[tool][count]['defer'] = $.when(updateTrace(tool, count, $trace));
124                });
125            }
126        },
127        success: function (response) {
128            $loadImg.hide();
129            if (viewer != 1) {
130                instance.addClass('rq-success');
131            }
132        },
133        fail: function () {
134            $loadImg.hide();
135            instance.addClass('rq-error');
136        },
137        error: function () {
138            $loadImg.hide();
139            instance.addClass('rq-error');
140        }
141    });
142};
143var runInstance = function (tool, count, viewer) {
144    autoOpen = true;
145    params = '';
146    if (instances[tool][count]['params'].length) {
147        params = '&' + instances[tool][count]['params'];
148    }
149    instance = $('.instance[data-tool=' + tool + '][data-count=' + count + ']');
150    if (viewer === '1') {
151        target = instance.find('.content');
152    }
153    else {
154        target = instance.find('.content .trace-body');
155    }
156    autoScroll(target);
157    $loadImg = instance.find('.load_img, .load_img i');
158    if (autoOpen) {
159        openWindow(instance);
160    }
161    proccessRequest = ajaxCall(tool, count, params, $loadImg, target, instance, viewer);
162    instances[tool][count]['request'] = proccessRequest;
163};
164var stopInstance = function (instanceDiv) {
165    instance = getInstance(instanceDiv);
166    instance[0]['request'].abort();
167    return instance;
168};
169var deleteInstance = function (instanceDiv) {
170    instance = stopInstance(instanceDiv);
171    delete instance;
172    instanceDiv.remove();
173    $('body').css('overflow', 'auto');
174};
175
176var autoScroll = function (element) {
177    if (typeof autoscroll === 'undefined') {
178        autoscroll = true;
179    }
180    $(element).on('change', function (autoscroll) {
181        if (autoscroll) {
182            $(element).animate({
183                scrollTop: $(element).delay(50).height()
184            }, 10);
185        }
186        else {
187            return false;
188        }
189    });
190};
191$(document).ready(function () {
192    $tools_interface = $("#tools-interface");
193    if (typeof wpCookies !== 'undefined') {
194//        console.log(wpCookies.getHash("wp-settings-1"));
195//        if (wpCookies.getHash("wp-settings-1").mfold === 'f') {
196//            $tools_interface.addClass('full');
197//        }
198    }
199
200    $(".tool-option").on('click', function (e) {
201        e.preventDefault();
202        createInstance($(this));
203    });
204    $(document).on('click', '.close_img', function (e) {
205        e.preventDefault();
206        instance = $(this).closest('.instance');
207        deleteInstance(instance);
208
209    });
210    $(".params-conf input").keyup(function (e) {
211        if (e.keyCode === 13) {
212            e.preventDefault();
213            $dataDiv = $(this).parent().parent().find('.tool-option');
214            createInstance($dataDiv);
215        }
216    });
217    $('.plugin-description .switch').on('click', function () {
218        icon = $(this).find('i');
219        pconf = $(this).parent().find('.params-conf');
220        if (icon.hasClass('fa-angle-right')) {
221            icon.removeClass('fa-angle-right');
222            icon.addClass('fa-angle-down');
223            pconf.css('display', 'block');
224        }
225        else {
226            icon.removeClass('fa-angle-down');
227            icon.addClass('fa-angle-right');
228            pconf.hide();
229        }
230    });
231    $(document).on('hover', '.load_img', function (e) {
232        e.preventDefault();
233        instance = $(this).closest('.instance');
234        instance.find('.stop_img').show();
235        $(this).hide();
236    });
237    $(document).on('mouseleave', '.stop_img', function (e) {
238        e.preventDefault();
239        instance = $(this).closest('.instance');
240        instance.find('.load_img').show();
241        $(this).hide();
242    });
243    $(document).on('click', '.stop_img', function (e) {
244        e.preventDefault();
245        instance = $(this).closest('.instance');
246        instance.find('.load_img, .load_img i').remove();
247        stopInstance(instance);
248        $(this).remove();
249    });
250    $('#collapse-button').on('click', function () {
251        $tools_interface.removeClass('full');
252    });
253    $('#collapse-menu span').on('click', function () {
254        $tools_interface.addClass('full');
255    });
256    $(document).on('click', '.instance .title', function (e) {
257        e.preventDefault();
258        instance = $(this).closest('.instance');
259        if (instance.hasClass('active')) {
260            closeWindow(instance);
261        }
262        else {
263            openWindow(instance);
264        }
265    });
266    $(document).on('click', '.m4p-lightbox.close-btn', function (e) {
267        e.preventDefault();
268        $('.m4p-lightbox.back').addClass('hide');
269        $('body').css('overflow', 'auto');
270    });
271    $(document).on('click', 'li.m4p-lightbox-show', function (e) {
272        e.preventDefault();
273        $('.m4p-lightbox.back').addClass('hide');
274        sourceId = $(this).attr('id');
275        finalId = '#' + sourceId.replace('wp-admin-bar-', '') + '-lightbox';
276        $(finalId).removeClass('hide').css('display', 'block');
277        $('body').css('overflow', 'hidden');
278    });
279});

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.