Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (itemData.notes) {
newItem.info.push({
name: i18next.t("models.ckan.datasetDescription"),
content: itemData.notes
});
// Prevent a description - often the same one - from also coming from the WMS server.
newItem.info.push({
name: i18next.t("models.ckan.datasetDescription"),
content: ""
});
}
if (defined(resource.description)) {
newItem.info.push({
name: i18next.t("models.ckan.resourceDescription"),
content: resource.description
});
}
if (defined(itemData.license_url)) {
newItem.info.push({
name: i18next.t("models.ckan.licence"),
content:
"[" +
(itemData.license_title || itemData.license_url) +
"](" +
itemData.license_url +
")"
});
} else if (defined(itemData.license_title)) {
newItem.info.push({
content: itemData.c
});
}
// If the date string is of format 'dddd-dd-dd*' extract the first part, otherwise we retain the entire date string.
function prettifyDate(date) {
if (date.match(/^\d\d\d\d-\d\d-\d\d.*/)) {
return date.substr(0, 10);
} else {
return date;
}
}
if (defined(itemData.metadata_created)) {
newItem.info.push({
name: i18next.t("models.ckan.metadata_created"),
content: prettifyDate(itemData.metadata_created)
});
}
if (defined(itemData.metadata_modified)) {
newItem.info.push({
name: i18next.t("models.ckan.metadata_modified"),
content: prettifyDate(itemData.metadata_modified)
});
}
if (defined(itemData.update_freq)) {
newItem.info.push({
name: i18next.t("models.ckan.update_freq"),
content: itemData.update_freq
});
}
if (reason) {
send(reason, vote, 0, function () {
window.location = window.location;
});
} else {
var $modal = $(require('./picture-moder-vote/modal.html'));
var $btnSend = $modal.find('.btn-send');
var $btnCancel = $modal.find('.btn-secondary');
var $checkboxLabel = $modal.find('.checkbox span');
$btnSend.addClass(vote > 0 ? 'btn-success' : 'btn-danger');
$modal.find('.modal-title').text(i18next.t("picture-moder-vote/custom/title"));
$btnSend.attr('data-loading-text', i18next.t("picture-moder-vote/custom/sending"));
$btnSend.text(i18next.t("picture-moder-vote/custom/send"));
$btnCancel.text(i18next.t("picture-moder-vote/custom/cancel"));
$checkboxLabel.text(i18next.t("picture-moder-vote/custom/save"));
var $reason = $modal.find(':input[name=reason]');
$modal.on('shown.bs.modal', function () {
$reason.focus();
});
$btnSend.on('click', function () {
reason = $reason.val();
if (reason) {
// $(this).button('loading');
var save = $modal.find(':input[name=save]').val();
} else {
var jsonPromise;
if (zipFileRegex.test(that.url)) {
if (typeof FileReader === "undefined") {
throw new TerriaError({
sender: that,
title: i18next.t("models.geoJson.unsupportedBrowserTitle"),
message: i18next.t("models.geoJson.unsupportedBrowserMessage", {
appName: that.terria.appName,
chrome:
'<a href="http://www.google.com/chrome">' +
i18next.t("models.geoJson.chrome") +
"</a>",
firefox:
'<a href="http://www.mozilla.org/firefox">' +
i18next.t("models.geoJson.firefox") +
"</a>",
internetExplorer:
'<a href="http://www.microsoft.com/ie">' +
i18next.t("models.geoJson.internetExplorer") +
"</a>"
})
});
}
jsonPromise = loadBlob(
proxyCatalogItemUrl(that, that.url, "1d")
).then(function(blob) {
var deferred = when.defer();
zip.createReader(
new zip.BlobReader(blob),
function(reader) {
newItem.info.push({
name: i18next.t("models.ckan.metadata_created"),
content: prettifyDate(itemData.metadata_created)
});
}
if (defined(itemData.metadata_modified)) {
newItem.info.push({
name: i18next.t("models.ckan.metadata_modified"),
content: prettifyDate(itemData.metadata_modified)
});
}
if (defined(itemData.update_freq)) {
newItem.info.push({
name: i18next.t("models.ckan.update_freq"),
content: itemData.update_freq
});
}
newItem.url = url;
var bboxString = itemData.geo_coverage || extras.geo_coverage;
if (defined(bboxString)) {
var parts = bboxString.split(",");
if (parts.length === 4) {
newItem.rectangle = Rectangle.fromDegrees(
parts[0],
parts[1],
parts[2],
parts[3]
);
}).otherwise(function() {
throw new TerriaError({
sender: that,
title: i18next.t("models.geoJson.errorLoadingTitle"),
message: i18next.t("models.geoJson.errorLoadingMessage", {
appName: that.terria.appName,
email:
'<a href="mailto:' +
that.terria.supportEmail +
'">' +
that.terria.supportEmail +
"</a>."
})
});
});
});
: undefined,
dataCustodian: that.dataCustodian,
itemProperties: that.itemProperties
});
if (defined(catalogItem)) {
catalogItem.name = that.name;
return catalogItem;
}
}
throw new TerriaError({
sender: that,
title: i18next.t("models.ckan.notCompatibleTitle"),
message: defined(that.resourceId)
? i18next.t("models.ckan.notCompatibleMessageI", {
resourceId: that.resourceId
})
: i18next.t("models.ckan.notCompatibleMessageII")
});
});
});
sender: that,
title: i18next.t("models.ckan.errorRetrievingUrlTitle"),
message: i18next.t("models.ckan.errorRetrievingUrlMessage", {
url: that.url
})
});
}
if (
!defined(resourceJson.result) ||
!defined(resourceJson.result.package_id)
) {
throw new TerriaError({
sender: that,
title: i18next.t("models.ckan.invalidCkanTitle"),
message: i18next.t("models.ckan.invalidCkanMessage")
});
}
return resourceJson.result.package_id;
});
}
.otherwise(function(e) {
if (e instanceof TerriaError) {
throw e;
}
throw new TerriaError({
sender: that,
title: i18next.t("models.geoJson.couldNotLoadTitle"),
message: i18next.t("models.geoJson.couldNotLoadMessage", {
cors:
'<a href="http://enable-cors.org/">CORS</a>',
email:
'<a href="mailto:' +
that.terria.supportEmail +
'">' +
that.terria.supportEmail +
"</a>."
})
});
});
}
datasetIdPromise = loadJson(resourceUrl).then(function(resourceJson) {
if (!resourceJson.success) {
throw new TerriaError({
sender: that,
title: i18next.t("models.ckan.errorRetrievingUrlTitle"),
message: i18next.t("models.ckan.errorRetrievingUrlMessage", {
url: that.url
})
});
}
if (
!defined(resourceJson.result) ||
!defined(resourceJson.result.package_id)
) {
throw new TerriaError({
sender: that,
title: i18next.t("models.ckan.invalidCkanTitle"),
message: i18next.t("models.ckan.invalidCkanMessage")
});
}