<commit_before>var getItemDetails = require('./../../config.js').config.dataService.getItemDetails;

function init(pageTitle, feedItem){
	var page = tabris.create("Page", { title: "Loading...", topLevel: false, _feedItem: feedItem });
	addItemWebView(page,feedItem, pageTitle);

	return page;
}


/*************************
 * Add the webview with the feed content.
 **************************/

var handlers = {
	html : function(webView, itemDetails, container, titleOnLoad){
		webView.set("html", itemDetails.content );
		if(titleOnLoad){
			container.set({title:titleOnLoad});
		}
	},
	url : function(webView, itemDetails, container, titleOnLoad){
		webView.set("url", itemDetails.content );
		if(titleOnLoad){
			webView.on("load",function(){
				container.set({title:titleOnLoad});
			});
		}
	},
};

function addItemWebView(container, feedItem, titleOnLoad){
	var itemWebView = tabris.create('WebView',{ left: 0, right: 0, top: 0, bottom: 0}).appendTo(container);
	container.set('_itemWebView', itemWebView);

	var itemDetails = getItemDetails(feedItem);
	handlers[itemDetails.type] (itemWebView, itemDetails, container, titleOnLoad);
}

function open(pageTitle, feedItem) {
	var p = init(pageTitle, feedItem);
	return p.open();
}

module.exports  = {
	open: open,
	init: init,
	addItemWebView: addItemWebView,
};<commit_msg>open item in new url<commit_after>var getItemDetails = require('./../../config.js').config.dataService.getItemDetails;

function init(pageTitle, feedItem){
	var page = tabris.create("Page", { title: "Loading...", topLevel: false, _feedItem: feedItem });
	addItemWebView(page,feedItem, pageTitle);
	registerPageActions(page, feedItem);

	return page;
}


/*************************
 * Add the webview with the feed content.
 **************************/

var handlers = {
	html : function(webView, itemDetails, container, titleOnLoad){
		webView.set("html", itemDetails.content );
		if(titleOnLoad){
			container.set({title:titleOnLoad});
		}
	},
	url : function(webView, itemDetails, container, titleOnLoad){
		webView.set("url", itemDetails.content );
		if(titleOnLoad){
			webView.on("load",function(){
				container.set({title:titleOnLoad});
			});
		}
	},
};

function addItemWebView(container, feedItem, titleOnLoad){
	var itemWebView = tabris.create('WebView',{ left: 0, right: 0, top: 0, bottom: 0}).appendTo(container);
	container.set('_itemWebView', itemWebView);

	var itemDetails = getItemDetails(feedItem);
	handlers[itemDetails.type] (itemWebView, itemDetails, container, titleOnLoad);
}

function open(pageTitle, feedItem) {
	var p = init(pageTitle, feedItem);
	return p.open();
}

function registerPageActions(page, feedItem){
	//tabris.create("Action", {
	//	placementPriority: "low",
	//	title: " ",
	//	image: {src:"images/info@2x.png", scale:4}
	//}).on("select", function() {
	//	aboutPage.open();
	//});
	//
	//tabris.create("Action", {
	//	placementPriority: "normal",
	//	title: "Bookmark",
	//	//image: {src:"images/search@2x.png", scale:4}
	//}).on("select", function() {
	//	aboutPage.open();
	//});
	
	var openURLAction = tabris.create("Action", {
		placementPriority: "high",
		title: " ",
		image: {src:"images/home@2x.png", scale:4}
	}).on("select", function() {
		var itemDetails = getItemDetails(feedItem);
		var appLauncher = tabris.create("AppLauncher");
		appLauncher.openUrl(itemDetails.link || itemDetails.content);
	});
	page.on("disappear", function(){
		openURLAction.dispose();
	});

}

module.exports  = {
	open: open,
	init: init,
	addItemWebView: addItemWebView,
};
{'fraction_non_alphanumeric': 0.19666572478101157, 'fraction_numerical': 0.003955919751342187, 'mean_word_length': 5.167247386759582, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2242614', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1178, 'n_words': 228}