From ee9e97ac9ca17927cbc3622e78e3bcb3740abc4e Mon Sep 17 00:00:00 2001
From: Alejandro De Maria Antolinos <demariaa@esrf.fr>
Date: Wed, 6 Jan 2021 10:54:20 +0100
Subject: [PATCH] Removed forgotten alert

---
 www/min/doi.min.js |   2 -
 www/src/doiview.js | 279 ++++++++++++++++++++++++---------------------
 2 files changed, 147 insertions(+), 134 deletions(-)

diff --git a/www/min/doi.min.js b/www/min/doi.min.js
index 38f53ce..121e782 100644
--- a/www/min/doi.min.js
+++ b/www/min/doi.min.js
@@ -603,8 +603,6 @@ DOIView.prototype.renderMetadata = function(data) {
 };
 
 DOIView.prototype.setDataAccessMessage = function(doiData) {
-    alert("test");
-    console.log(doiData);
     if (doiData.accessibility === "Open access") {
         return "The data can be accessed by clicking on the link below";
     } else if (doiData.accessibility === "Restricted access") {
diff --git a/www/src/doiview.js b/www/src/doiview.js
index 978290b..9ebb0e2 100644
--- a/www/src/doiview.js
+++ b/www/src/doiview.js
@@ -1,29 +1,28 @@
 function DOIView() {
-
-    this.mainPanelId = "main";
-    this.reportPanelId = "expReport";
-    this.badgePanelId = "badges";
-    this.metadataDivId = 'metadata';
-
-    this.reportExperimentFileNames = null;
-    this.failedRecievingExpReport = false;
-    this.isDOIAlreadyRendered = false;
-    this.onDOIRendered = new Event(this);
+  this.mainPanelId = "main";
+  this.reportPanelId = "expReport";
+  this.badgePanelId = "badges";
+  this.metadataDivId = "metadata";
+
+  this.reportExperimentFileNames = null;
+  this.failedRecievingExpReport = false;
+  this.isDOIAlreadyRendered = false;
+  this.onDOIRendered = new Event(this);
 }
 
 DOIView.prototype.setLoading = function (message) {
-    if (message == false) {
-        $("body").removeClass("loading");
-        return;
-    }
-    $("body").addClass("loading");
+  if (message == false) {
+    $("body").removeClass("loading");
+    return;
+  }
+  $("body").addClass("loading");
 };
 
 /**
-* Set the doi prefix/suffix text in the top banner of the doi landing page. This is done before the template is rendered.
-*/
+ * Set the doi prefix/suffix text in the top banner of the doi landing page. This is done before the template is rendered.
+ */
 DOIView.prototype.setDOIInTopBanner = function (doiCode) {
-    $("#doiValue").text("DOI > " + doiCode.toUpperCase());
+  $("#doiValue").text("DOI > " + doiCode.toUpperCase());
 };
 
 /**
@@ -31,150 +30,172 @@ DOIView.prototype.setDOIInTopBanner = function (doiCode) {
  * @param {array} data The filename list to be displayed
  */
 DOIView.prototype.renderExperimentalReportData = function (data) {
-    if (data) {
-        var _this = this;
-        /** Only render the list of files if DOI has already been rendered * */
-        if (this.isDOIAlreadyRendered) {
-            dust.render('experimentalreport_tpl', {
-                data: data
-            }, function (err, out) {
-                $('#' + _this.reportPanelId).html(out);
-            });
-        } else {
-            this.reportExperimentFileNames = data;
+  if (data) {
+    var _this = this;
+    /** Only render the list of files if DOI has already been rendered * */
+    if (this.isDOIAlreadyRendered) {
+      dust.render(
+        "experimentalreport_tpl",
+        {
+          data: data,
+        },
+        function (err, out) {
+          $("#" + _this.reportPanelId).html(out);
         }
+      );
     } else {
-
+      this.reportExperimentFileNames = data;
     }
+  } else {
+  }
 };
 
 DOIView.prototype.renderDOIData = function (doiData) {
-    var _this = this;
-    dust.render('landingpage_tpl', {
-        data: doiData,
-        constants: CONSTANTS
-    }, function (err, out) {
-        $('#' + _this.mainPanelId).html(out);
-        _this.isDOIAlreadyRendered = true;
-        _this.renderBadges(doiData);
-        _this.renderMetadata(doiData);
-        /**
-         * If there are experimental reports already retrieved then render them after
-         * the rendering of the DOI
-         */
-        if (_this.failedRecievingExpReport) {
-            _this.renderErrorForExperimentalReport();
-        } else if (_this.reportExperimentFileNames) {
-            _this.renderExperimentalReportData(_this.reportExperimentFileNames);
-        }
-    });
-
+  var _this = this;
+  dust.render(
+    "landingpage_tpl",
+    {
+      data: doiData,
+      constants: CONSTANTS,
+    },
+    function (err, out) {
+      $("#" + _this.mainPanelId).html(out);
+      _this.isDOIAlreadyRendered = true;
+      _this.renderBadges(doiData);
+      _this.renderMetadata(doiData);
+      /**
+       * If there are experimental reports already retrieved then render them after
+       * the rendering of the DOI
+       */
+      if (_this.failedRecievingExpReport) {
+        _this.renderErrorForExperimentalReport();
+      } else if (_this.reportExperimentFileNames) {
+        _this.renderExperimentalReportData(_this.reportExperimentFileNames);
+      }
+    }
+  );
 };
 /**
  * Render the error message
- * 
+ *
  * @param {string} errorThrown The error which was thrown
  * @param {string} origin The page which caused this rendering. This directly influences the element id
  */
 DOIView.prototype.renderError = function (jqXHR, errorThrown, origin) {
-    var template = ((origin === "welcome-page") ? "doinotfound2_tpl" : "doinotfound_tpl");
-    var message = "";
+  var template = origin === "welcome-page" ? "doinotfound2_tpl" : "doinotfound_tpl";
+  var message = "";
 
-    if (errorThrown === "Bad Prefix") {
-        if (origin === "welcome-page") {
-            message = '<h3> Not found ! </h3> <p> The DOI was not found at ESRF because its prefix is not ESRF specific. Please use the DOI search engine at <a href="https://www.doi.org"> doi.org</a>. </p>';
-        } else {
-            message = '<h2> Not found ! </h2> <p> The DOI was not found at ESRF because its prefix is not ESRF specific. </br> Please use the DOI search engine at <a href="https://www.doi.org"> doi.org</a>. </p>';
-        }
-    } else if (errorThrown === "Not Found") {
-        if (origin === "welcome-page") {
-            message = "<h3> Not found ! </h3> <p> Sorry, the requested DOI was not found. </p>";
-        } else {
-            message = "<h2> Not found ! </h2> <p> Sorry, the requested DOI was not found. </p>";
-        }
-    } else if (errorThrown === "timeout") {
-        if (origin === "welcome-page") {
-            message = "<h3> Not found ! </h3> <p> Sorry, the server took too long to reply. Try again later. </p>";
-        } else {
-            message = "<h2> Not found ! </h2> <p> Sorry, the server took too long to reply. Try again later. </p>";
-        }
-    } else if (errorThrown === "" && jqXHR.responseText === "The resource you are looking for doesn't exist.") {
-        if (origin === "welcome-page") {
-            message = "<h3> Not found ! </h3> <p>It may take up to 24 hours for a newly generated DOI to become available. Please try again later.</p>";
-        } else {
-            message = "<h2> Not found ! </h2> <p>It may take up to 24 hours for a newly generated DOI to become available. Please try again later.</p>";
-        }
+  if (errorThrown === "Bad Prefix") {
+    if (origin === "welcome-page") {
+      message =
+        '<h3> Not found ! </h3> <p> The DOI was not found at ESRF because its prefix is not ESRF specific. Please use the DOI search engine at <a href="https://www.doi.org"> doi.org</a>. </p>';
     } else {
-        if (origin === "welcome-page") {
-            message = "<h3> Not found ! </h3> <p> Connexion problem to the datacite server. Please try again later.</p>";
-        } else {
-            message = "<h2> Not found ! </h2> <p> Connexion problem to the datacite server. Please try again later.</p>";
-        }
+      message =
+        '<h2> Not found ! </h2> <p> The DOI was not found at ESRF because its prefix is not ESRF specific. </br> Please use the DOI search engine at <a href="https://www.doi.org"> doi.org</a>. </p>';
+    }
+  } else if (errorThrown === "Not Found") {
+    if (origin === "welcome-page") {
+      message = "<h3> Not found ! </h3> <p> Sorry, the requested DOI was not found. </p>";
+    } else {
+      message = "<h2> Not found ! </h2> <p> Sorry, the requested DOI was not found. </p>";
     }
-    dust.render(template, {
-        message: message
-    }, function (err, out) {
-        $("#error").html(out);
-    });
+  } else if (errorThrown === "timeout") {
+    if (origin === "welcome-page") {
+      message = "<h3> Not found ! </h3> <p> Sorry, the server took too long to reply. Try again later. </p>";
+    } else {
+      message = "<h2> Not found ! </h2> <p> Sorry, the server took too long to reply. Try again later. </p>";
+    }
+  } else if (errorThrown === "" && jqXHR.responseText === "The resource you are looking for doesn't exist.") {
+    if (origin === "welcome-page") {
+      message =
+        "<h3> Not found ! </h3> <p>It may take up to 24 hours for a newly generated DOI to become available. Please try again later.</p>";
+    } else {
+      message =
+        "<h2> Not found ! </h2> <p>It may take up to 24 hours for a newly generated DOI to become available. Please try again later.</p>";
+    }
+  } else {
+    if (origin === "welcome-page") {
+      message = "<h3> Not found ! </h3> <p> Connexion problem to the datacite server. Please try again later.</p>";
+    } else {
+      message = "<h2> Not found ! </h2> <p> Connexion problem to the datacite server. Please try again later.</p>";
+    }
+  }
+  dust.render(
+    template,
+    {
+      message: message,
+    },
+    function (err, out) {
+      $("#error").html(out);
+    }
+  );
 };
 
 DOIView.prototype.renderErrorForExperimentalReport = function () {
-    this.failedRecievingExpReport = true;
-    var out = '<div class="card-header text-center"> <label>Experimental report </label> </div> <div class="card-body padding10"> <p> The filename list is not available. </p> </div>';
-    $('#' + this.reportPanelId).html(out);
+  this.failedRecievingExpReport = true;
+  var out =
+    '<div class="card-header text-center"> <label>Experimental report </label> </div> <div class="card-body padding10"> <p> The filename list is not available. </p> </div>';
+  $("#" + this.reportPanelId).html(out);
 };
 
-
-
-/** 
+/**
  * Render the badge template in the corresponding div
  * @param {object} data : the doiData object as constructed by the doiController
  */
 DOIView.prototype.renderBadges = function (data) {
-    if (data) {
-        var _this = this;
+  if (data) {
+    var _this = this;
 
-        dust.render('badges_tpl', {
-            data: data,
-            constants: CONSTANTS
-        }, function (err, out) {
-            $('#' + _this.badgePanelId).html(out);
-        });
-    }
+    dust.render(
+      "badges_tpl",
+      {
+        data: data,
+        constants: CONSTANTS,
+      },
+      function (err, out) {
+        $("#" + _this.badgePanelId).html(out);
+      }
+    );
+  }
 };
 
-/** 
+/**
  * Render the badge template in the corresponding div
  */
 DOIView.prototype.renderMetadata = function (data) {
-    if (data) {
-        var _this = this;
-        data.sessionDate = moment(data.sessionDate).format('YYYY-M-D');
-
-        dust.render('metadata_tpl', {
-            data: data,
-            constants: CONSTANTS
-        }, function (err, out) {
-            $('#' + _this.metadataDivId).html(out);
-        });
-    }
+  if (data) {
+    var _this = this;
+    data.sessionDate = moment(data.sessionDate).format("YYYY-M-D");
+
+    dust.render(
+      "metadata_tpl",
+      {
+        data: data,
+        constants: CONSTANTS,
+      },
+      function (err, out) {
+        $("#" + _this.metadataDivId).html(out);
+      }
+    );
+  }
 };
 
 /**
  * Set the message which is displayed just above the "Access data button" in experimental data box.
  * @param {object} doiData json object reference.
- * @return {string} message to display                
+ * @return {string} message to display
  */
 DOIView.prototype.setDataAccessMessage = function (doiData) {
-alert("test");
-    console.log(doiData);
-    if (doiData.accessibility === "Open access") {
-        return "The data can be accessed by clicking on the link below";
-    } else if (doiData.accessibility === "Restricted access") {
-        return "The data are under embargo until <b>" + doiData.publiclyAccessibleYear + "</b> but could be released earlier." +
-            " Currently, they are only accessible to proposal team members.";
-    }
-
+  if (doiData.accessibility === "Open access") {
+    return "The data can be accessed by clicking on the link below";
+  } else if (doiData.accessibility === "Restricted access") {
+    return (
+      "The data are under embargo until <b>" +
+      doiData.publiclyAccessibleYear +
+      "</b> but could be released earlier." +
+      " Currently, they are only accessible to proposal team members."
+    );
+  }
 };
 
 /**
@@ -182,10 +203,7 @@ alert("test");
  * @param {string} data doi metadata in Json+LD format as provided by datacite.
  */
 DOIView.prototype.addDOIMetadataToHead = function (data) {
-    $('<script>')
-        .attr('type', 'application/ld+json')
-        .text(data)
-        .appendTo('head');
+  $("<script>").attr("type", "application/ld+json").text(data).appendTo("head");
 };
 
 /**
@@ -193,8 +211,5 @@ DOIView.prototype.addDOIMetadataToHead = function (data) {
  * @param {String} doiURL URL to the DOI
  */
 DOIView.prototype.addCanonicalURLToHead = function (doiURL) {
-    $('<link>')
-        .attr('rel', 'canonical')
-        .attr('href', doiURL)
-        .appendTo('head');
+  $("<link>").attr("rel", "canonical").attr("href", doiURL).appendTo("head");
 };
-- 
GitLab