Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(505)

Unified Diff: chrome/common/extensions/docs/examples/extensions/news/views/feed.html

Issue 3681008: Improvements to the Google News extension (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/examples/extensions/news/views/feed.html
===================================================================
--- chrome/common/extensions/docs/examples/extensions/news/views/feed.html (revision 0)
+++ chrome/common/extensions/docs/examples/extensions/news/views/feed.html (revision 0)
@@ -0,0 +1,146 @@
+<!DOCTYPE html>
+<!--
+ * Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this
+ * source code is governed by a BSD-style license that can be found in the
+ * LICENSE file.
+-->
+
+<!--
+@fileoverview This file serves as the pop-up page for showing news
+according to the settings saved in options page otherwise shows default
+settings.
+@author navneetg@google.com (Navneet Goel).
+-->
+
+<html>
+<head>
+<script src = "/javascript/util.js"></script>
+<link rel = "stylesheet" href = "/css/feed.css"/>
+
+<script id = "iframe_script">
+
+/**
+ * Facebook share URL.
+ */
+var FB_SHARE_URL = "http://www.facebook.com/sharer.php?u=";
+
+/**
+ * Twitter share URL.
+ */
+var TWITTER_SHARE_URL = "http://twitter.com/share?&url=";
+
+/**
+ * Buzz share URL.
+ */
+var BUZZ_SHARE_URL = "http://www.google.com/buzz/post?&url=";
+
+/**
+ * Opens new window either of facebook, twitter or google buzz.
+ * @param {String} id Specifies whether to share news on Facebook, Google Buzz
+ * or Twitter.
+ * @param {String} url Contains URL of the News to be shared.
+ */
+function openNewsShareWindow(id, url) {
+ var newsUrl = url.substring(url.indexOf('&url=') + 5);
+ var openUrl;
+ switch (id) {
+ case 'fb':
+ openUrl = FB_SHARE_URL;
+ break;
+ case 'buzz':
+ openUrl = BUZZ_SHARE_URL;
+ break;
+ case 'twitter':
+ openUrl = TWITTER_SHARE_URL;
+ break;
+ }
+ window.open(openUrl + newsUrl, '_blank',
+ 'resizable=0,scrollbars=0,width=690,height=415');
+}
+
+/**
+ * Checks language in image url retrieved from feed and sets style of
+ * title and openbox in pop-up page(if url is found), otherwise sets
+ * to default styling.
+ */
+function setStyleByLang(titleImgUrl) {
+ var openBoxes = document.getElementsByClassName('open_box');
+ var itemTitles = document.getElementsByClassName('item_title');
+
+ if (titleImgUrl != 'NULL') {
+ var pattern = /ar_/gi;
+ var result = titleImgUrl.match(pattern);
+ if (result != null || titleImgUrl == ISRAEL_IMAGE_URL) {
+ document.querySelector('body').className = 'rtl';
+ }
+ }
+}
+
+/**
+ * Reports the height.
+ */
+function reportHeight() {
+ var msg = JSON.stringify({type:"size", size:document.body.offsetHeight});
+ parent.postMessage(msg, "*");
+}
+
+/**
+ * Initialize the iframe body.
+ */
+function frameLoaded() {
+ var links = document.getElementsByTagName("A");
+ for (var i = 0, link; link = links[i]; i++) {
+ var class = link.className;
+ if (class != "item_title" && class != "open_box") {
+ link.addEventListener("click", showStory);
+ }
+ }
+ window.addEventListener("message", messageHandler);
+}
+
+/**
+ * Redirects to Google news site according to clicked URL.
+ * @param {Object} event Onclick event.
+ */
+function showStory(event) {
+ var href = event.currentTarget.href;
+ parent.postMessage(JSON.stringify({type:"show", url:href}), "*");
+ event.preventDefault();
+}
+
+/**
+ * Handles message.
+ * @param {Object} event Onmessage event.
+ */
+function messageHandler(event) {
+ reportHeight();
+}
+</script>
+<script src = "/javascript/feed.js"></script>
+</head>
+
+<body onload = "getTopics();getNewsByTitle();" onunload = "saveLastTopic();">
+
+<div style = "margin-bottom: 15px;">
+ <div style = "float: right;">
+ <div style = "float: right; font-size: 11px">
+ <a id = "option_link" onclick = "chrome.tabs.create({url: '/views/options.html', selected: true})">
+ </a>
+ </div>
+ <div style = "margin-top: 27px">
+ <select id = "topics" onchange = "getNewsByTitle();" style = "display: inline;">
+ </select>
+ </div>
+ </div>
+ <a id = "title_a">
+ <img id = "title" style = "padding-top: 5px;">
+ </a>
+</div>
+
+<div id = "feed">
+</div>
+
+<div id = "noStories">
+</div>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698