Utils = {}; Utils.normalizeString = function (str) { function normalize(str) { var rExps = [{ re: /[\xC0-\xC6]/g, ch: 'A' }, { re: /[\xE0-\xE6]/g, ch: 'a' }, { re: /[\xC8-\xCB]/g, ch: 'E' }, { re: /[\xE8-\xEB]/g, ch: 'e' }, { re: /[\xCC-\xCF]/g, ch: 'I' }, { re: /[\xEC-\xEF]/g, ch: 'i' }, { re: /[\xD2-\xD6]/g, ch: 'O' }, { re: /[\xF2-\xF6]/g, ch: 'o' }, { re: /[\xD9-\xDC]/g, ch: 'U' }, { re: /[\xF9-\xFC]/g, ch: 'u' }, { re: /[\xDF]/g, ch: 'ss' }, { re: /[\xD1]/g, ch: 'N' }, { re: /[\xF1]/g, ch: 'n'}]; for (var i = 0, len = rExps.length; i < len; i++) str = str.replace(rExps[i].re, rExps[i].ch); return str; } str = str.toLowerCase(); str = normalize(str); str = str.replace( new RegExp("'","g"), ""); str = str.replace( new RegExp("\"", "g") , ""); str = str.replace( new RegExp ("[^a-zA-Z0-9]","gi") , "_"); str = str.replace( new RegExp ("_+","gi"), "_"); str = str.replace( new RegExp ("_+$","gi"), ""); return str; }; Utils.createLinkToGenrePage = function (genreName) { return BASE_URL+'/genres/'+Utils.normalizeString(genreName); }; Utils.createLinkToGamePage = function (gameId,gameName) { return BASE_URL+'/games/'+gameId+'/'+Utils.normalizeString(gameName); }; Utils.ellipsisText = function () { $('.ellipsis_text:visible').each( function(index){ try { if ( $(this).parent().attr("threedots") == null ) { $(this).html($.trim($(this).html())); numOfLines = parseInt( $(this).parent().attr("class").replace("lines",'') ); $(this).parent().ThreeDots({max_rows:numOfLines}); } } catch(e){ }; }); }; Utils.fixUnloadImages = function () { function checkImages() { $(".image_fallback_enabled").each(function(){ var imageDim = imgRealSize(this); if (imageDim.width == 0 || imageDim.width == 28) { // image failed to load $(this).addClass("missing_img"); $(this).attr("alt",""); $(this).attr("title",""); $(this).attr("src","/system/modules/com.exent.owned.cms.utils/resources/img/empty.png"); } }); } setTimeout(checkImages,5000); }; //added function for getting natural size of the images due to ie8 natural width bug function imgRealSize(img) { var $img = $(img); if ($img.prop('naturalWidth') == undefined) { var $tmpImg = $('').attr('src', $img.attr('src')); $img.prop('naturalWidth', $tmpImg[0].width); $img.prop('naturalHeight', $tmpImg[0].height); } return { 'width': $img.prop('naturalWidth'), 'height': $img.prop('naturalHeight') } } Utils.fixUnloadImagesByName = function (imageName) { function checkImagesByName() { $(".image_fallback_enabled_by_name").each(function(){ var imageDim = imgRealSize(this); if (imageDim.width == 0 || imageDim.width == 28) { // image failed to load $(this).addClass("missing_img"); $(this).attr("alt",""); $(this).attr("title",""); $(this).attr("src","/system/modules/com.exent.owned.cms.utils/resources/img/"+imageName+""); } }); } setTimeout(checkImagesByName,5000); }; Utils.createIFrame = function (target,width,height,source,prop) { prop = prop ? prop : {}; prop.name = prop.name ? prop.name : Math.random().toString(36).substring(7); prop.id = prop.id ? prop.id : prop.name; prop.style = prop.style ? prop.style : ""; prop["class"] = prop["class"] ? prop["class"] : ""; if($(target).length==0) { try{ //console.error("error creating iframe in "+target); }catch(e){}; } var frame = $('