PageSourceSearch

https://www.hussainiat.com/javascript/vsk.js

js hussainiat.com collected 2026-09-24 09:47:50 UTC 16,671 bytes, 495 lines download raw bytes

1$(function () {
2    $(".vk-button:not(.ui-state-disabled)")
3		.hover(
4			function () {
5			    $(this).addClass("ui-state-hover");
6			},
7			function () {
8			    $(this).removeClass("ui-state-hover");
9			}
10		);
11});
12// Show / Hide Panels
13function toggle_panel(index, pnl) {
14    switch (index) {
15        case 1:
16            $(pnl).slideDown(1000);
17            break;
18        case 2:
19            $(pnl).hide("highlight", 1000);
20            break;
21    }
22}
23function ShowHide(index, pnl) {
24    switch (index) {
25        case 1:
26            $(pnl).show();
27            break;
28        case 2:
29            $(pnl).hide();
30            break;
31    }
32}
33function toggle_tw_panel(index, pnl1, pnl2) {
34    switch (index) {
35        case 1:
36            $(pnl1).show();
37            $(pnl2).hide();
38            break;
39        case 2:
40            $(pnl2).show();
41            $(pnl1).hide();
42            break;
43    }
44}
45// search autocomplete
46function src_ac(clid, surl) {
47    $(clid).autocomplete({
48        serviceUrl: surl,
49        minChars: 2,
50        delimiter: /(,|;)\s*/, // regex or character
51        maxHeight: 400,
52        width: 280,
53        zIndex: 9999,
54        deferRequestBy: 0, //miliseconds
55        noCache: false //default is false, set to true to disable caching
56    });
57}
58// Count text box characters   
59function Count_Chars(obj, label, maxlength) {
60    var len = obj.value.length;
61    if (len >= maxlength) {
62        obj.value = obj.value.substr(0, maxlength);
63    }
64    $(label).text(maxlength - len);
65}
66function ShowHidePanel(pnl, icon) {
67    if ($(pnl).is(':visible')) {
68        $(pnl).hide();
69        $(icon).removeClass('ui-icon ui-icon-triangle-1-s');
70        $(icon).addClass('ui-icon ui-icon-triangle-1-e');
71    }
72    else {
73        $(pnl).show();
74        $(icon).removeClass('ui-icon ui-icon-triangle-1-e');
75        $(icon).addClass('ui-icon ui-icon-triangle-1-s');
76    }
77}
78// check /uncheck all checkboxes in list
79function SelectAll(CheckBoxControl) {
80    var _value = CheckBoxControl.checked;
81    if (_value == true) {
82        var i;
83        for (i = 0; i < document.forms[0].elements.length; i++) {
84            if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf('MyList') > -1)) {
85                document.forms[0].elements[i].checked = true;
86            }
87        }
88    }
89    else {
90        var i;
91        for (i = 0; i < document.forms[0].elements.length; i++) {
92            if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf('MyList') > -1)) {
93                document.forms[0].elements[i].checked = false;
94            }
95        }
96    }
97}
98//* Ajax Related Operations
99function Ajax_Process(path, params, id, tp) {
100    $.ajax({
101        type: tp,
102        url: path,
103        data: params,
104        async: true,
105        cache: true,
106        success: function (msg) {
107            $(id).html(msg);
108        }
109
110    });
111}
112function Ajax_Process_v2(path, params, id, tp, loadingid) {
113    $.ajax({
114        type: tp,
115        url: path,
116        data: params,
117        async: true,
118        cache: true,
119        success: function (msg) {
120            $(id).html(msg);
121            $('#' + loadingid).html('loading');
122            ShowHide(2, '#' + loadingid);
123        }
124    });
125}
126function Ajax_Process_v3(path, params, id, tp, loadingid) {
127    var message = '';
128    $.ajax({
129        type: tp,
130        url: path,
131        data: params,
132        async: true,
133        cache: true,
134        success: function (msg) {
135            ShowHide(2, '#' + loadingid);
136            message = msg;
137        }
138    });
139    return message;
140}
141
142/* Process Like | Dislike */
143function Process_Advice(path, params, id, actionid, actiontype) {
144    toggle_panel(1, '#shw_lgn');
145    // start posting ajax
146    Ajax_Process(path, params, id, "GET");
147    // disable like or dislike button
148    if (actiontype == 0) {
149        $(actionid).removeClass("ui-adv-icon-good");
150        $(actionid).removeClass("ui-adv-icon-gd_hover");
151        $(actionid).addClass("ui-fixed ui-adv-icon-good");
152
153    } else {
154        $(actionid).removeClass("ui-adv-icon-bad");
155        $(actionid).removeClass("ui-adv-icon-bd_hover");
156        $(actionid).addClass("ui-fixed ui-adv-icon-bad");
157    }
158    // disable action
159}
160/* Process Abuse Report */
161function Process_Req(path, params, id, type) {
162    toggle_panel(1, '#shw_lgn');
163    // start posting ajax
164    Ajax_Process(path, params, id, type);
165}
166/* Process Ajax Request with Animation */
167function Process_Req_Animate(path, params, id, type, loadingid) {
168    //$(id).effect("highlight", {}, 1000);
169    $(id).hide("slide", { direction: "left" }, 500);
170    $(id).show("slide", { direction: "right" }, 500);
171    Process_Req(path, params, id, type, loadingid);
172
173}
174
175/* Process Ajax Request With Loading Message*/
176function Process_Req(path, params, id, type, loadingid) {
177    Display_Message(id, "Loading...", 2, 50);
178    //ShowHide(1, '#' + loadingid);
179    // start posting ajax
180    Ajax_Process_v2(path, params, id, type, loadingid);
181}
182
183/* Submit Abuse Report */
184function Post_Abuse(path, params, id, elementid, msgid) {
185    var value = $(elementid).val();
186    if (value == '') {
187        Display_Message(msgid, "Please select reason", 1, 200);
188        return;
189    }
190    Display_Processing(msgid);
191    Ajax_Process(path, params + "&val=" + value, id, "POST");
192    toggle_panel(1, '#shw_lgn');
193}
194/* Submit Playlist */
195function Post_Playlist(path, params, id, elementid, msgid) {
196    var value = $(elementid).val();
197    if (value == '') {
198        Display_Message(msgid, "Please select playlist", 1, 200);
199        return;
200    }
201    Display_Processing(msgid);
202    Ajax_Process(path, params + "&val=" + value, id, "POST");
203    toggle_panel(1, '#shw_lgn');
204}
205/* Validate and Post data */
206function Post_Data(path, params, id, elementid, msgid, valmsg) {
207    var value = $('#' + elementid).val();
208    if (value == '') {
209        Display_Message('#' + msgid, valmsg, 1, 200);
210        return;
211    }
212    Display_Processing(msgid);
213    Ajax_Process(path, params + "&val=" + value, id, "POST");
214    $('#' + elementid).val('');
215}
216/* Display processing message */
217function Display_Processing(id) {
218    $(id).html("<div style='padding:4px 0px;'>Processing....</div>");
219}
220/* Display Message */
221function Display_Message(id, msg, tp, width) {
222    switch (tp) {
223        case 0:
224            $(id).html("<div class='ui-state-highlight ui-corner-all' style='width:" + width + "px;margin:4px auto 4px auto;'>" + msg + "</div>");
225            break;
226        case 1:
227            $(id).html("<div class='ui-state-error ui-corner-all' style='width:" + width + "px;margin:4px auto 4px auto;'>" + msg + "</div>");
228            break;
229        case 2:
230            $(id).html("<div class='item_c' style='padding:20px 0px;'>" + msg + "</div>");
231            break;
232    }
233}
234/* view loading */
235function Expand_View(path, params, msg) {
236    // collapse info view if open
237    Collapse_Info();
238    $('#bx_expander').addClass('box-expander-body');
239    $('#bx_exp_arrow2').removeClass('ui-icon-triangle-1-s');
240    $('#bx_exp_arrow2').addClass('ui-icon-triangle-1-n');
241    $('#bx_exp_hd2').removeClass('box-expander-head');
242    $('#bx_exp_hd2').addClass('box-expander-head-active');
243    $('#bx_exp_bd2').show('slow');
244    $('#bx_hd_exp2').hide('slow');
245    $('#bx_exp_hd2').unbind("click");
246    $('#bx_exp_hd2').bind('click', function () {
247        Collapse_View(path, params, msg);
248    });
249    // ajax processing
250    Ajax_Process(path, params, msg, "POST");
251
252}
253
254function Collapse_View(path, params, msg) {
255    $('#bx_expander').removeClass('box-expander-body');
256    $('#bx_exp_arrow2').addClass('ui-icon-triangle-1-s');
257    $('#bx_exp_arrow2').removeClass('ui-icon-triangle-1-n');
258    $('#bx_exp_hd2').addClass('box-expander-head');
259    $('#bx_exp_hd2').removeClass('box-expander-head-active');
260    $('#bx_exp_bd2').hide('slow');
261    $('#bx_hd_exp2').show('slow');
262    $('#bx_exp_hd2').unbind("click");
263    $('#bx_exp_hd2').bind('click', function () {
264        Expand_View(path, params, msg);
265    });
266}
267/* Box behaviour design */
268function Expand_Info(path, params, msg) {
269    // collapse view if open
270    Collapse_View(path, params, msg);
271    $('#bx_expander').addClass('box-expander-body');
272    $('#bx_exp_arrow').removeClass('ui-icon-triangle-1-s');
273    $('#bx_exp_arrow').addClass('ui-icon-triangle-1-n');
274    $('#bx_exp_hd').removeClass('box-expander-head');
275    $('#bx_exp_hd').addClass('box-expander-head-active');
276    $('#bx_exp_bd').show('slow');
277    $('#bx_hd_exp').hide('slow');
278    $('#bx_exp_hd').unbind("click");
279    $('#bx_exp_hd').bind('click', function () {
280        Collapse_Info();
281    });
282}
283
284function Collapse_Info() {
285    $('#bx_expander').removeClass('box-expander-body');
286    $('#bx_exp_arrow').addClass('ui-icon-triangle-1-s');
287    $('#bx_exp_arrow').removeClass('ui-icon-triangle-1-n');
288    $('#bx_exp_hd').addClass('box-expander-head');
289    $('#bx_exp_hd').removeClass('box-expander-head-active');
290    $('#bx_exp_bd').hide('slow');
291    $('#bx_hd_exp').show('slow');
292    $('#bx_exp_hd').unbind("click");
293    $('#bx_exp_hd').bind('click', function () {
294        Expand_Info();
295    });
296}
297
298/* Box behaviour design */
299function Expand_Usr_Bx(path, params, output, loadingid) {
300    $(output).show('slow');
301    $('#bx_tp_usr_arrow').removeClass('ui-icon-triangle-1-s');
302    $('#bx_tp_usr_arrow').addClass('ui-icon-triangle-1-n');
303    $('#bx_tp_usr_hd').unbind("click");
304    $('#bx_tp_usr_hd').bind('click', function () {
305        Collapse_Usr_Bx(path, params, output, loadingid);
306    });
307    // ajax request
308    Process_Req(path, params, output, 'GET', loadingid)
309}
310
311function Collapse_Usr_Bx(path, params, output, loadingid) {
312    $('#bx_tp_usr_arrow').addClass('ui-icon-triangle-1-s');
313    $('#bx_tp_usr_arrow').removeClass('ui-icon-triangle-1-n');
314    $('#bx_tp_usr_hd').unbind("click");
315    $('#bx_tp_usr_hd').bind('click', function () {
316        Expand_Usr_Bx(path, params, output, loadingid);
317    });
318    $(output).hide('slow');
319}
320
321//*******************************************
322// Messaging Related JQuery Classes
323//*******************************************
324
325/* JS Function used to send message */
326function Send_Message(path, params, id, toid, subjectid, messageid, msgid) {
327    var to = $('#' + toid).val();
328    var subject = $('#' + subjectid).val();
329    var message = $('#' + messageid).val();
330    if (to == '') {
331        Display_Message('#' + msgid, "Please Enter Valid User ID.", 1, 150);
332        return;
333    }
334    if (message == '') {
335        Display_Message('#' + msgid, "Please Enter Message To Post.", 1, 200);
336        return;
337    }
338    Display_Processing(msgid);
339    Ajax_Process(path, params + "&to=" + to + "&sub=" + subject + "&msg=" + message, id, "POST");
340    $('#' + toid).val('');
341    $('#' + subjectid).val('');
342    $('#' + messageid).val('');
343    $('#' + msgid).val('');
344    $('#msg_cmp').dialog('close');
345    Display_Message('#msgclient', "Message Has Been Sent.", 1, 150);
346
347}
348
349function fb_login(u, redirect) {
350    //Commented by Salman,Perms is depricated instead of it scope is use now
351    //FB.login(function (response) {
352    //        if (response != null) {
353    //            if (response.perms) {
354    //                Process_Login(u, redirect);
355    //            } else {
356    //                // user is logged in, but did not grant any permissions
357    //            }
358    //        } else {
359    //            // user is not logged in
360    //        }
361    //    }, { perms: 'email,user_birthday,user_hometown,publish_stream' });
362
363    FB.login(function (response) {
364        if (response != null) {
365            if (response.authResponse) {
366                Process_Login(u, redirect);
367            } else {
368                // user is logged in, but did not grant any permissions
369            }
370        } else {
371            // user is not logged in
372        }
373    }, { scope: 'email,user_birthday,user_hometown' });
374
375}
376
377
378function Process_Login(u, redirect) {
379    $.ui.dialog.defaults.bgiframe = true;
380    // build loading section
381    loadingtext('#ft_dialog');
382    $("#ft_dialog").dialog({
383        bgiframe: true,
384        autoOpen: false,
385        modal: true
386    });
387    $('#ft_dialog').dialog('open');
388
389    FB.api('/me', function (response) {
390        var fb_data = "uid=" + response.id + "&fn=" + response.first_name + "&ln=" + response.last_name + "&gn=" + response.gender + "&bt=" + response.birthday + "&eml=" + response.email;
391        if (response.hometown != undefined)
392            fb_data = fb_data + "&loc=" + response.hometown.name;
393        if (response.username != undefined)
394            fb_data = fb_data + "&uname=" + response.username;
395        $.ajax({
396            type: 'GET',
397            url: u + "handlers/signup.ashx",
398            data: fb_data,
399            success: function (msg) {
400                switch (msg) {
401                    case "nouid":
402                        document.location = u + "facebook/error.aspx?status=nouid";
403                        break;
404                    case "emailexist":
405                        document.location = u + "facebook/error.aspx?status=emailexist";
406                        break;
407                    case "ucsuccess":
408                        document.location = u + "myaccount/Default.aspx?status=success";
409                        break;
410                    case "csuccess":
411                        document.location = u + "myaccount/Default.aspx?status=success&clg=true";
412                        break;
413                    case "nologinname":
414                        document.location = u + "facebook/error.aspx?status=nologinname";
415                        break;
416                    case "ipblocked":
417                        document.location = u + "IPBlocked.aspx";
418                        break;
419                    case "success":
420                        if (redirect != "") {
421                            document.location = redirect;
422                        }
423                        else
424                            document.location = u + "myaccount/Default.aspx";
425                        break;
426                }
427            }
428        });
429
430    });
431}
432
433function loadingtext(id) {
434    var str = "";
435    str += "<div class=\"item_pad_4_c\">";
436    str += "<img src='..\/images\/loading\/loading7.gif\' style=\"width: 100px;   height: 100px;\" \/>";
437    str += "<\/div>";
438    str += "<div class=\"item_pad_4_c\">";
439    str += "<h3>Please wait for login via facebook.<\/h3>";
440    str += "<\/div>";
441    $(id).html(str);
442}
443function ShowMsg(id, message,messagetype,icontype) {
444    var str = "";
445    var message_class = "ui-state-error";
446    var icon_message = "Alert";
447    var icon_class = "ui-icon-alert";
448    switch (messagetype) {
449        case 0:
450            message_class = "ui-state-error";
451            break;
452        case 1:
453            message_class = "ui-state-highlight";
454            break;
455    }
456    switch (icontype) {
457        case 0:
458            icon_class = "ui-icon-alert";
459            icon_message = "Alert:";
460            break;
461        case 1:
462            icon_class = "ui-icon-info";
463            icon_message = "Info:";
464            break;
465        case 2:
466            icon_class = "ui-icon-check";
467            icon_message = "Success:";
468            break;
469    }
470    str += "<div class=\"item_pad_2 ui-corner-all\"><div class=\"" + message_class + " ui-corner-all\">";
471    str += "<div style=\"float:left; width:85%;\">";
472    str += "<p><span class=\"ui-icon " + icon_class + "\" style=\"float: left; margin-right: .3em;\"></span>";
473    str += "<strong>" + icon_message + "</strong>";
474    str += " " + message + "<\/p><\/div><div style=\"float:right; width:10%; text-align:right;\"><a href=\"javascript:void(0)\" onclick=\"toggle_panel(2,'#" + id + "');\">close<\/a><\/div><div class=\"clear\"><\/div>";
475    str += "<\/div><\/div>";
476    $('#' + id).html(str);
477}
478
479function ConvertSize(size) {
480    var csize = "";
481    if (size > 1000000000) {
482        csize = Math.round(size / 1000000000) + "G";
483    } else if (size > 1000000) {
484        csize = Math.round(size / 1000000) + "M";
485    }
486    else if (size > 1000) {
487        csize = Math.round(size / 1000) + "K";
488    }
489    else {
490        csize = size + "B";
491    }
492
493    return csize;
494}
495

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.