var ImageUtil = (function () {
    var f = {
        getLogo: function (jObj, logoKey) {
            if (jObj && jObj[logoKey] && jObj[logoKey].length > 0) {
                return jObj[logoKey][0];
            }
            return null;
        },
        getLogoUrl: function (jObj, logoKey, width, height) {
            var jImage = f.getLogo(jObj, logoKey);
            if (jImage) {
                return jImage.url + "?x-oss-process=image/resize,w_" + width + ",h_" + height;
            }
            return "";
        },
        getLogoUrlEx: function (jObj, logoKey, spex) {
            if (spex) {
                var imageSize = spex.split("X");

                return f.getLogoUrl(jObj, logoKey, imageSize[0], imageSize[1]);
            }
            var jImage = f.getLogo(jObj, logoKey);
            if (jImage) {
                return jImage.url;
            }
            return "";
        },

        getUrl: function (fullUrl, width, height) {
            if (fullUrl) {
                return fullUrl + "?x-oss-process=image/resize,w_" + width + ",h_" + height;
            }
            return "";
        },
        getImageList: function (jObj, key, spex) {
            var resultImages = [];
            if (jObj) {
                var images = jObj[key];
                if (images) {
                    var imageSize = spex.split("X");
                    images.map(function (jImage) {
                        var img = {
                            relUrl: f.getUrl(jImage.url, imageSize[0], imageSize[1]),
                            fullUrl: jImage.url
                        };
                        resultImages.push(img);
                    });
                }
            }
            return resultImages;
        },
        getIcon: function (logoUrl) {
            return {
                name: "",
                url: logoUrl,
                thumbUrl: f.getUrl(logoUrl, "500", "500"),
            };
        },
        getVideo: function (videoUrl) {
            return {
                name: videoUrl.substring(videoUrl.lastIndexOf("/") + 1),
                videoUrl: videoUrl,
                url: videoUrl,
                thumbUrl: videoUrl + "?x-oss-process=video/snapshot,t_800",
            };
        }
    };
    return f;
})();