<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">

(function ($) {
    $.widget("nmk.unsubscribe", {
        options: {
            identifier: "",
            session: "",
            id: 0,
            chk: "",    
            con: "",
            user: function (user) { }
        },
        url: 'json/unsubscribe.ashx',
        currentStatus: 0,
        refresh: function (options2) {
            if (options2)
                this.options = $.extend({}, options2);
            this._load();
        },
        _create: function () {
            this.randomnr = randomFromInterval(0, 99999);
            this._load();
        },
        _download: function (detta, command, id, type) {
            var url = detta.url + '?command=' + command + '&amp;f=' + id + '&amp;_=' + new Date().getTime() + '&amp;session=' + detta.options.session + '&amp;fakturatype=' + type;
            $.fileDownload(url);
        },
        _ajax: function (detta, item, callback) {
            if (item.title == undefined) {
                item.title = "";
            }
            item.session = detta.options.session;
            item.identifier = detta.options.identifier;
            console.log(item);
            if (item.title.length &gt; 0)
                loadingBar(true, 1, "Vänta...", item.title + "...");
            $.ajax({
                url: detta.url,
                error: function (xhr, textStatus, errorThrown) {
                    if (item.title.length &gt; 0)
                        loadingBar(false, 1);
                },
                cache: false,
                data: item,
                type: "POST"
            }).done(function (data) {
                var obj = $.parseJSON(data);
                if (item.title.length &gt; 0)
                    loadingBar(false, 1);
                callback(obj);
                if (obj.checkitem) {
                    detta.options.user(obj.checkitem.medlem);
                }

            });
        },
        item: null,
        _load: function () {
            this.element.empty();
            var detta = this;

            var div = $("&lt;div/&gt;").appendTo(detta.element);
            var item = new Object();
            item.command = "getunsubscribe";
            item.id = detta.options.id;
            item.chk = detta.options.chk;
            item.title = "Hämtar";

            detta._ajax(detta, item, function (obj) {
                if (obj.resultat) {
                    if (detta.options.con == undefined) {
                        detta.options.con = "";
                    }
                    if (detta.options.con == null) {
                        detta.options.con = "";
                    }

                  
                    var unsubscribeFunc = function () {
                        var item = new Object();
                        item.command = "unsubscribe";
                        item.id = detta.options.id;
                        item.chk = detta.options.chk;
                        item.title = "Avslutar...";

                        detta._ajax(detta, item, function (obj) {
                            detta.element.empty();
                            var divButtons = $("&lt;div/&gt;");
                            $("&lt;button/&gt;").appendTo(divButtons).attr("type", "button").addClass("btn btn-primary").attr("data-loading-text", "&lt;i class='fa fa-circle-o-notch fa-spin'&gt;&lt;/i&gt; Stänger").html("Stäng").bind('click', function (e) {
                                e.preventDefault();
                                $(this).button('loading');
                                $(location).attr('href', "default.html");
                            });

                            $("&lt;div/&gt;").appendTo(detta.element).mypanel({
                                header: { text: "Avsluta nyhetsbrev" }, content: { text: obj.text }, footer: {
                                    text: divButtons
                                }
                            });

                        });
                    }


                    if (detta.options.con == "f") {
                        unsubscribeFunc();
                    }
                    else {
                        var divButtons = $("&lt;div/&gt;");
                        $("&lt;button/&gt;").appendTo(divButtons).attr("type", "button").addClass("btn btn-primary").attr("data-loading-text", "&lt;i class='fa fa-circle-o-notch fa-spin'&gt;&lt;/i&gt; Slutför").html("Bekräfta att avsluta nyhetsbrev").bind('click', function (e) {
                            e.preventDefault();
                            $(this).button('loading');

                            unsubscribeFunc();
                        });
                        $("&lt;div/&gt;").appendTo(detta.element).mypanel({
                            header: { text: "Bekräfta" }, content: { text: obj.text }, footer: {
                                text: divButtons
                            }
                        });
                    }
                   




                }
                else {
                    var divButtons = $("&lt;div/&gt;");
                    $("&lt;button/&gt;").appendTo(divButtons).attr("type", "button").addClass("btn btn-primary").attr("data-loading-text", "&lt;i class='fa fa-circle-o-notch fa-spin'&gt;&lt;/i&gt; Stänger").html("Stäng").bind('click', function (e) {
                        e.preventDefault();
                        $(this).button('loading');
                        $(location).attr('href', "default.html");
                    });
                    $("&lt;div/&gt;").appendTo(detta.element).mypanel({
                        header: { text: "Avsluta nyhetsbrev" }, content: { text: obj.text }, footer: {
                            text: divButtons
                        }
                    });
                }
            });

            
           

        },
        destroy: function () {
            this.element.empty();
            // Call the base destroy function.
            $.Widget.prototype.destroy.call(this);
        }
    });
})(jQuery);</pre></body></html>