Skip to content

Commit

Permalink
new Shawn flairs set replacing Amanda's broken one
Browse files Browse the repository at this point in the history
shorten url when composing a set
  • Loading branch information
sirloon committed May 14, 2016
1 parent 899376e commit 70b6b7f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app.yaml
@@ -1,5 +1,5 @@
application: eventflairs
version: 12
version: 13
runtime: python27
api_version: 1
threadsafe: no
Expand Down
21 changes: 20 additions & 1 deletion choose.html
Expand Up @@ -37,6 +37,9 @@ <h5 class="cart-title">Your Custom Flairs Sets</h5>
<div id="flairs-button-next" style="display: none; text-align: center; background-color: rgb(0, 0, 139); color: white; font-size: 0.8em; background-position: initial initial; background-repeat: initial initial;">Go back to gadget, click "import" and paste</div>
</div>
<div id="custom-icons"></div>
<div style="text-align:center">
<div id="flairs-limit-reached" style="display: none; text-align: center; background-color: rgb(227, 53, 0); color: white; font-size: 0.8em; background-position: initial initial; background-repeat: initial initial;">Limit reached, can't add more...</div>
</div>
</div>
<!-- Header Wrapper -->
<div id="header-wrapper">
Expand Down Expand Up @@ -217,7 +220,18 @@ <h3>Mail</h3>
function selectIcon(elem)
{
var url = elem.src;
// -> extract roo url and check if it exists
// shorten url to save space in userdefault's gadget
// so we can add more icons
$.ajax({
"type":"GET",
"url":"https://eventflairs.appspot.com/shorturl?service=goo.gl&longurl=" + url,"async":false}
).done(function(resp){
url = JSON.parse(resp)['short']
}).fail(function( jqXHR, textStatus ) {
console.log("Will use long URL, cannot shorten URL: " + textStatus);
});

// -> extract root url and check if it exists
var res = splitRootIcon(url);
var icon = res.icon;
var root = res.root;
Expand All @@ -229,6 +243,11 @@ <h3>Mail</h3>
{
userFlairs[root] = [icon];
}
// check max limit (userdefault prefs gadget limit)
if(JSON.stringify(userFlairs).length > 1024) {
$("#flairs-limit-reached").show().delay(2000).fadeOut();
return;
}
// update clipboard content
$("#flairs-button").attr("data-clipboard-text",JSON.stringify(userFlairs));
// add img element
Expand Down
8 changes: 4 additions & 4 deletions static/js/sets.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 70b6b7f

Please sign in to comment.