const BookmarkRouter = {
    template: `
<div class="content">
    <div id="om-msg-cards" class="column pull-right-sm is-four-fifths-desktop">
        <h3>Gespeicherte Nachrichten </h3>
        <MsgCard
            v-for="id in msgDisplay"
            :key="id"
            :msg="messages[id] || {}"
            :isBookmark="bookmarkArray[id]"
        ></MsgCard>
    </div>
</div>`,

    data: function () {
        return {
            messagelist: _messagelist,
            messages: _messages,
            isActive: true,
            messageId: '',
            bookmarkArray: auth.bookmarks,
        }
    },
    computed:{
        msgDisplay: function(){
            return (this.messagelist.slice().reverse());
        }
    },
    methods: {
        myFilter: function() {
            this.isActive = !this.isActive;
        },
        getMessageId: function(){

        },
        getMessages: function(){
            var arr = auth.bookmarks;
            console.log("arr: "+arr+" auth.bookmarks: "+auth.bookmarks);
            _messagelist.splice(0, _messagelist.length);
            _messagelist.push.apply(_messagelist, arr);
            for (var e in arr) {
                if (!_messages[arr[e]]) {
                    //arr[e] =arr[e].replace(/\[/g, '').replace(/\"/g, '').replace(/\]/g, '')
                    console.log("getinsertmessage: "+ arr[e]);
                    get_insert_message(arr[e]);
                }
            }




            /*var _usrid = auth.user;
            $.ajax({
                url: "api/usr/id/" + _usrid,
                method: "GET"
            })
            .done(have_result).fail(have_error);

			function have_result(res) {
				var str = JSON.stringify(res[0].bookmarks).split(",");
                _messagelist.splice(0, _messagelist.length);
                for (var e in str) {
                    if (!_messages[str[e]]) {
                        str[e] =str[e].replace(/\[/g, '').replace(/\"/g, '').replace(/\]/g, '')
                        get_insert_message(str[e]);
                    }
                }
                _messagelist.push.apply(_messagelist, str);
                //console.log("bookmark str: "+str);
			}

			function have_error(err) {
				console.log("error: " + err.responseText);
				console.log(err);
			}*/
        }
    },
    beforeMount: function(){

    },
    mounted: function (){
        this.getMessages();
    },

};
