Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Remove duplicates from javascript array

To remove duplicates from JavaScript array.
you can use the following javaScript function, you need JQuery to be able to run this function

distinct: function (anArray) {
        var result = [];
        $.each(anArray, function (i, v) {
            if ($.inArray(v, result) === -1) result.push(v);
        });
        return result;
    }

Remove duplicate options from HTML Select

Some times you get the options from database by ajax duplicated.
The following JavaScript function should do the trick.
You need JQuery to make it work.

dropdown_remove_repeated: function () {
        var $selects = $('select');
        $selects.each(function () {
            var $select = $(this);

            var $options = $select.find('option');

            $options.each(function () {
                var $option = $(this);
                $option.siblings().each(function () {
                    var $this = $(this);
                    if ($this.text().trim() === $option.text().trim()) {
                        $this.remove();
                    }
                });
            });
        });
    }

Removing Watermark from Amazing Carousel Version (4.1)

Someone asked me how to remove the Amazing Carousel Version (4.1) water mark from the free edition

Please just download this File and replace it with your old one.

Remove Amazing Slider Watermark (Version 6.7)

Many of you asked about the latest version of Amazing Slider Version 6.7
Just replace amazingslider.js inside sliderengine folder with my file.

Download File

How to Get Browser Type

// Opera 8.0+
 var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
 // Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// At least Safari 3+: "[object HTMLElementConstructor]"
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
 // Internet Explorer 6-11
 var isIE = /*@cc_on!@*/false || !!document.documentMode;
 // Edge 20+
 var isEdge = !isIE && !!window.StyleMedia;
 // Chrome 1+
 var isChrome = !!window.chrome && !!window.chrome.webstore;
 // Blink engine detection
 var isBlink = (isChrome || isOpera) && !!window.CSS;
 var output = 'Detecting browsers by ducktyping:

'; output += 'isFirefox: ' + isFirefox + '
'; output += 'isChrome: ' + isChrome + '
'; output += 'isSafari: ' + isSafari + '
'; output += 'isOpera: ' + isOpera + '
'; output += 'isIE: ' + isIE + '
'; output += 'isEdge: ' + isEdge + '
'; output += 'isBlink: ' + isBlink + '
'; document.body.innerHTML = output;


How to Disable weekends for AjaxToolKit Calendar extender

if you want to disable the weekends for an ajax toolkit calendar
here is the way.
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:CalendarExtender ID="TextBox1_CalendarExtender" runat="server"
            Enabled="True" TargetControlID="TextBox1" OnClientShown="DisableWeekends">
        </asp:CalendarExtender>
javascript method
           for (var i = 0; i &lt; 6; i++) {
                var row = sender._days.children[0].childNodes[1].children[i];
                for (var j = 0; j &lt; 7; j++) {
                    var cell = row.children[j].firstChild;

                    if (cell.id == sender._id + "_day_" + i + "_" + "5") {
                        cell.style.display = "none";
                    }
                    if (cell.id == sender._id + "_day_" + i + "_" + "6") {
                        cell.style.display = "none";
                    }
                }
            }

Jquery FadeOut table row not working with Internet Explorer

JQuery is write less and do more, we all know that
I have a simple table row and I want to use the fadeOut effect on this row, it is working over all the browsers  except the Internet Explorer "for sure :)"

so I try to find out the problem and whats wrong with Internet Explorer
till I understand this
I have to effect on each child 'cells' of the row before the row it self


var $tr = $(this).parent().parent();

$tr.parent().children().each(function () {
                                $(this).fadeOut('slow');
                            }).fadeOut('slow');

filter attribute that checks whether current connection is secured

using APS.net Core to mark all website pages working with https protocol we will do this using IAuthorizationFilter. and here is an exampl...