Commit 680d6478 authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos

Merge branch 'issue21' into 'master'

Issue21 - Ensure cross compatibility between several browsers

See merge request !19
parents 07fef007 cee706d0
......@@ -25,8 +25,9 @@ module.exports = function(grunt) {
'bower_components/jquery/dist/jquery.js',
'bower_components/bootstrap/dist/js/bootstrap.js',
'bower_components/dustjs-linkedin/dist/dust-full.min.js',
'bower_components/dustjs-helpers/dist/dust-helpers.min.js' ],
'min/doi.min.js': [
'bower_components/dustjs-helpers/dist/dust-helpers.min.js',
'bower_components/lodash/dist/lodash.min.js' ],
'min/doi.min.js': [
'src/*js']
}
}
......@@ -77,6 +78,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-css');
grunt.loadNpmTasks('grunt-include-source');
grunt.registerTask('default', ['jshint', 'dustjs', 'uglify', 'cssmin', 'wiredep:prod']);
grunt.registerTask('default', ['jshint', 'dustjs', 'uglify', 'cssmin']);
grunt.registerTask('dev', ['jshint', 'includeSource:dev', 'dustjs', 'cssmin', 'wiredep:dev']);
};
......@@ -28,6 +28,7 @@
"jquery": "^3.2.1",
"dustjs-linkedin": "^2.7.5",
"bootstrap": "^3.3.7",
"dustjs-helpers": "^1.7.3"
"dustjs-helpers": "^1.7.3",
"lodash": "^4.17.5"
}
}
......@@ -21,6 +21,7 @@
<script src="bower_components/dustjs-linkedin/dist/dust-full.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/dustjs-helpers/dist/dust-helpers.min.js"></script>
<script src="bower_components/lodash/lodash.js"></script>
<!-- endbower -->
<!-- Using grunt-include-source, the proper all dustjs templates files (not minified are included below -->
......
......@@ -16,16 +16,10 @@
<script src="/src/doiview.js"></script>
<script src="/src/doicontroller.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var params = new URLSearchParams(document.location.search.substring(1));
var doi;
if (params.get("DOI")){
doi = params.get("DOI");
}
else{
doi = document.location.pathname.substring(1,document.location.pathname.length )
}
new DOIController(new DOIView()).getData(doi);
$(document).ready(function() {
// retrieve the doi code from an url of the format http://doi.esrf.fr/prefix/suffix
var doi = document.location.pathname.substring(1);
new DOIController(new DOIView()).getData(doi);
});
......
This source diff could not be displayed because it is too large. You can view the blob instead.
function DOIController(e){this.server="https://data.datacite.org/",this.sessionId=null,this.acceptedPrefix=["10.5072","10.15151"],this.view=e}function findRegExpInText(e,t){return t.search(e)}function extractFieldsFromCategories(e){var t,n=e.categories;for(t in n)0!=findRegExpInText(/id/,n[t])&&0!=findRegExpInText(/bm/,n[t])||(e.beamline=n[t]);for(t in n)0==findRegExpInText(/\D+-/,n[t])&&(e.proposalNumber=n[t]);for(t in n)-1!=findRegExpInText(/\s/,n[t])&&(e.proposalType=n[t])}function DOIView(){}DOIController.prototype.getData=function(e){var t=this;this.view.setDOI(e),this.hasAcceptedPrefix(e)?$.ajax({headers:{Accept:"application/vnd.citationstyles.csl+json"},type:"GET",url:this.server+e,beforeSend:function(){t.view.setLoading("Retrieving data from Server")},complete:function(){t.view.setLoading(!1)},success:function(e){e?(extractFieldsFromCategories(e),dust.render("esrf-landing-page",{data:e},function(e,t){$("#main").html(t)})):dust.render("doi-not-found-page",{message:"Sorry, the requested DOI was not found."},function(e,t){$("#main").html(t)})},error:function(e,n,i){$("#result").text("error: "+n),dust.render("doi-not-found-page",{message:"Sorry, there was a connexion problem with the datacite server."},function(e,t){$("#main").html(t)}),t.view.setLoading(!1)}}):dust.render("doi-not-found-page",{message:'The DOI was not found at ESRF. (bad prefix). </br> Please use the DOI search engine at <a href="https://www.doi.org"> doi.org</a>.'},function(e,t){$("#main").html(t)})},DOIController.prototype.hasAcceptedPrefix=function(e){var t=e.split("/")[0];return this.acceptedPrefix.includes(t)},DOIView.prototype.setLoading=function(e){0!=e?$("body").addClass("loading"):$("body").removeClass("loading")},DOIView.prototype.setDOI=function(e){$("#doiPanel").html(e)};
\ No newline at end of file
function DOIController(e){this.server="https://data.datacite.org/",this.sessionId=null,this.acceptedPrefix=["10.5072","10.15151"],this.view=e}function findRegExpInText(e,t){return t.search(e)}function extractFieldsFromCategories(e){var t,n=e.categories;for(t in n)0!=findRegExpInText(/id/,n[t])&&0!=findRegExpInText(/bm/,n[t])||(e.beamline=n[t]);for(t in n)0==findRegExpInText(/\D+-/,n[t])&&(e.proposalNumber=n[t]);for(t in n)-1!=findRegExpInText(/\s/,n[t])&&(e.proposalType=n[t])}function DOIView(){}DOIController.prototype.getData=function(e){var t=this;this.view.setDOI(e),this.hasAcceptedPrefix(e)?$.ajax({headers:{Accept:"application/vnd.citationstyles.csl+json"},type:"GET",url:this.server+e,beforeSend:function(){t.view.setLoading("Retrieving data from Server")},complete:function(){t.view.setLoading(!1)},success:function(e){e?(extractFieldsFromCategories(e),dust.render("esrf-landing-page",{data:e},function(e,t){$("#main").html(t)})):dust.render("doi-not-found-page",{message:"Sorry, the requested DOI was not found."},function(e,t){$("#main").html(t)})},error:function(e,n,i){$("#result").text("error: "+n),dust.render("doi-not-found-page",{message:"Sorry, there was a connexion problem with the datacite server."},function(e,t){$("#main").html(t)}),t.view.setLoading(!1)}}):dust.render("doi-not-found-page",{message:'The DOI was not found at ESRF. (bad prefix). </br> Please use the DOI search engine at <a href="https://www.doi.org"> doi.org</a>.'},function(e,t){$("#main").html(t)})},DOIController.prototype.hasAcceptedPrefix=function(e){var t=e.split("/")[0];return-1!=_.findIndex(this.acceptedPrefix,function(e){return t==e})},DOIView.prototype.setLoading=function(e){0!=e?$("body").addClass("loading"):$("body").removeClass("loading")},DOIView.prototype.setDOI=function(e){$("#doiPanel").html(e)};
\ No newline at end of file
......@@ -75,7 +75,7 @@ DOIController.prototype.getData = function(doi) {
// return false otherwise
DOIController.prototype.hasAcceptedPrefix = function(doi) {
var prefix = doi.split('/')[0];
return this.acceptedPrefix.includes(prefix);
return (_.findIndex(this.acceptedPrefix, function(o){ return prefix==o; }) != -1);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment