generated from jonico/octodemo.github.io
-
Notifications
You must be signed in to change notification settings - Fork 1
/
close.html
32 lines (26 loc) · 1.08 KB
/
close.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
---
layout: default
title: Getting Twitter Permissions
id: close-window
permalink: /close/
---
<script>
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
var response = [getUrlParameter('oauth_token'), getUrlParameter('oauth_verifier')];
//console.log('URL Reponse = ' + response);
window.addEventListener('message', function(event) {
//console.log('response hit');
//if (event.origin !== "http://127.0.0.1:4000" || event.origin !== "http://octocat.andrewross.co") return;
// //console.log('message received: ' + event.data,event);
if( response[0] === undefined || response[0] === '' || response.length == 0 ) {
event.source.postMessage('nothing', event.origin);
} else {
event.source.postMessage(response, event.origin);
}
},false);
</script>