1<!doctype html>
2<html lang="en">
3<head>
4<style type="text/css">
5 #author_name {
6 font-weight: bold;
7 }
8 body {
9 padding-top: 1px;
10 }
11 #brand {
12 background-color: #fbfbfb;
13 color: #bbb;
14 font-family: helvetica neue, arial, sans-serif;
15 font-size: 8pt;
16 left: 0px;
17 padding-left: 0.5em;
18 padding-right: 0.5em;
19 position: absolute;
20 top: 0px;
21 }
22 #brand a {
23 color: #aaa;
24 text-decoration: none;
25 }
26</style>
27</head>
28<body>
29 <span id="brand">
30 <a href="https://twitframe.com/?ref=t" target="_blank">Twitframe</a>
31 </span>
32 <blockquote class="twitter-tweet" id="t">
33 <span id="author_name"></span>
34 <span id="author_username"></span>
35 <p>
36 <span id="tweet"></span>
37 </p>
38 <a id="date"></a>
39 </blockquote>
40</body>
41<script>
42
43var params = {};
44location.search.substr(1).split("&").forEach(function(part) {
45 var item = part.split("=");
46 params[item[0]] = decodeURIComponent(item[1]).replace(/\+/g, " ");
47});
48
49var url = params["url"] || "";
50var datetime = (params["datetime"] || 0);
51var tweet = (params["tweet"] ? params["tweet"] : "Loading tweet...");
52var author_name = (params["author_name"] ? params["author_name"] : "");
53var author_username = (params["author_username"] ? params["author_username"] : "");
54var align = params["align"];
55var link_color = params["link_color"];
56var theme = params["theme"];
57var formatted_date = "Unknown date";
58var conversation = params["conversation"];
59
60var m;
61if (m = url.match(/^(https?:)?\/\/(www\.)?twitter\.com\/([^\/]+)\//)) {
62 if (!author_username)
63 author_username = m[3];
64}
65
66if (author_username && author_username.substr(0, 1) != "@")
67 author_username = "@" + author_username;
68
69if (datetime) {
70 var d = new Date(datetime * 1000);
71 formatted_date = d.toDateString();
72}
73
74var t = document.getElementById("t");
75if (align)
76 t.align = align;
77if (link_color)
78 t.setAttribute("data-link-color", link_color);
79if (theme)
80 t.setAttribute("data-theme", theme);
81if (conversation)
82 t.setAttribute("data-conversation", conversation);
83
84var h = "";
85if (author_name)
86 document.getElementById("author_name").innerText = author_name;
87if (author_username)
88 document.getElementById("author_username").innerText = author_username;
89
90document.getElementById("tweet").innerText = tweet;
91
92document.getElementById("date").href = url;
93document.getElementById("date").innerText = formatted_date;
94
95if (!params["force_fail"]) {
96 var s = document.createElement("script");
97 s.src = "https://platform.twitter.com/widgets.js";
98 document.body.appendChild(s);
99}
100
101var caller, _timer, loaded = false;
102var saveCaller = function(e) {
103 if (e.data.element) {
104 caller = e;
105 if (loaded)
106 sendResponse();
107 }
108};
109if (window.addEventListener)
110 window.addEventListener("message", saveCaller, false);
111else
112 window.attachEvent("onmessage", saveCaller);
113
114var lastHeight = 0;
115var loadedTime = window.performance ? window.performance.now() : 0;
116function checkHeight() {
117 if (document.body.scrollHeight != lastHeight && caller) {
118 lastHeight = document.body.scrollHeight;
119 sendResponse();
120 }
121
122 /* give up after a while to save cpu */
123 if (window.performance &&
124 (window.performance.now() - loadedTime > (10 * 1000)))
125 return;
126
127 window.requestAnimationFrame(checkHeight);
128}
129window.requestAnimationFrame(checkHeight);
130
131function sendResponse() {
132 if (caller.data.query == "height")
133 caller.source.postMessage({ element: caller.data.element,
134 height: document.body.scrollHeight + 20 }, caller.origin);
135};
136</script>
137</html>