-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
214 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,214 @@ | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta name="google-signin-scope" content="https://picasaweb.google.com/data/"> | ||
<meta name="google-signin-client_id" content="765859880369-7ouk5plitha96v57hbkbpko5tgnmhv8g.apps.googleusercontent.com"> | ||
<script src="https://apis.google.com/js/platform.js" async defer></script> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> | ||
|
||
<!-- Latest compiled and minified CSS --> | ||
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/bootstrap-table.min.css"> | ||
|
||
<!-- Latest compiled and minified JavaScript --> | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/bootstrap-table.min.js"></script> | ||
|
||
<!-- Latest compiled and minified Locales --> | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/locale/bootstrap-table-en-US.min.js"></script> | ||
|
||
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> | ||
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> | ||
|
||
<style> | ||
div.link { | ||
padding: 10px; | ||
} | ||
|
||
.fixed-table-body { | ||
overflow: visible; | ||
height: auto; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<p> | ||
<a style="display:none; float: left; margin-right: 10px; height: 36px;" class="btn btn-warning" id="sign-out" href="#">Sign out</a> | ||
<div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div> | ||
<div style="clear: both;"></div> | ||
</p> | ||
|
||
<script> | ||
var tableEntries; | ||
|
||
function onSignIn(googleUser) { | ||
// Useful data for your client-side scripts: | ||
var profile = googleUser.getBasicProfile(), | ||
id_token = googleUser.getAuthResponse().id_token, | ||
access_token = googleUser.getAuthResponse().access_token; | ||
|
||
|
||
//console.log("ID: " + profile.getId()); // Don't send this directly to your server! | ||
//console.log("Name: " + profile.getName()); | ||
//console.log("Image URL: " + profile.getImageUrl()); | ||
//console.log("Email: " + profile.getEmail()); | ||
|
||
// The ID token you need to pass to your backend: | ||
|
||
//console.log("ID Token: " + id_token); | ||
jQuery('#sign-out').show(); | ||
|
||
jQuery.ajax( | ||
{ | ||
url: 'https://picasaweb.google.com/data/feed/api/user/' + profile.getId() + '?alt=json&access=all&access_token=' + access_token, | ||
dataType: 'json', | ||
method:'GET', | ||
success: function(data){ | ||
var i, j; | ||
tableEntries = []; | ||
|
||
for(var i=0; i<data.feed.entry.length; i++) { | ||
|
||
var entry = data.feed.entry[i], | ||
title = entry.title.$t, | ||
userid = entry.gphoto$user.$t, | ||
albumid = entry.gphoto$id.$t, | ||
link, | ||
authKeyMatchResult, | ||
tableEntry = {}; | ||
|
||
for(var j=0; j<entry.link.length; j++) { | ||
if (entry.link[j].rel === "alternate") { | ||
tableEntry.link = entry.link[j].href; | ||
} | ||
} | ||
|
||
tableEntry.userid = userid; | ||
tableEntry.title = title; | ||
tableEntry.albumid = albumid; | ||
tableEntry.rights = entry.rights.$t; | ||
tableEntry.authKey = ''; | ||
tableEntry.access_token = access_token; | ||
|
||
authKeyMatchResult = tableEntry.link.match(/authkey=([^&]*)/); | ||
|
||
if (null !== authKeyMatchResult && authKeyMatchResult.length > 1) { | ||
tableEntry.authKey = authKeyMatchResult[1]; | ||
} | ||
|
||
tableEntries.push(tableEntry); | ||
} | ||
|
||
jQuery('#table').bootstrapTable({ | ||
search: true, | ||
columns: [ | ||
{ | ||
field: 'operations', | ||
title: 'Operations', | ||
formatter: function(value) { | ||
var result = '<button data-permission="private" class="btn btn-default change-permission" href="">Make Private</button>'; | ||
result +='<button data-permission="protected" class="btn btn-default change-permission" href="">Make Protected</button>'; | ||
result +='<button data-permission="public" class="btn btn-default change-permission" href="">Make Public</button>'; | ||
return result; | ||
|
||
} | ||
}, | ||
{ | ||
field: 'rights', | ||
title: 'Rights', | ||
sortable: true | ||
}, | ||
{ | ||
field: 'title', | ||
title: 'Title', | ||
sortable: true | ||
}, | ||
{ | ||
field: 'link', | ||
formatter: function(value) { return '<a class="albumlink" href="' + value + '" target="_blank">Link</a>'; }, | ||
title: 'Link' | ||
}, | ||
{ | ||
field: 'userid', | ||
title: 'User ID' | ||
}, { | ||
field: 'albumid', | ||
title: 'Album ID' | ||
}, | ||
{ | ||
field: 'authKey', | ||
title: 'Picasa Key' | ||
} | ||
], data: tableEntries | ||
|
||
}); | ||
|
||
jQuery('#table').on('click-cell.bs.table', function(e, field, value, row, $element){ | ||
|
||
if (field == 'operations') { | ||
return; | ||
} | ||
|
||
console.log('row hit: ', row.link); | ||
if (field !== 'link') { | ||
parent.postMessage(row.link, '*'); | ||
} | ||
}); | ||
|
||
} | ||
}); | ||
}; | ||
|
||
jQuery( document ).ready(function() { | ||
|
||
jQuery(document).on('click', '#sign-out', function(e){ | ||
var auth2 = gapi.auth2.getAuthInstance(); | ||
auth2.signOut().then(function () { | ||
location.reload(); | ||
}); | ||
}); | ||
|
||
jQuery(document).on('click', '.change-permission', function(e){ | ||
e.preventDefault(); | ||
var index = jQuery(e.target).parents('tr').attr('data-index'), | ||
tableEntry = tableEntries[index], | ||
url = 'change_permission.php', | ||
new_access = jQuery(e.target).attr('data-permission'); | ||
|
||
$.ajax({ | ||
url: url, | ||
dataType: 'json', | ||
method:'POST', | ||
data: { | ||
'userid': tableEntry.userid, | ||
'albumid': tableEntry.albumid, | ||
'access_token': tableEntry.access_token, | ||
'new_access': new_access | ||
} | ||
|
||
}) | ||
.done(function( msg ) { | ||
console.log( "Data Saved: " + msg ); | ||
location.reload(); | ||
}); | ||
|
||
}); | ||
|
||
|
||
}); | ||
</script> | ||
|
||
<table id="table" class="table table-striped"></table> | ||
|
||
<script> | ||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | ||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | ||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | ||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); | ||
|
||
ga('create', 'UA-62812-16', 'auto'); | ||
ga('send', 'pageview'); | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |