Skip to content

Commit

Permalink
implement messaging for 'invalid' Google Sheets URL
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeGermuska committed Jul 18, 2017
1 parent cbaf558 commit e6dd6b0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
9 changes: 8 additions & 1 deletion website/static/css/site.css
Expand Up @@ -47,4 +47,11 @@ ul#embed-font li img {

#preview-embed {
display: none;
}
}

.note-error {
display: none;
}
.note-error:before {
content: "Warning: "
}
12 changes: 11 additions & 1 deletion website/static/js/main.js
Expand Up @@ -55,6 +55,10 @@ function getLinkAndIframe() {
/* SOURCE KEY
================================================== */
if (e_source.value.match("docs.google.com")) {
if (e_source.value.match(new RegExp('/spreadsheets/d/e'))) {
theobj.warning = "Invalid Google URL. Please see the note above about how a recent change with Google Spreadsheets affects creating timelines.";
return theobj;
}
var obj = TL.ConfigFactory.parseGoogleSpreadsheetURL(e_source.value);
source_key = obj.key;
} else {
Expand Down Expand Up @@ -103,7 +107,7 @@ function getLinkAndIframe() {

if (start_at_end) {
vars += "&start_at_end=" + start_at_end;
}
}

if (timenav_position == "top") {
vars += "&timenav_position=" + timenav_position;
Expand Down Expand Up @@ -150,8 +154,14 @@ function getLinkAndIframe() {
var $ = jQuery;

function updateEmbedCode(element, options) {
$("#embed-source-url-message").hide();
var e_embed = document.getElementById('embed_code'),
el = getLinkAndIframe();
if (el.warning) {
$("#embed-source-url-message").html(el.warning);
$("#embed-source-url-message").css('display','block');
return;
}
e_embed.value = el.copybox;
// document.getElementById('embed_code_medium').val(el.link);
document.getElementById('preview-embed-link').setAttribute('href', el.link);
Expand Down
2 changes: 1 addition & 1 deletion website/templates/_head.html
Expand Up @@ -4,8 +4,8 @@
<meta name="keywords" content="">
<meta name="description" content="Timeline JS is a free, easy-to-use tool for telling stories in a timeline format.">
<link rel="stylesheet" href="https://cloud.webtype.com/css/d4767ecb-457a-4677-8761-72f890add836.css"/>
<link rel="stylesheet" href="/static/css/site.css"/>
<link rel="stylesheet" href="https://cdn.knightlab.com/libs/orangeline/latest/css/orangeline.min.css"/>
<link rel="stylesheet" href="/static/css/site.css"/>

<!-- favicons -->
<link rel="apple-touch-icon" sizes="180x180" href="https://cdn.knightlab.com/libs/orangeline/latest/assets/favicons/apple-touch-icon.png">
Expand Down
1 change: 1 addition & 0 deletions website/templates/_make.html
Expand Up @@ -54,6 +54,7 @@ <h6>Generate your timeline</h6>
<div class="input-group-label column-12">
<label class="input-group-addon" for="inlinelabel">Google Spreadsheet URL</label>
<input type="text" id="embed-source-url" placeholder="1cWqQBZCkX9GpzFtxCWHoqFXCHg-ylTVUWlnrdYMzKUI" name="inlinelabel">
<p id="embed-source-url-message" class="note note-alert note-error"></p>
</div>
<div class="input-group-label column-3">
<label class="input-group-addon" for="inlinelabel">Width</label>
Expand Down

0 comments on commit e6dd6b0

Please sign in to comment.