function NewsViewModel(){var a=this;a.News=ko.observableArray([]);a.connectionFailed=ko.observable(!1);a.Url=ko.computed(function(){var b="ExCalc";a.connectionFailed()||(b=Culture.translations().stringPropertyNewsChannel);return ApplicationSettings.atomServiceUrl+b});a.NewsDetails=ko.observable();a.index=ko.observable(0);a.NewsObject=function(b){var e=void 0==b.title?"":b.title,g=void 0==b.link?"":b.link,f=void 0==b.updated?"":b.updated,b=void 0==b.description?"":b.description;Log("content przed: "+
b);b=a.filterContent(b);Log("content po: "+b);var c="<div>"+b+"</div>",d=$(c).find("img").attr("src");$(c+" > style").remove();c=$(c).text();null==d&&(d="");null==c&&(c="");return{title:e,link:g,updated:f,image:d,description:c,content:b}};a.GetFeed=function(b){jQuery.getFeed({url:a.Url(),success:function(b){var g;a.News([]);for(var f=0;f<b.items.length;f++)Log(b.items[f]),g=a.NewsObject(b.items[f]),a.News.push(g);a.News.sort(function(a,b){return a.updated==b.updated?0:a.updated>b.updated?-1:1});Overlay.destroy()}}).fail(b)};
a.GetNews=function(){MainViewModel.checkInternetConnection()&&(Overlay.create(!0,Culture.translations().stringMsgDownloadingNews),a.connectionFailed(!1),a.GetFeed(function(){a.connectionFailed(!0);a.GetFeed(function(){Overlay.hideLoader();Overlay.showTextOnlyLoader(Culture.translations().stringTextInternetConnectionProblem);setTimeout(function(){Overlay.destroy()},2E3)})}))};a.commendNewsDetails=function(b){a.NewsDetails(b);a.index(a.News.indexOf(b));$.mobile.changePage("NewsDetails.html","none",
!0,!0)};a.commandShowPage=function(){""!=a.NewsDetails().link&&window.open(a.NewsDetails().link,"_system","location=yes")};a.commandNewsObjects=function(){a.News.removeAll();a.GetNews()};a.nextNews=function(){a.index(a.News.indexOf(a.NewsDetails()));a.index(a.index()-1);a.NewsDetails("");$.mobile.silentScroll(0);a.NewsDetails(a.News()[a.index()])};a.previousNews=function(){a.index(a.News.indexOf(a.NewsDetails()));a.index(a.index()+1);a.NewsDetails("");$.mobile.silentScroll(0);a.NewsDetails(a.News()[a.index()])};
a.filterContent=function(a){var e=document.createElement("div");e.innerHTML=a;for(a=0;a<ApplicationSettings.atomRemoveTags.length;a++)$(e).find(ApplicationSettings.atomRemoveTags[a]).remove();$(e).find("*").each(function(){if(void 0!=ApplicationSettings.atomEnabledTags[$(this)[0].tagName]){do for(var a=!1,b=$(this).get(0).attributes,c=b.length,d=0;d<c;d++)if(-1==$.inArray(b.item(d).nodeName,ApplicationSettings.atomEnabledTags[$(this)[0].tagName])){$(this).removeAttr(b.item(d).nodeName);a=!0;break}while(a)
}else $(this).replaceWith(function(){return $(this).contents()})});return $(e).html()}};
