<commit_before>(function () {
    (function (jQuery) {
        return jQuery.widget("Liip.halloimage", {
            options: {
                editable: null,
                toolbar: null,
                uuid: "",
                searchUrl: "",
                dialogOpts: {
                    autoOpen: false,
                    width: 270,
                    height: 'auto',
                    title: "Insert Images",
                    modal: false,
                    resizable: false,
                    draggable: true,
                    dialogClass: 'halloimage-dialog',
                    close: function (ev, ui) {
                        return jQuery('.image_button').removeClass('ui-state-clicked');
                    }
                },
                dialog: null
            },
            _create: function () {
                var button, buttonset, dialogId, id, insertImage, widget;
                widget = this;
                dialogId = "" + this.options.uuid + "-image-dialog";
                this.options.dialog = jQuery("<div id=\"" + dialogId + "\">                        <div class=\"nav\">                                <ul class=\"tabs\">                                        <li id=\"" + this.options.uuid + "-tab-suggestions\"><img src=\"/bundles/liipvie/img/tabicon_suggestions.png\" /> Suggestions</li>                                        <li id=\"" + this.options.uuid + "-tab-search\"><img src=\"/bundles/liipvie/img/tabicon_search.png\" /> Search</li>                                        <li id=\"" + this.options.uuid + "-tab-upload\"><img src=\"/bundles/liipvie/img/tabicon_upload.png\" /> Upload</li>                                </ul>                                <img src=\"/bundles/liipvie/img/arrow.png\" id=\"" + this.options.uuid + "-tab-activeIndicator\" class=\"tab-activeIndicator\" />                        </div>                        <div class=\"dialogcontent\">                                <div id=\"" + this.options.uuid + "-tab-suggestions-content\" class=\"" + widget.widgetName + "-tab tab-suggestions\">                                        <div class=\"imageThumbnailContainer fixed\"><ul><li><img src=\"http://imagesus.homeaway.com/mda01/badf2e69babf2f6a0e4b680fc373c041c705b891\" class=\"imageThumbnail imageThumbnailActive\" /> </li></ul><br style=\"clear:both\"/>                                                                                                                                    </div>                                        <div class=\"activeImageContainer\">                                                <div class=\"rotationWrapper\">                                                        <div class=\"hintArrow\"></div>                                                        <img src=\"\" id=\"" + this.options.uuid + "-sugg-activeImage\" class=\"activeImage\" />                                                </div>                                                <img src=\"\" id=\"" + this.options.uuid + "-sugg-activeImageBg\" class=\"activeImage activeImageBg\" />                                        </div>                                        <div class=\"metadata\">                                                <label for=\"caption-sugg\">Caption</label><input type=\"text\" id=\"caption-sugg\" />                                                <!--<button id=\"" + this.options.uuid + "-" + widget.widgetName + "-addimage\">Add Image</button>-->                                        </div>                                </div>                                <div id=\"" + this.options.uuid + "-tab-search-content\" class=\"" + widget.widgetName + "-tab tab-search\">                                        <form action=\"" + widget.options.searchUrl + "/?page=1&length=8\" type=\"get\" id=\"" + this.options.uuid + "-" + widget.widgetName + "-searchForm\">                                                <input type=\"text\" class=\"searchInput\" /><input type=\"submit\" id=\"" + this.options.uuid + "-" + widget.widgetName + "-searchButton\" class=\"button searchButton\" value=\"OK\"/>                                        </form>                                        <div class=\"searchResults imageThumbnailContainer\"></div>                                        <div id=\"" + this.options.uuid + "-search-activeImageContainer\" class=\"search-activeImageContainer activeImageContainer\">                                                <div class=\"rotationWrapper\">                                                        <div class=\"hintArrow\"></div>                                                        <img src=\"\" id=\"" + this.options.uuid + "-search-activeImageBg\" class=\"activeImage\" />                                                </div>                                                <img src=\"\" id=\"" + this.options.uuid + "-search-activeImage\" class=\"activeImage activeImageBg\" />                                        </div>                                        <div class=\"metadata\" id=\"metadata-search\" style=\"display: none;\">                                                <label for=\"caption-search\">Caption</label><input type=\"text\" id=\"caption-search\" />                                                <!--<button id=\"" + this.options.uuid + "-" + widget.widgetName + "-addimage\">Add Image</button>-->                                        </div>                                </div>                                <div id=\"" + this.options.uuid + "-tab-upload-content\" class=\"" + widget.widgetName + "-tab tab-upload\">UPLOAD</div>                        </div></div>");
                jQuery(".tab-search form", this.options.dialog).submit(function (event) {
                    var search, showResults, that;
                    event.preventDefault();
                    that = this;
                    showResults = function (response) {
                        var container, firstimage, items;
                        items = [];
                        items.push("<div class=\"pager-prev\" style=\"display:none\"></div>");
                        $.each(response.assets, function (key, val) {
                            return items.push("<img src=\"" + val.url + "\" class=\"imageThumbnail " + widget.widgetName + "-search-imageThumbnail\" /> ");
                        });
                        items.push("<div class=\"pager-next\" style=\"display:none\"></div>");
                        container = jQuery("#" + dialogId + " .tab-search .searchResults");
                        container.html(items.join(''));
                        if (response.page > 1) {
                            jQuery('.pager-prev', container).show();
                        }
                        if (response.page < Math.ceil(response.total / response.length)) {
                            jQuery('.pager-next', container).show();
                        }
                        jQuery('.pager-prev', container).click(function (event) {
                            return search(response.page - 1);
                        });
                        jQuery('.pager-next', container).click(function (event) {
                            return search(response.page + 1);
                        });
                        jQuery("#" + widget.options.uuid + "-search-activeImageContainer").show();
                        firstimage = jQuery("." + widget.widgetName + "-search-imageThumbnail").first().addClass("imageThumbnailActive");
                        jQuery("#" + widget.options.uuid + "-search-activeImage, #" + widget.options.uuid + "-search-activeImageBg").attr("src", firstimage.attr("src"));
                        return jQuery("#metadata-search").show();
                    };
                    search = function (page) {
                        page = page || 1;
                        return jQuery.ajax({
                            type: "GET",
                            url: widget.options.searchUrl,
                            data: "page=" + page + "&length=8",
                            success: showResults
                        });
                    };
                    return search();
                });
                
                insertImage = function () {
                    var img, triggerModified;
                    try {
                        if (!widget.options.editable.getSelection()) {
                            throw new Error("SelectionNotSet");
                        }
                    } catch (error) {
                        widget.options.editable.restoreSelection(widget.lastSelection);
                    }
                    document.execCommand("insertImage", null, $(this).attr('src'));
                    img = document.getSelection().anchorNode.firstChild;
                    jQuery(img).attr("alt", jQuery(".caption").value);
                    triggerModified = function () {
                        return widget.element.trigger("hallomodified");
                    };
                    window.setTimeout(triggerModified, 100);
                    return widget._closeDialog();
                };
                
                this.options.dialog.find(".halloimage-activeImage, #" + widget.options.uuid + "-" + widget.widgetName + "-addimage").click(insertImage);
                buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
                id = "" + this.options.uuid + "-image";
                buttonset.append(jQuery("<input id=\"" + id + "\" type=\"checkbox\" /><label for=\"" + id + "\" class=\"image_button\" >Image</label>").button());
                button = jQuery("#" + id, buttonset);
                button.bind("change", function (event) {
                    if (widget.options.dialog.dialog("isOpen")) {
                        return widget._closeDialog();
                    } else {
                        return widget._openDialog();
                    }
                });
                this.options.editable.element.bind("hallodeactivated", function (event) {
                    return widget._closeDialog();
                });
                jQuery(this.options.editable.element).delegate("img", "click", function (event) {
                    return widget._openDialog();
                });
                jQuery(this.options.dialog).find(".nav li").click(function () {
                    jQuery("." + widget.widgetName + "-tab").each(function () {
                        return jQuery(this).hide();
                    });
                    id = jQuery(this).attr("id");
                    jQuery("#" + id + "-content").show();
                    return jQuery("#" + widget.options.uuid + "-tab-activeIndicator").css("margin-left", jQuery(this).position().left + (jQuery(this).width() / 2));
                });
                jQuery("." + widget.widgetName + "-tab .imageThumbnail").live("click", function (event) {
                    var scope;
                    scope = jQuery(this).closest("." + widget.widgetName + "-tab");
                    jQuery(".imageThumbnail", scope).removeClass("imageThumbnailActive");
                    jQuery(this).addClass("imageThumbnailActive");
                    jQuery(".activeImage", scope).attr("src", jQuery(this).attr("src"));
                    return jQuery(".activeImageBg", scope).attr("src", jQuery(this).attr("src"));
                });
                buttonset.buttonset();
                this.options.toolbar.append(buttonset);
                this.options.dialog.dialog(this.options.dialogOpts);
                return this._addDragnDrop();
            },
            _init: function () {},
            _openDialog: function () {
                var xposition, yposition, responseType;
                
                jQuery('.image_button').addClass('ui-state-clicked');
                jQuery("#" + this.options.uuid + "-sugg-activeImage").attr("src", jQuery("#" + this.options.uuid + "-tab-suggestions-content .imageThumbnailActive").first().attr("src"));
                jQuery("#" + this.options.uuid + "-sugg-activeImageBg").attr("src", jQuery("#" + this.options.uuid + "-tab-suggestions-content .imageThumbnailActive").first().attr("src"));
                
                this.lastSelection = this.options.editable.getSelection();
                
                xposition = jQuery(this.options.editable.element).offset().left + jQuery(this.options.editable.element).outerWidth() - 3;
                yposition = jQuery(this.options.toolbar).offset().top - jQuery(document).scrollTop() - 29;
                this.options.dialog.dialog("option", "position", [xposition, yposition]);
                
                var articleTags = [];
                var tmpArticleTags;
                var tagType;
                tmpArticleTags = jQuery('.inEditMode').parent().find('.articleTags input').val();
                tmpArticleTags = tmpArticleTags.split(',');

                for(var i in tmpArticleTags) {
                    tagType = typeof tmpArticleTags[i];
                    if('string' === tagType) {
                        if(tmpArticleTags[i].indexOf('http') !== -1) articleTags.push(tmpArticleTags[i]);
                    }
                }

                var vie = new VIE();

                vie.use(new vie.DBPediaService({
                    url : "http://dev.iks-project.eu/stanbolfull",
                    proxyDisabled: true
                }));

                jQuery('.imageThumbnailContainer ul').empty();
                jQuery(articleTags).each(function () {
                    vie.load({
                            entity: this + ""
                        }).
                        using('dbpedia').
                        execute().
                        done(function(entity) {
                            jQuery(entity).each(function () {
                                //hint: this.attributes['<http://xmlns.com/foaf/0.1/depiction>'] || 
                                console.log('+++++++++++++++++');
                                if (this.attributes['<http://dbpedia.org/ontology/thumbnail>']) {
                                    responseType = typeof(this.attributes['<http://dbpedia.org/ontology/thumbnail>']);
                                    if(responseType === 'string') {
                                        var img = this.attributes['<http://dbpedia.org/ontology/thumbnail>'];
                                        img = img.substring(1, img.length - 1);
                                    }
                                    if(responseType === 'object') {
                                        var img = '';
                                        img = this.attributes['<http://dbpedia.org/ontology/thumbnail>'][0].value;
                                    }
                                    console.log('image: '+img);
                                    console.log('------------------');
                                    /*$.ajax({
                                        url: img,
                                        crossDomain: true,
                                        type: 'HEAD',
                                        dataType: 'jsonp',
                                        statusCode: {
                                            404: function() {
                                                console.log(img + 'page not found');
                                            }
                                        }
                                    });*/
                                    
                                    jQuery('.imageThumbnailContainer ul').append('<li><img src="'+img+'" class="imageThumbnail"></li>');
                                }
                            });
                        });
                });
                
                return this.options.dialog.dialog("open");
            },
            _closeDialog: function () {
                return this.options.dialog.dialog("close");
            },
            _addDragnDrop: function () {<commit_msg>markup changes on suggested images<commit_after>(function () {
    (function (jQuery) {
        return jQuery.widget("Liip.halloimage", {
            options: {
                editable: null,
                toolbar: null,
                uuid: "",
                searchUrl: "",
                dialogOpts: {
                    autoOpen: false,
                    width: 270,
                    height: 'auto',
                    title: "Insert Images",
                    modal: false,
                    resizable: false,
                    draggable: true,
                    dialogClass: 'halloimage-dialog',
                    close: function (ev, ui) {
                        return jQuery('.image_button').removeClass('ui-state-clicked');
                    }
                },
                dialog: null
            },
            _create: function () {
                var button, buttonset, dialogId, id, insertImage, widget;
                widget = this;
                dialogId = "" + this.options.uuid + "-image-dialog";
                this.options.dialog = jQuery("<div id=\"" + dialogId + "\">                        <div class=\"nav\">                                <ul class=\"tabs\">                                        <li id=\"" + this.options.uuid + "-tab-suggestions\"><img src=\"/bundles/liipvie/img/tabicon_suggestions.png\" /> Suggestions</li>                                        <li id=\"" + this.options.uuid + "-tab-search\"><img src=\"/bundles/liipvie/img/tabicon_search.png\" /> Search</li>                                        <li id=\"" + this.options.uuid + "-tab-upload\"><img src=\"/bundles/liipvie/img/tabicon_upload.png\" /> Upload</li>                                </ul>                                <img src=\"/bundles/liipvie/img/arrow.png\" id=\"" + this.options.uuid + "-tab-activeIndicator\" class=\"tab-activeIndicator\" />                        </div>                        <div class=\"dialogcontent\">                                <div id=\"" + this.options.uuid + "-tab-suggestions-content\" class=\"" + widget.widgetName + "-tab tab-suggestions\">                                        <div class=\"imageThumbnailContainer fixed\"><ul><li><img src=\"http://imagesus.homeaway.com/mda01/badf2e69babf2f6a0e4b680fc373c041c705b891\" class=\"imageThumbnail imageThumbnailActive\" /> </li></ul><br style=\"clear:both\"/>                                                                                                                                    </div>                                        <div class=\"activeImageContainer\">                                                <div class=\"rotationWrapper\">                                                        <div class=\"hintArrow\"></div>                                                        <img src=\"\" id=\"" + this.options.uuid + "-sugg-activeImage\" class=\"activeImage\" />                                                </div>                                                <img src=\"\" id=\"" + this.options.uuid + "-sugg-activeImageBg\" class=\"activeImage activeImageBg\" />                                        </div>                                        <div class=\"metadata\">                                                <label for=\"caption-sugg\">Caption</label><input type=\"text\" id=\"caption-sugg\" />                                                <!--<button id=\"" + this.options.uuid + "-" + widget.widgetName + "-addimage\">Add Image</button>-->                                        </div>                                </div>                                <div id=\"" + this.options.uuid + "-tab-search-content\" class=\"" + widget.widgetName + "-tab tab-search\">                                        <form action=\"" + widget.options.searchUrl + "/?page=1&length=8\" type=\"get\" id=\"" + this.options.uuid + "-" + widget.widgetName + "-searchForm\">                                                <input type=\"text\" class=\"searchInput\" /><input type=\"submit\" id=\"" + this.options.uuid + "-" + widget.widgetName + "-searchButton\" class=\"button searchButton\" value=\"OK\"/>                                        </form>                                        <div class=\"searchResults imageThumbnailContainer\"></div>                                        <div id=\"" + this.options.uuid + "-search-activeImageContainer\" class=\"search-activeImageContainer activeImageContainer\">                                                <div class=\"rotationWrapper\">                                                        <div class=\"hintArrow\"></div>                                                        <img src=\"\" id=\"" + this.options.uuid + "-search-activeImageBg\" class=\"activeImage\" />                                                </div>                                                <img src=\"\" id=\"" + this.options.uuid + "-search-activeImage\" class=\"activeImage activeImageBg\" />                                        </div>                                        <div class=\"metadata\" id=\"metadata-search\" style=\"display: none;\">                                                <label for=\"caption-search\">Caption</label><input type=\"text\" id=\"caption-search\" />                                                <!--<button id=\"" + this.options.uuid + "-" + widget.widgetName + "-addimage\">Add Image</button>-->                                        </div>                                </div>                                <div id=\"" + this.options.uuid + "-tab-upload-content\" class=\"" + widget.widgetName + "-tab tab-upload\">UPLOAD</div>                        </div></div>");
                jQuery(".tab-search form", this.options.dialog).submit(function (event) {
                    var search, showResults, that;
                    event.preventDefault();
                    that = this;
                    showResults = function (response) {
                        var container, firstimage, items;
                        items = [];
                        items.push("<div class=\"pager-prev\" style=\"display:none\"></div>");
                        $.each(response.assets, function (key, val) {
                            return items.push("<img src=\"" + val.url + "\" class=\"imageThumbnail " + widget.widgetName + "-search-imageThumbnail\" /> ");
                        });
                        items.push("<div class=\"pager-next\" style=\"display:none\"></div>");
                        container = jQuery("#" + dialogId + " .tab-search .searchResults");
                        container.html(items.join(''));
                        if (response.page > 1) {
                            jQuery('.pager-prev', container).show();
                        }
                        if (response.page < Math.ceil(response.total / response.length)) {
                            jQuery('.pager-next', container).show();
                        }
                        jQuery('.pager-prev', container).click(function (event) {
                            return search(response.page - 1);
                        });
                        jQuery('.pager-next', container).click(function (event) {
                            return search(response.page + 1);
                        });
                        jQuery("#" + widget.options.uuid + "-search-activeImageContainer").show();
                        firstimage = jQuery("." + widget.widgetName + "-search-imageThumbnail").first().addClass("imageThumbnailActive");
                        jQuery("#" + widget.options.uuid + "-search-activeImage, #" + widget.options.uuid + "-search-activeImageBg").attr("src", firstimage.attr("src"));
                        return jQuery("#metadata-search").show();
                    };
                    search = function (page) {
                        page = page || 1;
                        return jQuery.ajax({
                            type: "GET",
                            url: widget.options.searchUrl,
                            data: "page=" + page + "&length=8",
                            success: showResults
                        });
                    };
                    return search();
                });
                
                insertImage = function () {
                    var img, triggerModified;
                    try {
                        if (!widget.options.editable.getSelection()) {
                            throw new Error("SelectionNotSet");
                        }
                    } catch (error) {
                        widget.options.editable.restoreSelection(widget.lastSelection);
                    }
                    document.execCommand("insertImage", null, $(this).attr('src'));
                    img = document.getSelection().anchorNode.firstChild;
                    jQuery(img).attr("alt", jQuery(".caption").value);
                    triggerModified = function () {
                        return widget.element.trigger("hallomodified");
                    };
                    window.setTimeout(triggerModified, 100);
                    return widget._closeDialog();
                };
                
                this.options.dialog.find(".halloimage-activeImage, #" + widget.options.uuid + "-" + widget.widgetName + "-addimage").click(insertImage);
                buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
                id = "" + this.options.uuid + "-image";
                buttonset.append(jQuery("<input id=\"" + id + "\" type=\"checkbox\" /><label for=\"" + id + "\" class=\"image_button\" >Image</label>").button());
                button = jQuery("#" + id, buttonset);
                button.bind("change", function (event) {
                    if (widget.options.dialog.dialog("isOpen")) {
                        return widget._closeDialog();
                    } else {
                        return widget._openDialog();
                    }
                });
                this.options.editable.element.bind("hallodeactivated", function (event) {
                    return widget._closeDialog();
                });
                jQuery(this.options.editable.element).delegate("img", "click", function (event) {
                    return widget._openDialog();
                });
                jQuery(this.options.dialog).find(".nav li").click(function () {
                    jQuery("." + widget.widgetName + "-tab").each(function () {
                        return jQuery(this).hide();
                    });
                    id = jQuery(this).attr("id");
                    jQuery("#" + id + "-content").show();
                    return jQuery("#" + widget.options.uuid + "-tab-activeIndicator").css("margin-left", jQuery(this).position().left + (jQuery(this).width() / 2));
                });
                jQuery("." + widget.widgetName + "-tab .imageThumbnail").live("click", function (event) {
                    var scope;
                    scope = jQuery(this).closest("." + widget.widgetName + "-tab");
                    jQuery(".imageThumbnail", scope).removeClass("imageThumbnailActive");
                    jQuery(this).addClass("imageThumbnailActive");
                    jQuery(".activeImage", scope).attr("src", jQuery(this).attr("src"));
                    return jQuery(".activeImageBg", scope).attr("src", jQuery(this).attr("src"));
                });
                buttonset.buttonset();
                this.options.toolbar.append(buttonset);
                this.options.dialog.dialog(this.options.dialogOpts);
                return this._addDragnDrop();
            },
            _init: function () {},
            _openDialog: function () {
                var xposition, yposition, responseType;
                
                jQuery('.image_button').addClass('ui-state-clicked');
                jQuery("#" + this.options.uuid + "-sugg-activeImage").attr("src", jQuery("#" + this.options.uuid + "-tab-suggestions-content .imageThumbnailActive").first().attr("src"));
                jQuery("#" + this.options.uuid + "-sugg-activeImageBg").attr("src", jQuery("#" + this.options.uuid + "-tab-suggestions-content .imageThumbnailActive").first().attr("src"));
                
                this.lastSelection = this.options.editable.getSelection();
                
                xposition = jQuery(this.options.editable.element).offset().left + jQuery(this.options.editable.element).outerWidth() - 3;
                yposition = jQuery(this.options.toolbar).offset().top - jQuery(document).scrollTop() - 29;
                this.options.dialog.dialog("option", "position", [xposition, yposition]);
                
                var articleTags = [];
                var tmpArticleTags;
                var tagType;
                tmpArticleTags = jQuery('.inEditMode').parent().find('.articleTags input').val();
                tmpArticleTags = tmpArticleTags.split(',');

                for(var i in tmpArticleTags) {
                    tagType = typeof tmpArticleTags[i];
                    if('string' === tagType) {
                        if(tmpArticleTags[i].indexOf('http') !== -1) articleTags.push(tmpArticleTags[i]);
                    }
                }

                var vie = new VIE();

                vie.use(new vie.DBPediaService({
                    url : "http://dev.iks-project.eu/stanbolfull",
                    proxyDisabled: true
                }));

                jQuery('.imageThumbnailContainer ul').empty();
                jQuery(articleTags).each(function () {
                    vie.load({
                            entity: this + ""
                        }).
                        using('dbpedia').
                        execute().
                        done(function(entity) {
                            jQuery(entity).each(function () {
                                //hint: this.attributes['<http://xmlns.com/foaf/0.1/depiction>'] || 
                                if (this.attributes['<http://dbpedia.org/ontology/thumbnail>']) {
                                    responseType = typeof(this.attributes['<http://dbpedia.org/ontology/thumbnail>']);
                                    if(responseType === 'string') {
                                        var img = this.attributes['<http://dbpedia.org/ontology/thumbnail>'];
                                        img = img.substring(1, img.length - 1);
                                    }
                                    if(responseType === 'object') {
                                        var img = '';
                                        img = this.attributes['<http://dbpedia.org/ontology/thumbnail>'][0].value;
                                    }
                                    jQuery('.imageThumbnailContainer ul').append('<li><img src="'+img+'" class="imageThumbnail"></li>');
                                }
                            });
                        });
                });
                
                return this.options.dialog.dialog("open");
            },
            _closeDialog: function () {
                return this.options.dialog.dialog("close");
            },
            _addDragnDrop: function () {
{'fraction_non_alphanumeric': 0.14277568346691163, 'fraction_numerical': 0.0030728292203883803, 'mean_word_length': 1.1072024564448302, 'pattern_counts': {'":': 0, '<': 181, '<?xml version=': 0, '>': 181, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 174, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '643785', 'n_tokens_mistral': 7017, 'n_tokens_neox': 6612, 'n_words': 1140}