@knight-lab/timelinejs
Advanced tools
Comparing version 3.8.5 to 3.8.7
{ | ||
"name": "@knight-lab/timelinejs", | ||
"version": "3.8.5", | ||
"version": "3.8.7", | ||
"license": "MPL-2.0", | ||
@@ -5,0 +5,0 @@ "description": "TimelineJS v3: A Storytelling Timeline built in JavaScript, made by Northwestern University Knight Lab.", |
@@ -107,7 +107,15 @@ import { TimelineConfig } from "../core/TimelineConfig" | ||
if (row['Time']) { | ||
mergeData(d.start_date, parseTime(row['Time'])); | ||
if (d.start_date) { | ||
mergeData(d.start_date, parseTime(row['Time'])); | ||
} else { | ||
throw new TLError("invalid_start_time_without_date") | ||
} | ||
} | ||
if (row['End Time']) { | ||
mergeData(d.end_date, parseTime(row['End Time'])); | ||
if (d.end_date) { | ||
mergeData(d.end_date, parseTime(row['End Time'])); | ||
} else { | ||
throw new TLError("invalid_end_time_without_date") | ||
} | ||
} | ||
@@ -114,0 +122,0 @@ |
@@ -26,2 +26,5 @@ /* Adapted from okfn/csv.js under MIT license | ||
function chomp(s, lineterminator) { | ||
if (s == null) return '' | ||
lineterminator = lineterminator || '\n' | ||
@@ -84,3 +87,3 @@ | ||
return { | ||
fields: rows[0].map(chomp), | ||
fields: rows[0].map(x => x.trim()), | ||
records: rows.slice(1) | ||
@@ -87,0 +90,0 @@ }; |
@@ -5,2 +5,4 @@ require('../less/TL.Timeline.less') | ||
export { parseGoogleSpreadsheetURL } | ||
from "./core/ConfigFactory" | ||
from "./core/ConfigFactory" | ||
export { lookupMediaType } | ||
from "./media/MediaType" |
@@ -27,3 +27,3 @@ import { mergeData, pad, trace } from "../core/Util" | ||
var script_path = script_path; | ||
if (/\/$/.test(script_path)) { fragment = fragment.substr(1)} | ||
if (/\/$/.test(script_path)) { fragment = fragment.substr(1) } | ||
var url = script_path + fragment; | ||
@@ -33,3 +33,4 @@ } | ||
var xhr = ajax({ | ||
url: url, async: false | ||
url: url, | ||
async: false | ||
}); | ||
@@ -42,3 +43,3 @@ if (xhr.status == 200) { | ||
} | ||
mergeData(this,LANGUAGES[code]); | ||
mergeData(this, LANGUAGES[code]); | ||
} | ||
@@ -54,3 +55,3 @@ } | ||
if (lang_json[k]) { | ||
if (typeof (this[k]) == 'object') { | ||
if (typeof(this[k]) == 'object') { | ||
mergeData(lang_json[k], this[k]); | ||
@@ -113,3 +114,3 @@ } else { | ||
var self = this; | ||
var formatPeriod = function (fmt, value) { | ||
var formatPeriod = function(fmt, value) { | ||
var formats = self.period_labels[fmt]; | ||
@@ -178,3 +179,3 @@ if (formats) { | ||
var formatted = mask.replace(Language.DATE_FORMAT_TOKENS, function ($0) { | ||
var formatted = mask.replace(Language.DATE_FORMAT_TOKENS, function($0) { | ||
return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); | ||
@@ -205,3 +206,3 @@ }); | ||
function formatNumber(val,mask) { | ||
function formatNumber(val, mask) { | ||
if (mask.match(/%(\.(\d+))?f/)) { | ||
@@ -213,3 +214,3 @@ var match = mask.match(/%(\.(\d+))?f/); | ||
} | ||
return mask.replace(token,val); | ||
return mask.replace(token, val); | ||
} | ||
@@ -251,22 +252,16 @@ // use mask as literal display value. | ||
loading_timeline: "Loading Timeline... ", | ||
swipe_to_navigate: | ||
"Swipe to Navigate<br><span class='tl-button'>OK</span>", | ||
unknown_read_err: | ||
"An unexpected error occurred trying to read your spreadsheet data", | ||
invalid_url_err: | ||
"Unable to read Timeline data. Make sure your URL is for a Google Spreadsheet or a Timeline JSON file.", | ||
invalid_url_share_required: | ||
"Because of unexpected changes to Google's data access API, the creator of this timeline must enable 'anyone with the url can read' access for this spreadsheet. See timeline.knightlab.com for more information.", | ||
network_err: | ||
"Unable to read your Google Spreadsheet. Make sure you have published it to the web.", | ||
swipe_to_navigate: "Swipe to Navigate<br><span class='tl-button'>OK</span>", | ||
unknown_read_err: "An unexpected error occurred trying to read your spreadsheet data", | ||
invalid_url_err: "Unable to read Timeline data. Make sure your URL is for a Google Spreadsheet or a Timeline JSON file.", | ||
invalid_url_share_required: "Because of unexpected changes to Google's data access API, the creator of this timeline must enable 'anyone with the url can read' access for this spreadsheet. See timeline.knightlab.com for more information.", | ||
network_err: "Unable to read your Google Spreadsheet. Make sure you have published it to the web.", | ||
empty_feed_err: "No data entries found", | ||
missing_start_date_err: "Missing start_date", | ||
invalid_data_format_err: "Header row has been modified.", | ||
date_compare_err: | ||
"Can't compare timeline date objects on different scales", | ||
invalid_start_time_without_date: "Invalid configuration: time cannot be used without date.", | ||
invalid_end_time_without_date: "Invalid configuration: end time cannot be used without end date.", | ||
date_compare_err: "Can't compare timeline date objects on different scales", | ||
invalid_scale_err: "Invalid scale", | ||
invalid_date_err: | ||
"Invalid date: month, day and year must be numbers.", | ||
invalid_separator_error: | ||
"Invalid time: misuse of : or . as separator.", | ||
invalid_date_err: "Invalid date: month, day and year must be numbers.", | ||
invalid_separator_error: "Invalid time: misuse of : or . as separator.", | ||
invalid_hour_err: "Invalid time (hour)", | ||
@@ -276,4 +271,3 @@ invalid_minute_err: "Invalid time (minute)", | ||
invalid_fractional_err: "Invalid time (fractional seconds)", | ||
invalid_second_fractional_err: | ||
"Invalid time (seconds and fractional seconds)", | ||
invalid_second_fractional_err: "Invalid time (seconds and fractional seconds)", | ||
invalid_year_err: "Invalid year", | ||
@@ -291,9 +285,6 @@ flickr_notfound_err: "Photo not found or private", | ||
invalid_rgb_err: "Invalid RGB argument", | ||
time_scale_scale_err: | ||
"Don't know how to get date from time for scale", | ||
axis_helper_no_options_err: | ||
"Axis helper must be configured with options", | ||
time_scale_scale_err: "Don't know how to get date from time for scale", | ||
axis_helper_no_options_err: "Axis helper must be configured with options", | ||
axis_helper_scale_err: "No AxisHelper available for scale", | ||
invalid_integer_option: | ||
"Invalid option value—must be a whole number." | ||
invalid_integer_option: "Invalid option value—must be a whole number." | ||
}, | ||
@@ -377,4 +368,3 @@ date: { | ||
time_no_minutes_short: "h TT", | ||
time_no_seconds_small_date: | ||
"h:MM TT' <small>'mmmm d',' yyyy'</small>'", | ||
time_no_seconds_small_date: "h:MM TT' <small>'mmmm d',' yyyy'</small>'", | ||
time_milliseconds: "l", | ||
@@ -381,0 +371,0 @@ full_long: "mmm d',' yyyy 'at' h:MM TT", |
@@ -37,3 +37,16 @@ /* | ||
export function lookupMediaType(m, image_only) { | ||
/** | ||
* Given a URL, or a limited set of non-URL strings, return the class which can | ||
* handle creating and showing an embed in the "media" section of a Timeline slide. | ||
* Used to assess the event.media.url attribute value for Timeline events (or, | ||
* more commonly, the value of the "Media" column of the Google Sheets configuration.) | ||
* | ||
* When the `image_only` argument is true, the input `url_or_text` will only be | ||
* tested against patterns which are known to return images suitable for use as | ||
* thumbnails and backgrounds. | ||
* | ||
* @param {String} url_or_text | ||
* @param {Boolean} image_only | ||
*/ | ||
export function lookupMediaType(url_or_text, image_only) { | ||
var media = {}, | ||
@@ -193,3 +206,3 @@ media_types = [{ | ||
if (image_only) { | ||
if (m instanceof Array) { | ||
if (url_or_text instanceof Array) { | ||
return false; | ||
@@ -202,3 +215,3 @@ } | ||
case "instagram": | ||
if (m.url.match(media_types[i].match_str)) { | ||
if (url_or_text.url.match(media_types[i].match_str)) { | ||
media = media_types[i]; | ||
@@ -215,3 +228,3 @@ return media; | ||
for (var i = 0; i < media_types.length; i++) { | ||
if (m.url.match(media_types[i].match_str)) { | ||
if (url_or_text.url.match(media_types[i].match_str)) { | ||
return media_types[i]; | ||
@@ -218,0 +231,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
5359199
23571