first commit

master
Cesare Concordia 3 years ago
parent 3d8343cc06
commit c6c38e4994

@ -0,0 +1,30 @@
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="js/xss.js"></script>
<script type="text/javascript" src="js/audio.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
<link type="text/css" rel="stylesheet" href="css/preview.css"/>
</head>
<body class="container">
<script>
var cType="audio%2Fmpeg";
</script>
<img id='logo'></img>
<H1 class="page-title audioPreviewText">SSHOC Audio Preview
</H1>
<div class='preview-container'>
<div class='preview-header'></div>
<div class='preview'></div>
</div>
</body>
</html>

@ -0,0 +1,27 @@
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/xss.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/audio.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
<link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
</head>
<body class="container">
<img id='logo'></img>
<H1 class="page-title audioPreviewText">Audio Preview
</H1>
<div class='preview-container'>
<div class='preview-header'></div>
<div class='preview'></div>
</div>
</body>
</html>

@ -0,0 +1,30 @@
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="js/xss.js"></script>
<script type="text/javascript" src="
js/html.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
<link type="text/css" rel="stylesheet" href="css/preview.css"/>
</head>
<body class="container">
<script>
var cType="text%2Fhtml";
</script>
<img id='logo'></img>
<H1 class="page-title htmlPreviewText">SSHOC Html Preview
</H1>
<div class='preview-container'>
<div class='preview-header'></div>
<div class='preview'></div>
</div>
</body>
</html>

@ -0,0 +1,26 @@
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/xss.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/html.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
<link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
</head>
<body class="container">
<img id='logo'></img>
<H1 class="page-title htmlPreviewText">Html Preview
</H1>
<div class='preview-container'>
<div class='preview-header'></div>
<div class='preview'></div>
</div>
</body>
</html>

@ -0,0 +1,28 @@
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/xss.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/showdown.min.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/showdown-xss-filter.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/hypothesis.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
<link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
</head>
<body class="container">
<img id='logo'></img>
<H1 class="page-title">
<a href="https://qdr.syr.edu/ati">ATI</a><span class="annotationsText">Annotations</span>
</H1>
<div class='preview-header'></div>
<div class="hypothesis">
</div>
</body>
</html>

@ -0,0 +1,27 @@
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/xss.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/image.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-zoom/1.7.21/jquery.zoom.min.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
<link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
</head>
<body class="container">
<img id='logo'></img>
<H1 class="page-title imagePreviewText">Image Preview
</H1>
<div class='preview-container'>
<div class='preview-header'></div>
<div class='preview'></div>
</div>
</body>
</html>

@ -0,0 +1,43 @@
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="js/xss.js"></script>
<script type="text/javascript" src="js/pdfpreview.js"></script>
<script type="text/javascript" src="js/pdf.js"></script>
<script type="text/javascript" src="js/pdf.worker.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-zoom/1.7.21/jquery.zoom.min.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
<link type="text/css" rel="stylesheet" href="css/preview.css"/>
<link type="text/css" rel="stylesheet" href="css/lds-spinner.css"/>
</head>
<body class="container">
<script>
var cType="application%2Fpdf";
</script>
<img id='logo'></img>
<H1 class="page-title pdfPreviewText">SSHOC PDF Preview
</H1>
<div class='preview-container'>
<div class='preview-header'></div>
<div class='preview'>
<div>
<button id="prev">Previous</button>
<button id="next">Next</button>
&nbsp; &nbsp;
<span class="pageText">Page:</span> <span id="page_num"></span> / <span id="page_count"></span>
</div>
<div class="lds-spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
<canvas id="the-canvas"></canvas>
</div>
</div>
</body>
</html>

@ -0,0 +1,40 @@
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/xss.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/pdfpreview.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/pdf.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/pdf.worker.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-zoom/1.7.21/jquery.zoom.min.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
<link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
<link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/lds-spinner.css"/>
</head>
<body class="container">
<img id='logo'></img>
<H1 class="page-title pdfPreviewText">PDF Preview
</H1>
<div class='preview-container'>
<div class='preview-header'></div>
<div class='preview'>
<div>
<button id="prev">Previous</button>
<button id="next">Next</button>
&nbsp; &nbsp;
<span class="pageText">Page:</span> <span id="page_num"></span> / <span id="page_count"></span>
</div>
<div class="lds-spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
<canvas id="the-canvas"></canvas>
</div>
</div>
</body>
</html>

@ -0,0 +1,23 @@
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/previewers/css/preview.css"/>
</head>
<body class="container">
<script>
var cType="application%2Fpdf";
queryParams = new URLSearchParams(window.location.search.substring(1));
lRSUrl="https://switchboard.clarin.eu/#/dataverse/"+encodeURIComponent(queryParams.get("siteUrl") + "/api/access/datafile/"+ queryParams.get("fileid")+ "?gbrecs=false" )+"/"+cType+queryParams.get("locale");
$(function() {$(location).attr('href',lRSUrl);});
</script>
</body>
</html>

@ -0,0 +1,27 @@
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="js/xss.js"></script>
<script type="text/javascript" src="js/text.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/previewers/css/preview.css"/>
<link type="text/css" rel="stylesheet" href="css/preview.css"/>
</head>
<body class="container">
<script>
var cType="application%2Fpdf";
queryParams = new URLSearchParams(window.location.search.substring(1));
lRSUrl="https://switchboard.clarin.eu/#/d4science/"+encodeURIComponent(queryParams.get("siteUrl") + "/api/access/datafile/"+ queryParams.get("fileid")+ "?gbrecs=false" )+"/"+cType+queryParams.get("locale");
$(function() {$(location).attr('href',lRSUrl);});
</script>
</body>
</html>

@ -0,0 +1,23 @@
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/previewers/css/preview.css"/>
</head>
<body class="container">
<script>
var cType="text%2Fplain";
queryParams = new URLSearchParams(window.location.search.substring(1));
lRSUrl="https://switchboard.clarin.eu/#/dataverse/"+encodeURIComponent(queryParams.get("siteUrl") + "/api/access/datafile/"+ queryParams.get("fileid")+ "?gbrecs=false" )+"/"+cType+"/en";
//alert(lRSUrl);
$(function() {$(location).attr('href',lRSUrl);});
</script>
</body>
</html>

@ -0,0 +1,36 @@
<html >
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="js/xss.js"></script>
<script src="https://cdn.jsdelivr.net/handsontable/0.28.4/handsontable.full.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/papaparse@5"></script>
<script type="text/javascript" src="js/spreadsheet.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-zoom/1.7.21/jquery.zoom.min.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/handsontable/0.28.4/handsontable.full.min.css">
<link type="text/css" rel="stylesheet" href="css/preview.css"/>
</head>
<body class="container">
<script>
var cType="text%2Ftab-separated-values";
</script>
<img id='logo'></img>
<H1 class="page-title spreadsheetViewerText">SSHOC Spreadsheet Viewer
</H1>
<div class='preview-container'>
<div class='preview-header'></div>
<div class='preview'>
<div id="handsontable-container"></div>
</div>
</div>
</body>
</html>

@ -0,0 +1,33 @@
<html >
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/xss.js"></script>
<script src="https://cdn.jsdelivr.net/handsontable/0.28.4/handsontable.full.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/papaparse@5"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/spreadsheet.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-zoom/1.7.21/jquery.zoom.min.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/handsontable/0.28.4/handsontable.full.min.css">
<link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
</head>
<body class="container">
<img id='logo'></img>
<H1 class="page-title spreadsheetViewerText">Spreadsheet Viewer
</H1>
<div class='preview-container'>
<div class='preview-header'></div>
<div class='preview'>
<div id="handsontable-container"></div>
</div>
</div>
</body>
</html>

@ -0,0 +1,30 @@
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="js/xss.js"></script>
<script type="text/javascript" src="js/text.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/previewers/css/preview.css"/>
<link type="text/css" rel="stylesheet" href="css/preview.css"/>
</head>
<body class="container">
<script>
var cType="text%2Fplain";
</script>
<img id='logo'></img>
<H1 class="page-title textPreviewText">SSHOC Text Preview
</H1>
<div class='preview-container'>
<div class='preview-header'></div>
<div class='preview'></div>
</div>
</body>
</html>

@ -0,0 +1,27 @@
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/xss.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/text.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
<link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
</head>
<body class="container">
<img id='logo'></img>
<H1 class="page-title textPreviewText">Text Preview
</H1>
<div class='preview-container'>
<div class='preview-header'></div>
<div class='preview'></div>
</div>
</body>
</html>

@ -0,0 +1,26 @@
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/xss.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/video.js"></script>
<script src="lib/jquery.i18n.js"></script>
<script src="lib/jquery.i18n.messagestore.js"></script>
<script src="lib/jquery.i18n.language.js"></script>
<script type="text/javascript" src="/dataverse-previewers/previewers/js/retriever.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous"><link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
<link type="text/css" rel="stylesheet" href="/dataverse-previewers/previewers/css/preview.css"/>
</head>
<body class="container">
<img id='logo'></img>
<H1 class="page-title videoPreviewText">Video Preview
</H1>
<div class='preview-container'>
<div class='preview-header'></div>
<div class='preview'></div>
</div>
</body>
</html>

@ -0,0 +1,76 @@
.lds-spinner {
color: official;
position: relative;
margin: 20% 10% 10% 30%;
}
.lds-spinner div {
transform-origin: 128px 128px;
animation: lds-spinner 1.2s linear infinite;
}
.lds-spinner div:after {
content: " ";
display: block;
position: absolute;
top: 3px;
left: 122px;
width: 10px;
height: 64px;
border-radius: 20%;
background: #999;
}
.lds-spinner div:nth-child(1) {
transform: rotate(0deg);
animation-delay: -1.1s;
}
.lds-spinner div:nth-child(2) {
transform: rotate(30deg);
animation-delay: -1s;
}
.lds-spinner div:nth-child(3) {
transform: rotate(60deg);
animation-delay: -0.9s;
}
.lds-spinner div:nth-child(4) {
transform: rotate(90deg);
animation-delay: -0.8s;
}
.lds-spinner div:nth-child(5) {
transform: rotate(120deg);
animation-delay: -0.7s;
}
.lds-spinner div:nth-child(6) {
transform: rotate(150deg);
animation-delay: -0.6s;
}
.lds-spinner div:nth-child(7) {
transform: rotate(180deg);
animation-delay: -0.5s;
}
.lds-spinner div:nth-child(8) {
transform: rotate(210deg);
animation-delay: -0.4s;
}
.lds-spinner div:nth-child(9) {
transform: rotate(240deg);
animation-delay: -0.3s;
}
.lds-spinner div:nth-child(10) {
transform: rotate(270deg);
animation-delay: -0.2s;
}
.lds-spinner div:nth-child(11) {
transform: rotate(300deg);
animation-delay: -0.1s;
}
.lds-spinner div:nth-child(12) {
transform: rotate(330deg);
animation-delay: 0s;
}
@keyframes lds-spinner {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}

@ -0,0 +1,135 @@
.page-title {
display: inline-block;
width: 58%;
text-align:center;
}
.page-title a {
color: #56B7CB;
}
.preview-header {
font-size:14px;
font-family: sans-serif;
color: darkslategray;
overflow-wrap: break-word;
margin-bottom: 10px;
background: #ECF6FB;
border-color: #9acfea;
border-style: solid;
border-width:1px;
padding: 15px 15px 5px 15px;
}
.preview-header div {
margin: 10px 5px 5px 0px;
}
.preview-header #filename {
font-size: 16px;
}
.preview-header #dataset {
font-style: italic;
}
.preview-note {
float:right;
font-size: 12px;
padding-top:20px;
}
.preview-container {
margin-left: 40px;
}
.preview {
margin: 0 auto;
padding: 10px 10px 5px 10px;
}
.preview audio {
margin:20px auto;
display: table;
}
.preview video {
margin:20px auto;
min-width:600px;
display: table;
}
#logo {
display: inline-block;
margin-left: 40px;
width: 240px;
min-height:140px;
}
#footer {
font-size: x-small;
float: right;
}
}
.annotation-note {
float:right;
font-size: 12px;
padding-top:20px;
}
.annotation-card {
font-size: 13px;
line-height: 15px;
font-weight: 400;
border: 1px solid #ececec;
list-style: none;
padding: 15px;
margin-bottom: 10px;
box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
background: #fff;
overflow-wrap: break-word;
}
.annotation-card__text {
overflow-wrap: break-word;
}
.annotation-card__text img {
max-width:100%;
}
.annotation-card__quote {
padding: 0 10px;
overflow-wrap: break-word;
color: #a6a6a6;
font-family: sans-serif;
font-size: 12px;
font-style: italic;
letter-spacing: .1px;
border-left: 3px solid #dbdbdb;
margin-bottom: 10px;
}
.annotation-card__tags {
display: -ms-flexbox;
display: flex;
-ms-flex-direction: row;
flex-direction: row;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.annotation-card__tag {
text-decoration: none;
border: 1px solid #dbdbdb;
border-radius: 2px;
padding: 0 5px 2px;
color: #7a7a7a;
background: #f2f2f2;
margin: 0 5px 5px 0;
font-size: 11px;
cursor: pointer;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.annotation_raw {
max-height:500px;
word-break:break-all;
overflow-y:auto;
}

@ -0,0 +1,25 @@
{
"filenameText": "Filename: ",
"inText": "In ",
"byText": ", by ",
"uploadedOnText": "File uploaded on ",
"downloadFileText": "Download File",
"closePreviewText": "Close Preview",
"audioPreviewText": "SSHOC Audio Preview",
"csvPreviewText": "Csv Preview",
"htmlPreviewText": "Html Preview",
"annotationsText": "Annotations",
"imagePreviewText": "Image Preview",
"pdfPreviewText": "SSHOC PDF Preview",
"spreadsheetViewerText": "SSHOC Spreadsheet Viewer",
"textPreviewText": "SSHOC Text Preview",
"videoPreviewText": "Video Preview",
"prev": "Previous",
"next": "Next",
"pageText": "Page:",
"versionText": "version",
"LRSText": "Process with Language Resource Switchboard",
"descriptionText": "Description: ",
"footer": "The SSHOC Previewer, developed by Cesare Concordia, is based on the one developed by <a href=\"https://qdr.syr.edu\">QDR</a> and maintained at <a href=\"https://github.com/GlobalDataverseCommunityConsortium/dataverse-previewers\">https://github.com/GlobalDataverseCommunityConsortium/dataverse-previewers</a>.",
"errorText" : "Please try again. The most common issue is that your login has timed out. If the problem persists, please contact the support team of this data repository. Please include any status code included at the end of this message: "
}

@ -0,0 +1,24 @@
{
"filenameText": "Filename: ",
"inText": "In ",
"byText": ", by ",
"uploadedOnText": "File uploaded on ",
"downloadFileText": "Download File",
"closePreviewText": "Close Preview",
"audioPreviewText": "Audio Preview",
"csvPreviewText": "Csv Preview",
"htmlPreviewText": "Html Preview",
"annotationsText": "Annotations",
"imagePreviewText": "Image Preview",
"pdfPreviewText": "PDF Preview",
"spreadsheetViewerText": "Spreadsheet Viewer",
"textPreviewText": "Text Preview",
"videoPreviewText": "Video Preview",
"prev": "Previous",
"next": "Next",
"pageText": "Page:",
"versionText": "version",
"descriptionText": "Description: ",
"footer": "Previewers originally developed by <a href=\"https://qdr.syr.edu\">QDR</a> and maintained at <a href=\"https://github.com/GlobalDataverseCommunityConsortium/dataverse-previewers\">https://github.com/GlobalDataverseCommunityConsortium/dataverse-previewers</a>. Feedback and contributions welcome.",
"errorText" : "Please try again. The most common issue is that your login has timed out. If the problem persists, please contact the support team of this data repository. Please include any status code included at the end of this message: "
}

@ -0,0 +1,25 @@
{
"filenameText": "Nombre del fichero: ",
"inText": "En ",
"byText": ", por ",
"uploadedOnText": "Fichero subido el ",
"downloadFileText": "Descargar fichero",
"closePreviewText": "Cerrar previsualización",
"audioPreviewText": "SSHOC Previsualización de audio",
"csvPreviewText": "Previsualización de csv",
"htmlPreviewText": "Previsualización de html",
"annotationsText": "Anotaciones",
"imagePreviewText": "Previsualización de imagen",
"pdfPreviewText": "SSHOC Previsualización de pdf",
"spreadsheetViewerText": "SSHOC Visor de hojas de cálculo",
"textPreviewText": "Previsualización de texto",
"videoPreviewText": "Previsualización de vídeo",
"prev": "Anterior",
"next": "Siguiente",
"pageText": "Página:",
"versionText": "versión",
"LRSText": "Process with Language Resource Switchboard",
"descriptionText": "Descripción: ",
"footer": "The SSHOC Previewer, developed by Cesare Concordia, is based on the one developed by <a href=\"https://qdr.syr.edu\">QDR</a> and maintained at <a href=\"https://github.com/GlobalDataverseCommunityConsortium/dataverse-previewers\">https://github.com/GlobalDataverseCommunityConsortium/dataverse-previewers</a>.",
"errorText" : "Inténtelo de nuevo por favor. El problema más común es que su sesión haya caducado. Si el problema continúa puede contactar con el equipo de soporte de su repositorio de datos. Por favor, indique los códigos de estado que encontrará al final de este mensaje: "
}

@ -0,0 +1,25 @@
{
"filenameText": "Nom du fichier: ",
"inText": "Dans ",
"byText": ", par ",
"uploadedOnText": "Fichier téléversé le ",
"downloadFileText": "Télécharger le fichier",
"closePreviewText": "Fermer l'aperçu",
"audioPreviewText": "SSHOC Aperçu audio",
"csvPreviewText": "Aperçu CSV",
"htmlPreviewText": "Aperçu HTML",
"annotationsText": "Annotations",
"imagePreviewText": "Aperçu image",
"pdfPreviewText": "SSHOC Aperçu PDF",
"spreadsheetViewerText": "SSHOC Visualisateur de feuille de calcul",
"textPreviewText": "Aperçu texte",
"videoPreviewText": "Aperçu vidéo",
"prev": "Précédent",
"next": "Suivant",
"pageText": "Page:",
"versionText": "version",
"LRSText": "Process with Language Resource Switchboard",
"descriptionText": "Description: ",
"footer": "The SSHOC Previewer, developed by Cesare Concordia, is based on the one developed by <a href=\"https://qdr.syr.edu\">QDR</a> and maintained at <a href=\"https://github.com/GlobalDataverseCommunityConsortium/dataverse-previewers\">https://github.com/GlobalDataverseCommunityConsortium/dataverse-previewers</a>.",
"errorText" : "Veuillez réessayer. Le problème le plus commun est que votre session a expiré. Si le problème persiste, veuillez communiquer avec l'équipe de soutien pour ce dépôt de données. Veuillez fournir le code indiqué à la fin du présent message : "
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

@ -0,0 +1,14 @@
$(document).ready(function() {
startPreview(false);
});
function translateBaseHtmlPage() {
var audioPreviewText = $.i18n( "audioPreviewText" );
$( '.audioPreviewText' ).text( audioPreviewText );
}
function writeContent(fileUrl, file, title, authors) {
addStandardPreviewHeader(file, title, authors);
$('.preview').append($("<audio/>").attr("controls","").attr("src",fileUrl));
}

@ -0,0 +1,16 @@
$(document).ready(function() {
startPreview(true);
});
function translateBaseHtmlPage() {
var htmlPreviewText = $.i18n( "htmlPreviewText" );
$( '.htmlPreviewText' ).text( htmlPreviewText );
}
function writeContentAndData(data, fileUrl, file, title, authors) {
addStandardPreviewHeader(file,title, authors);
options = {"stripIgnoreTag":true,
"stripIgnoreTagBody":['script','head']}; // Custom rules
$('.preview').append($("<div/>").html(filterXSS(data,options)));
}

@ -0,0 +1,87 @@
$(document).ready(function() {
startPreview(true);
});
function translateBaseHtmlPage() {
var annotationsText = $.i18n( "annotationsText" );
$( '.annotationsText' ).text( annotationsText );
}
function writeContentAndData(data, fileUrl, file, title, authors) {
addStandardPreviewHeader(file,title, authors);
var json = JSON.parse(data);
$(".preview-note").text(
json.total + " annotations, retrieved on " + file.creationDate);
$("<div/>").attr('id','incontext').addClass("btn btn-default").append(
$("<a/>").attr("href", json.rows[0].links.incontext).text(
"View Annotations In Context")).insertBefore($('.preview-header>.btn')[0]);
// Order by TextPositionSelector.start
json.rows.sort(annotationCompare);
// Create header block
var hypo = $(".hypothesis");
if (json.rows.length > 0) {
var converter = new showdown.Converter({
extensions : [ 'xssFilter' ]
});
hypo.html("");
//Display annotations
var list = $("<ol>").appendTo(hypo);
for ( var row in json.rows) {
var selectors = json.rows[row].target[0].selector;
var quote = "";
for ( var k in selectors) {
if (selectors[k].type == "TextQuoteSelector") {
quote = selectors[k].exact;
}
}
var created = json.rows[row].created;
list
.append($('<li class="annotation-card">')
.append(
$(
'<blockquote class="annotation-card__quote" title="Annotation quote">')
.text(quote))
.append(
$('<div class="annotation-card__text">')
.html(
converter
.makeHtml(json.rows[row].text))));
var tags = ($('<div class="annotation-card__tags" title="Tags">'))
.appendTo(list);
for ( var j in json.rows[row].tags) {
tags.append($('<div class="annotation-card__tag">').text(
json.rows[row].tags[j]));
}
}
$('.annotation-card__text a').attr("rel", "noopener nofollow").attr(
"target", "_blank");
}
}
function annotationCompare(a, b) {
var aPosition = 0;
var bPosition = 0;
for ( var j in a.target[0].selector) {
if (a.target[0].selector[j].type === "TextPositionSelector") {
aPosition = a.target[0].selector[j].start;
}
}
for ( var j in b.target[0].selector) {
if (b.target[0].selector[j].type === "TextPositionSelector") {
bPosition = b.target[0].selector[j].start;
}
}
if (aPosition < bPosition)
return -1;
if (aPosition > bPosition)
return 1;
return 0;
}

@ -0,0 +1,18 @@
$(document).ready(function() {
startPreview(false);
});
function translateBaseHtmlPage() {
var imagePreviewText = $.i18n( "imagePreviewText" );
$( '.imagePreviewText' ).text( imagePreviewText );
}
function writeContent(fileUrl, file, title, authors) {
addStandardPreviewHeader(file, title, authors);
$('.preview').append($('<img/>').attr('style','max-width:100%').attr('src',fileUrl).attr('id','previewImage'));
$("#previewImage")
.wrap('<span style="display:inline-block"></span>')
.css('display', 'block')
.parent()
.zoom({on:'grab'});
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,122 @@
var pdfDoc = null,
pageNum = 1,
pageRendering = false,
pageNumPending = null,
scale = 1.2,
canvas = null,
ctx = null;
$(document)
.ready(
function() {
canvas = document.getElementById('the-canvas');
ctx = canvas.getContext('2d');
document.getElementById('prev').addEventListener('click', onPrevPage);
document.getElementById('next').addEventListener('click', onNextPage);
startPreview(false);
});
function translateBaseHtmlPage() {
//PDF Previewer has prev, next, and Page text on it along with the previewer title
var pdfPreviewText = $.i18n( "pdfPreviewText" );
$( '.pdfPreviewText' ).text( pdfPreviewText );
var prev = $.i18n( "prev" );
$( '#prev' ).text( prev );
var next = $.i18n( "next" );
$( '#next' ).text( next );
var pageText = $.i18n( "pageText" );
$( '.pageText' ).text( pageText );
}
function writeContent(fileUrl, file, title, authors) {
addStandardPreviewHeader(file, title, authors);
// Loaded via <script> tag, create shortcut to access PDF.js exports.
var pdfjsLib = window['pdfjs-dist/build/pdf'];
// The workerSrc property shall be specified.
pdfjsLib.GlobalWorkerOptions.workerSrc = '/dataverse-previewers/previewers/js/pdf.worker.js';
/**
* Asynchronously downloads PDF.
*/
pdfjsLib.getDocument(fileUrl).promise.then(function(pdfDoc_) {
pdfDoc = pdfDoc_;
document.getElementById('page_count').textContent = pdfDoc.numPages;
// Initial/first page rendering
renderPage(pageNum);
});
}
/**
* Get page info from document, resize canvas accordingly, and render page.
* @param num Page number.
*/
function renderPage(num) {
pageRendering = true;
// Using promise to fetch the page
pdfDoc.getPage(num).then(function(page) {
var viewport = page.getViewport({scale: scale});
canvas.height = viewport.height;
canvas.width = viewport.width;
// Render PDF page into canvas context
var renderContext = {
canvasContext: ctx,
viewport: viewport
};
var renderTask = page.render(renderContext);
// Wait for rendering to finish
renderTask.promise.then(function() {
$('.lds-spinner').hide();
pageRendering = false;
if (pageNumPending !== null) {
// New page rendering is pending
renderPage(pageNumPending);
pageNumPending = null;
}
});
});
// Update page counters
document.getElementById('page_num').textContent = num;
}
/**
* If another page rendering in progress, waits until the rendering is
* finised. Otherwise, executes rendering immediately.
*/
function queueRenderPage(num) {
if (pageRendering) {
pageNumPending = num;
} else {
renderPage(num);
}
}
/**
* Displays previous page.
*/
function onPrevPage() {
if (pageNum <= 1) {
return;
}
pageNum--;
queueRenderPage(pageNum);
}
/**
* Displays next page.
*/
function onNextPage() {
if (pageNum >= pdfDoc.numPages) {
return;
}
pageNum++;
queueRenderPage(pageNum);
}

@ -0,0 +1,222 @@
var queryParams = null;
var datasetUrl = null;
var version = null;
var fileDownloadUrl = null;
var lrsUrl=null;
var previewMode = null;
var locale=null;
function startPreview(retrieveFile) {
// Retrieve tool launch parameters from URL
queryParams = new URLSearchParams(window.location.search.substring(1));
var fileUrl = queryParams.get("siteUrl") + "/api/access/datafile/"
+ queryParams.get("fileid") + "?gbrecs=true";
fileDownloadUrl = queryParams.get("siteUrl") + "/api/access/datafile/"
+ queryParams.get("fileid") + "?gbrecs=false";
lrsUrl="https://switchboard.clarin.eu/#/dataverse/"+encodeURIComponent(queryParams.get("siteUrl") + "/api/access/datafile/"
+ queryParams.get("fileid")+ "?gbrecs=false" )+"/"+cType+"/en";//"/text%2fplain/en";
var versionUrl = queryParams.get("siteUrl") + "/api/datasets/"
+ queryParams.get("datasetid") + "/versions/"
+ queryParams.get("datasetversion");
var apiKey = queryParams.get("key");
// Hide header and citation to embed on Dataverse file landing page.
previewMode = queryParams.get("preview");
locale = queryParams.get("locale");
if(locale== null) {
locale='en';
}
var i18n = $.i18n();
i18n.locale=locale;
i18n.load( 'i18n/' + i18n.locale + '.json', i18n.locale ).done(
function() {
//Call previewer-specific translation code
translateBaseHtmlPage();
}
);
if (apiKey != null) {
fileUrl = fileUrl + "&key=" + apiKey;
versionUrl = versionUrl + "?key=" + apiKey;
}
// Get metadata for dataset/version/file
$
.ajax({
dataType : "json",
url : versionUrl,
// headers: { 'X-Dataverse-key': apiKey },
crossite : true,
success : function(json, status) {
var mdFields = json.data.metadataBlocks.citation.fields;
var title = "";
var authors = "";
datasetUrl = json.data.storageIdentifier;
datasetUrl = datasetUrl
.substring(datasetUrl.indexOf("//") + 2);
version = queryParams.get("datasetversion");
if (version === ":draft") {
version = "DRAFT";
}
for ( var field in mdFields) {
if (mdFields[field].typeName === "title") {
title = mdFields[field].value;
}
if (mdFields[field].typeName === "author") {
var authorFields = mdFields[field].value;
for ( var author in authorFields) {
if (authors.length > 0) {
authors = authors + "; ";
}
authors = authors
+ authorFields[author].authorName.value;
}
}
}
var datafiles = json.data.files;
var fileIndex = 0;
for ( var entry in datafiles) {
if (JSON.stringify(datafiles[entry].dataFile.id) === queryParams
.get("fileid")) {
fileIndex = entry;
if (retrieveFile) {
$.ajax({
type : 'GET',
dataType : 'text',
// headers: { 'X-Dataverse-key': apiKey},
crosssite : true,
url : fileUrl,
success : function(data, status) {
writeContentAndData(data, fileUrl,
datafiles[fileIndex].dataFile,
title, authors);
},
error : function(request, status, error) {
reportFailure(
"Unable to retrieve file.",
status);
}
});
} else {
writeContent(fileUrl,
datafiles[entry].dataFile, title,
authors);
}
}
}
},
error : function(jqXHR, textStatus, errorThrown) {
//alert (jqXHR + " "+ errorThrown);
reportFailure("Unable to retrieve metadata: ", textStatus);
}
});
}
var filePageUrl = null;
function addStandardPreviewHeader(file, title, authors) {
if (previewMode !== 'true') {
// Add favicon from source Dataverse
$('head')
.append(
$('<link/>')
.attr('type', 'image/png')
.attr('rel', 'icon')
.attr(
'href',
queryParams.get("siteUrl")
+ '/javax.faces.resource/images/favicondataverse.png.xhtml'));
// Add logo from source Dataverse or use a local one, unless we are in preview mode
$('#logo')
.attr('src', queryParams.get("siteUrl") + '/logos/preview_logo.png')
.attr(
'onerror',
'this.onerror=null;this.src="/previewers/images/logo_placeholder.png";');
}
//Footer
var footer = $.i18n( "footer" );
$('body').append($('<div/>').html(footer).attr('id','footer'));
if (previewMode !== 'true') {
options = {"stripIgnoreTag":true, "stripIgnoreTagBody":['script','head']}; // Custom rules
//Translated text used in the preview header
var filenameText = $.i18n( "filenameText" );
var inText = $.i18n( "inText" );
var byText = $.i18n( "byText" );
var uploadedOnText = $.i18n("uploadedOnText");
var downloadFileText = $.i18n( "downloadFileText" );
var closePreviewText = $.i18n( "closePreviewText" );
var versionText = $.i18n( "versionText" );
var descriptionText = $.i18n( "descriptionText" );
var lrsText= $.i18n("LRSText");
filePageUrl = queryParams.get("siteUrl") + "/file.xhtml?";
if (file.persistentId.length == 0) {
filePageUrl = filePageUrl + "fileId=" + file.id;
} else {
filePageUrl = filePageUrl + "persistentId=" + file.persistentId;
}
filePageUrl = filePageUrl + "&version=" + version;
var header = $('.preview-header').append($('<div/>'));
header.append($("<div/>").append($("<span/>").text(filenameText)).append(
$('<a/>').attr('href', filePageUrl).text(file.filename)).attr('id',
'filename'));
if ((file.description != null) && (file.description.length > 0)) {
header.append($('<div/>').html(filterXSS("<span>" + descriptionText + "</span>" + file.description), options));
}
header.append($('<div/>').append($("<span/>").text(inText)).append(
$('<span/>').attr('id', 'dataset').append(
$('<a/>').attr(
'href',
queryParams.get("siteUrl")
+ "/dataset.xhtml?persistentId=doi:"
+ datasetUrl + "&version=" + version).text(
title))).append(
$('<span/>').html(" (<span>" + versionText + "</span> " + version + ")").attr('id', 'version')).append(
$('<span/>').text(byText)).append(
$('<span/>').text(authors).attr('id', 'authors')));
header.append($("<div/>").addClass("btn btn-default").html(
"<a href='" + fileDownloadUrl + "'>" + downloadFileText + "</a>"));
header.append($("<div/>").addClass("btn btn-default").html(
"<a href='" + lrsUrl + "'> <span class='glyphicon glyphicon-cog'></span> " + lrsText + "</a>"));//added
header.append($("<div/>").addClass("btn btn-default").html(
"<a href=\"javascript:window.close();\">" + closePreviewText + "</a>"));
if(file.creationDate != null) {
header.append($("<div/>").addClass("preview-note").text(
uploadedOnText + file.creationDate));
}
}
if (previewMode === 'true') {
$('#logo').hide();
$('.page-title').hide();
var lrsText= $.i18n("LRSText");
options = {"stripIgnoreTag":true, "stripIgnoreTagBody":['script','head']}; // Custom rules
//Translated text used in the preview header
//var header = $('.preview-header').append($('<div/>'));
var header = $('.preview-header');
header.append($("<div/>").addClass("btn btn-default").html(
"<a href='" + lrsUrl + "'><span class='glyphicon glyphicon-cog'></span> " + lrsText + "</a>"));
//<span class="glyphicon glyphicon-cog"></span>
//Cesare
//$('.preview-header').hide();
}
}
function reportFailure(msg, statusCode) {
var preview = $(".preview");
preview.addClass("alert alert-danger");
var errorText = $.i18n( "errorText" );
preview
.text(msg
+ errorText
+ statusCode);
}

@ -0,0 +1,213 @@
var queryParams = null;
var datasetUrl = null;
var version = null;
var fileDownloadUrl = null;
var lrsUrl=null;
var previewMode = null;
var locale=null;
function startPreview(retrieveFile) {
// Retrieve tool launch parameters from URL
queryParams = new URLSearchParams(window.location.search.substring(1));
var fileUrl = queryParams.get("siteUrl") + "/api/access/datafile/"
+ queryParams.get("fileid") + "?gbrecs=true";
fileDownloadUrl = queryParams.get("siteUrl") + "/api/access/datafile/"
+ queryParams.get("fileid") + "?gbrecs=false";
lrsUrl="https://switchboard.clarin.eu/#/d4science/"+encodeURIComponent(queryParams.get("siteUrl") + "/api/access/datafile/"
+ queryParams.get("fileid")+ "?gbrecs=false" )+"/text%2fplain/en";
var versionUrl = queryParams.get("siteUrl") + "/api/datasets/"
+ queryParams.get("datasetid") + "/versions/"
+ queryParams.get("datasetversion");
var apiKey = queryParams.get("key");
// Hide header and citation to embed on Dataverse file landing page.
previewMode = queryParams.get("preview");
locale = queryParams.get("locale");
if(locale== null) {
locale='en';
}
var i18n = $.i18n();
i18n.locale=locale;
i18n.load( 'i18n/' + i18n.locale + '.json', i18n.locale ).done(
function() {
//Call previewer-specific translation code
translateBaseHtmlPage();
}
);
if (apiKey != null) {
fileUrl = fileUrl + "&key=" + apiKey;
versionUrl = versionUrl + "?key=" + apiKey;
}
// Get metadata for dataset/version/file
$
.ajax({
dataType : "json",
url : versionUrl,
// headers: { 'X-Dataverse-key': apiKey },
crossite : true,
success : function(json, status) {
var mdFields = json.data.metadataBlocks.citation.fields;
var title = "";
var authors = "";
datasetUrl = json.data.storageIdentifier;
datasetUrl = datasetUrl
.substring(datasetUrl.indexOf("//") + 2);
version = queryParams.get("datasetversion");
if (version === ":draft") {
version = "DRAFT";
}
for ( var field in mdFields) {
if (mdFields[field].typeName === "title") {
title = mdFields[field].value;
}
if (mdFields[field].typeName === "author") {
var authorFields = mdFields[field].value;
for ( var author in authorFields) {
if (authors.length > 0) {
authors = authors + "; ";
}
authors = authors
+ authorFields[author].authorName.value;
}
}
}
var datafiles = json.data.files;
var fileIndex = 0;
for ( var entry in datafiles) {
if (JSON.stringify(datafiles[entry].dataFile.id) === queryParams
.get("fileid")) {
fileIndex = entry;
if (retrieveFile) {
$.ajax({
type : 'GET',
dataType : 'text',
// headers: { 'X-Dataverse-key': apiKey},
crosssite : true,
url : fileUrl,
success : function(data, status) {
writeContentAndData(data, fileUrl,
datafiles[fileIndex].dataFile,
title, authors);
},
error : function(request, status, error) {
reportFailure(
"Unable to retrieve file.",
status);
}
});
} else {
writeContent(fileUrl,
datafiles[entry].dataFile, title,
authors);
}
}
}
},
error : function(jqXHR, textStatus, errorThrown) {
//alert (jqXHR + " "+ errorThrown);
reportFailure("Unable to retrieve metadata: ", textStatus);
}
});
}
var filePageUrl = null;
function addStandardPreviewHeader(file, title, authors) {
if (previewMode !== 'true') {
// Add favicon from source Dataverse
$('head')
.append(
$('<link/>')
.attr('type', 'image/png')
.attr('rel', 'icon')
.attr(
'href',
queryParams.get("siteUrl")
+ '/javax.faces.resource/images/favicondataverse.png.xhtml'));
// Add logo from source Dataverse or use a local one, unless we are in preview mode
$('#logo')
.attr('src', queryParams.get("siteUrl") + '/logos/preview_logo.png')
.attr(
'onerror',
'this.onerror=null;this.src="/previewers/images/logo_placeholder.png";');
}
//Footer
var footer = $.i18n( "footer" );
$('body').append($('<div/>').html(footer).attr('id','footer'));
if (previewMode !== 'true') {
options = {"stripIgnoreTag":true, "stripIgnoreTagBody":['script','head']}; // Custom rules
//Translated text used in the preview header
var filenameText = $.i18n( "filenameText" );
var inText = $.i18n( "inText" );
var byText = $.i18n( "byText" );
var uploadedOnText = $.i18n("uploadedOnText");
var downloadFileText = $.i18n( "downloadFileText" );
var closePreviewText = $.i18n( "closePreviewText" );
var versionText = $.i18n( "versionText" );
var descriptionText = $.i18n( "descriptionText" );
var lrsText= $.i18n("LRSText");
filePageUrl = queryParams.get("siteUrl") + "/file.xhtml?";
if (file.persistentId.length == 0) {
filePageUrl = filePageUrl + "fileId=" + file.id;
} else {
filePageUrl = filePageUrl + "persistentId=" + file.persistentId;
}
filePageUrl = filePageUrl + "&version=" + version;
var header = $('.preview-header').append($('<div/>'));
header.append($("<div/>").append($("<span/>").text(filenameText)).append(
$('<a/>').attr('href', filePageUrl).text(file.filename)).attr('id',
'filename'));
if ((file.description != null) && (file.description.length > 0)) {
header.append($('<div/>').html(filterXSS("<span>" + descriptionText + "</span>" + file.description), options));
}
header.append($('<div/>').append($("<span/>").text(inText)).append(
$('<span/>').attr('id', 'dataset').append(
$('<a/>').attr(
'href',
queryParams.get("siteUrl")
+ "/dataset.xhtml?persistentId=doi:"
+ datasetUrl + "&version=" + version).text(
title))).append(
$('<span/>').html(" (<span>" + versionText + "</span> " + version + ")").attr('id', 'version')).append(
$('<span/>').text(byText)).append(
$('<span/>').text(authors).attr('id', 'authors')));
header.append($("<div/>").addClass("btn btn-default").html(
"<a href='" + fileDownloadUrl + "'>" + downloadFileText + "</a>"));
header.append($("<div/>").addClass("btn btn-default").html(
"<a href='" + lrsUrl + "'>" + lrsText + "</a>"));//added
header.append($("<div/>").addClass("btn btn-default").html(
"<a href=\"javascript:window.close();\">" + closePreviewText + "</a>"));
if(file.creationDate != null) {
header.append($("<div/>").addClass("preview-note").text(
uploadedOnText + file.creationDate));
}
}
if (previewMode === 'true') {
$('#logo').hide();
$('.page-title').hide();
$('.preview-header').hide();
}
}
function reportFailure(msg, statusCode) {
var preview = $(".preview");
preview.addClass("alert alert-danger");
var errorText = $.i18n( "errorText" );
preview
.text(msg
+ errorText
+ statusCode);
}

@ -0,0 +1,35 @@
/*
* Showdown XSS Filter extension
* https://github.com/VisionistInc/showdown-xss-filter
* 2015, Visionist, Inc.
* License: MIT
*/
(function() {
// Server-side import
if (typeof module !== 'undefined') {
filterXSS = require('xss');
}
// Filter out potential XSS attacks before rendering HTML
var xssfilter = function (converter) {
return [
{
type: "output",
filter: function(text) {
return filterXSS(text);
}
}
];
};
// Client-side export
if (typeof window !== 'undefined' && window.showdown && window.showdown.extensions) {
window.showdown.extension('xssfilter', xssfilter);
}
// Server-side export
if (typeof module !== 'undefined') {
module.exports = xssfilter;
}
})();

File diff suppressed because one or more lines are too long

@ -0,0 +1,45 @@
$(document).ready(function() {
startPreview(false);
});
function translateBaseHtmlPage() {
var spreadsheetViewerText = $.i18n( "spreadsheetViewerText" );
$( '.spreadsheetViewerText' ).text( spreadsheetViewerText );
}
function writeContent(fileUrl, file, title, authors) {
addStandardPreviewHeader(file, title, authors);
var handsontableContainer = document.getElementById('handsontable-container');
var request = new XMLHttpRequest();
request.open('GET', fileUrl, true);
request.responseType = 'blob';
request.onload = function() {
var reader = new FileReader()
reader.onload = function (e) {
var csv = e.target.result;
var data = Papa.parse(csv, {
header: true,
skipEmptyLines: true
})
handsontableContainer.innerHTML = '';
handsontableContainer.className = '';
Handsontable(handsontableContainer, {
data: data.data,
rowHeaders: true,
colHeaders: Object.keys(data.data[0]),
columnSorting: true
})
}
reader.readAsText(request.response);
};
request.send();
}

@ -0,0 +1,80 @@
$(document).ready(function() {
startPreview(true);
});
function translateBaseHtmlPage() {
var textPreviewText = $.i18n( "textPreviewText" );
$( '.textPreviewText' ).text( textPreviewText );
}
function writeContentAndData(data, fileUrl, file, title, authors) {
addStandardPreviewHeader(file,title, authors);
//removing href and target attributes from the default
var whiteList = {
a: ["title"],
abbr: ["title"],
address: [],
area: [],
article: [],
aside: [],
audio: [],
b: [],
bdi: ["dir"],
bdo: ["dir"],
big: [],
blockquote: ["cite"],
br: [],
caption: [],
center: [],
cite: [],
code: [],
col: ["align", "valign", "span", "width"],
colgroup: ["align", "valign", "span", "width"],
dd: [],
del: ["datetime"],
details: ["open"],
div: [],
dl: [],
dt: [],
em: [],
font: ["color", "size", "face"],
footer: [],
h1: [],
h2: [],
h3: [],
h4: [],
h5: [],
h6: [],
header: [],
hr: [],
i: [],
img: ["src", "alt", "title", "width", "height"],
ins: ["datetime"],
li: [],
mark: [],
nav: [],
ol: [],
p: [],
pre: [],
s: [],
section: [],
small: [],
span: [],
sub: [],
sup: [],
strong: [],
table: ["width", "border", "align", "valign"],
tbody: ["align", "valign"],
td: ["width", "rowspan", "colspan", "align", "valign"],
tfoot: ["align", "valign"],
th: ["width", "rowspan", "colspan", "align", "valign"],
thead: ["align", "valign"],
tr: ["rowspan", "align", "valign"],
tt: [],
u: [],
ul: [],
video: []
};
options = {"whiteList":whiteList}; // Custom rules
$('.preview').append($("<pre/>").html(filterXSS(data,options)));
}

@ -0,0 +1,80 @@
$(document).ready(function() {
startPreview(true);
});
function translateBaseHtmlPage() {
var textPreviewText = $.i18n( "textPreviewText" );
$( '.textPreviewText' ).text( textPreviewText );
}
function writeContentAndData(data, fileUrl, file, title, authors) {
addStandardPreviewHeader(file,title, authors);
//removing href and target attributes from the default
var whiteList = {
a: ["title"],
abbr: ["title"],
address: [],
area: [],
article: [],
aside: [],
audio: [],
b: [],
bdi: ["dir"],
bdo: ["dir"],
big: [],
blockquote: ["cite"],
br: [],
caption: [],
center: [],
cite: [],
code: [],
col: ["align", "valign", "span", "width"],
colgroup: ["align", "valign", "span", "width"],
dd: [],
del: ["datetime"],
details: ["open"],
div: [],
dl: [],
dt: [],
em: [],
font: ["color", "size", "face"],
footer: [],
h1: [],
h2: [],
h3: [],
h4: [],
h5: [],
h6: [],
header: [],
hr: [],
i: [],
img: ["src", "alt", "title", "width", "height"],
ins: ["datetime"],
li: [],
mark: [],
nav: [],
ol: [],
p: [],
pre: [],
s: [],
section: [],
small: [],
span: [],
sub: [],
sup: [],
strong: [],
table: ["width", "border", "align", "valign"],
tbody: ["align", "valign"],
td: ["width", "rowspan", "colspan", "align", "valign"],
tfoot: ["align", "valign"],
th: ["width", "rowspan", "colspan", "align", "valign"],
thead: ["align", "valign"],
tr: ["rowspan", "align", "valign"],
tt: [],
u: [],
ul: [],
video: []
};
options = {"whiteList":whiteList}; // Custom rules
$('.preview').append($("<pre/>").html(filterXSS(data,options)));
}

@ -0,0 +1,14 @@
$(document).ready(function() {
startPreview(false);
});
function translateBaseHtmlPage() {
var videoPreviewText = $.i18n( "videoPreviewText" );
$( '.videoPreviewText' ).text( videoPreviewText );
}
function writeContent(fileUrl, file, title, authors) {
addStandardPreviewHeader(file, title, authors);
$(".preview").append($("<video/>").prop("controls",true).append($('<source/>').attr("src",fileUrl)));
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,186 @@
/*!
* jQuery Internationalization library
*
* Copyright (C) 2012 Santhosh Thottingal
*
* jquery.i18n is dual licensed GPLv2 or later and MIT. You don't have to do anything special to
* choose one license or the other and you don't have to notify anyone which license you are using.
* You are free to use UniversalLanguageSelector in commercial projects as long as the copyright
* header is left intact. See files GPL-LICENSE and MIT-LICENSE for details.
*
* @licence GNU General Public Licence 2.0 or later
* @licence MIT License
*/
( function ( $ ) {
'use strict';
$.i18n = $.i18n || {};
$.extend( $.i18n.fallbacks, {
ab: [ 'ru' ],
ace: [ 'id' ],
aln: [ 'sq' ],
// Not so standard - als is supposed to be Tosk Albanian,
// but in Wikipedia it's used for a Germanic language.
als: [ 'gsw', 'de' ],
an: [ 'es' ],
anp: [ 'hi' ],
arn: [ 'es' ],
arz: [ 'ar' ],
av: [ 'ru' ],
ay: [ 'es' ],
ba: [ 'ru' ],
bar: [ 'de' ],
'bat-smg': [ 'sgs', 'lt' ],
bcc: [ 'fa' ],
'be-x-old': [ 'be-tarask' ],
bh: [ 'bho' ],
bjn: [ 'id' ],
bm: [ 'fr' ],
bpy: [ 'bn' ],
bqi: [ 'fa' ],
bug: [ 'id' ],
'cbk-zam': [ 'es' ],
ce: [ 'ru' ],
crh: [ 'crh-latn' ],
'crh-cyrl': [ 'ru' ],
csb: [ 'pl' ],
cv: [ 'ru' ],
'de-at': [ 'de' ],
'de-ch': [ 'de' ],
'de-formal': [ 'de' ],
dsb: [ 'de' ],
dtp: [ 'ms' ],
egl: [ 'it' ],
eml: [ 'it' ],
ff: [ 'fr' ],
fit: [ 'fi' ],
'fiu-vro': [ 'vro', 'et' ],
frc: [ 'fr' ],
frp: [ 'fr' ],
frr: [ 'de' ],
fur: [ 'it' ],
gag: [ 'tr' ],
gan: [ 'gan-hant', 'zh-hant', 'zh-hans' ],
'gan-hans': [ 'zh-hans' ],
'gan-hant': [ 'zh-hant', 'zh-hans' ],
gl: [ 'pt' ],
glk: [ 'fa' ],
gn: [ 'es' ],
gsw: [ 'de' ],
hif: [ 'hif-latn' ],
hsb: [ 'de' ],
ht: [ 'fr' ],
ii: [ 'zh-cn', 'zh-hans' ],
inh: [ 'ru' ],
iu: [ 'ike-cans' ],
jut: [ 'da' ],
jv: [ 'id' ],
kaa: [ 'kk-latn', 'kk-cyrl' ],
kbd: [ 'kbd-cyrl' ],
khw: [ 'ur' ],
kiu: [ 'tr' ],
kk: [ 'kk-cyrl' ],
'kk-arab': [ 'kk-cyrl' ],
'kk-latn': [ 'kk-cyrl' ],
'kk-cn': [ 'kk-arab', 'kk-cyrl' ],
'kk-kz': [ 'kk-cyrl' ],
'kk-tr': [ 'kk-latn', 'kk-cyrl' ],
kl: [ 'da' ],
'ko-kp': [ 'ko' ],
koi: [ 'ru' ],
krc: [ 'ru' ],
ks: [ 'ks-arab' ],
ksh: [ 'de' ],
ku: [ 'ku-latn' ],
'ku-arab': [ 'ckb' ],
kv: [ 'ru' ],
lad: [ 'es' ],
lb: [ 'de' ],
lbe: [ 'ru' ],
lez: [ 'ru' ],
li: [ 'nl' ],
lij: [ 'it' ],
liv: [ 'et' ],
lmo: [ 'it' ],
ln: [ 'fr' ],
ltg: [ 'lv' ],
lzz: [ 'tr' ],
mai: [ 'hi' ],
'map-bms': [ 'jv', 'id' ],
mg: [ 'fr' ],
mhr: [ 'ru' ],
min: [ 'id' ],
mo: [ 'ro' ],
mrj: [ 'ru' ],
mwl: [ 'pt' ],
myv: [ 'ru' ],
mzn: [ 'fa' ],
nah: [ 'es' ],
nap: [ 'it' ],
nds: [ 'de' ],
'nds-nl': [ 'nl' ],
'nl-informal': [ 'nl' ],
no: [ 'nb' ],
os: [ 'ru' ],
pcd: [ 'fr' ],
pdc: [ 'de' ],
pdt: [ 'de' ],
pfl: [ 'de' ],
pms: [ 'it' ],
pt: [ 'pt-br' ],
'pt-br': [ 'pt' ],
qu: [ 'es' ],
qug: [ 'qu', 'es' ],
rgn: [ 'it' ],
rmy: [ 'ro' ],
'roa-rup': [ 'rup' ],
rue: [ 'uk', 'ru' ],
ruq: [ 'ruq-latn', 'ro' ],
'ruq-cyrl': [ 'mk' ],
'ruq-latn': [ 'ro' ],
sa: [ 'hi' ],
sah: [ 'ru' ],
scn: [ 'it' ],
sg: [ 'fr' ],
sgs: [ 'lt' ],
sli: [ 'de' ],
sr: [ 'sr-ec' ],
srn: [ 'nl' ],
stq: [ 'de' ],
su: [ 'id' ],
szl: [ 'pl' ],
tcy: [ 'kn' ],
tg: [ 'tg-cyrl' ],
tt: [ 'tt-cyrl', 'ru' ],
'tt-cyrl': [ 'ru' ],
ty: [ 'fr' ],
udm: [ 'ru' ],
ug: [ 'ug-arab' ],
uk: [ 'ru' ],
vec: [ 'it' ],
vep: [ 'et' ],
vls: [ 'nl' ],
vmf: [ 'de' ],
vot: [ 'fi' ],
vro: [ 'et' ],
wa: [ 'fr' ],
wo: [ 'fr' ],
wuu: [ 'zh-hans' ],
xal: [ 'ru' ],
xmf: [ 'ka' ],
yi: [ 'he' ],
za: [ 'zh-hans' ],
zea: [ 'nl' ],
zh: [ 'zh-hans' ],
'zh-classical': [ 'lzh' ],
'zh-cn': [ 'zh-hans' ],
'zh-hant': [ 'zh-hans' ],
'zh-hk': [ 'zh-hant', 'zh-hans' ],
'zh-min-nan': [ 'nan' ],
'zh-mo': [ 'zh-hk', 'zh-hant', 'zh-hans' ],
'zh-my': [ 'zh-sg', 'zh-hans' ],
'zh-sg': [ 'zh-hans' ],
'zh-tw': [ 'zh-hant', 'zh-hans' ],
'zh-yue': [ 'yue' ]
} );
}( jQuery ) );

@ -0,0 +1,290 @@
/*!
* jQuery Internationalization library
*
* Copyright (C) 2012 Santhosh Thottingal
*
* jquery.i18n is dual licensed GPLv2 or later and MIT. You don't have to do
* anything special to choose one license or the other and you don't have to
* notify anyone which license you are using. You are free to use
* UniversalLanguageSelector in commercial projects as long as the copyright
* header is left intact. See files GPL-LICENSE and MIT-LICENSE for details.
*
* @licence GNU General Public Licence 2.0 or later
* @licence MIT License
*/
( function ( $ ) {
'use strict';
var I18N,
slice = Array.prototype.slice;
/**
* @constructor
* @param {Object} options
*/
I18N = function ( options ) {
// Load defaults
this.options = $.extend( {}, I18N.defaults, options );
this.parser = this.options.parser;
this.locale = this.options.locale;
this.messageStore = this.options.messageStore;
this.languages = {};
};
I18N.prototype = {
/**
* Localize a given messageKey to a locale.
* @param {string} messageKey
* @return {string} Localized message
*/
localize: function ( messageKey ) {
var localeParts, localePartIndex, locale, fallbackIndex,
tryingLocale, message;
locale = this.locale;
fallbackIndex = 0;
while ( locale ) {
// Iterate through locales starting at most-specific until
// localization is found. As in fi-Latn-FI, fi-Latn and fi.
localeParts = locale.split( '-' );
localePartIndex = localeParts.length;
do {
tryingLocale = localeParts.slice( 0, localePartIndex ).join( '-' );
message = this.messageStore.get( tryingLocale, messageKey );
if ( message ) {
return message;
}
localePartIndex--;
} while ( localePartIndex );
if ( locale === this.options.fallbackLocale ) {
break;
}
locale = ( $.i18n.fallbacks[ this.locale ] &&
$.i18n.fallbacks[ this.locale ][ fallbackIndex ] ) ||
this.options.fallbackLocale;
$.i18n.log( 'Trying fallback locale for ' + this.locale + ': ' + locale + ' (' + messageKey + ')' );
fallbackIndex++;
}
// key not found
return '';
},
/*
* Destroy the i18n instance.
*/
destroy: function () {
$.removeData( document, 'i18n' );
},
/**
* General message loading API This can take a URL string for
* the json formatted messages. Example:
* <code>load('path/to/all_localizations.json');</code>
*
* To load a localization file for a locale:
* <code>
* load('path/to/de-messages.json', 'de' );
* </code>
*
* To load a localization file from a directory:
* <code>
* load('path/to/i18n/directory', 'de' );
* </code>
* The above method has the advantage of fallback resolution.
* ie, it will automatically load the fallback locales for de.
* For most usecases, this is the recommended method.
* It is optional to have trailing slash at end.
*
* A data object containing message key- message translation mappings
* can also be passed. Example:
* <code>
* load( { 'hello' : 'Hello' }, optionalLocale );
* </code>
*
* A source map containing key-value pair of languagename and locations
* can also be passed. Example:
* <code>
* load( {
* bn: 'i18n/bn.json',
* he: 'i18n/he.json',
* en: 'i18n/en.json'
* } )
* </code>
*
* If the data argument is null/undefined/false,
* all cached messages for the i18n instance will get reset.
*
* @param {string|Object} source
* @param {string} locale Language tag
* @return {jQuery.Promise}
*/
load: function ( source, locale ) {
var fallbackLocales, locIndex, fallbackLocale, sourceMap = {};
if ( !source && !locale ) {
source = 'i18n/' + $.i18n().locale + '.json';
locale = $.i18n().locale;
}
if ( typeof source === 'string' &&
// source extension should be json, but can have query params after that.
source.split( '?' )[ 0 ].split( '.' ).pop() !== 'json'
) {
// Load specified locale then check for fallbacks when directory is
// specified in load()
sourceMap[ locale ] = source + '/' + locale + '.json';
fallbackLocales = ( $.i18n.fallbacks[ locale ] || [] )
.concat( this.options.fallbackLocale );
for ( locIndex = 0; locIndex < fallbackLocales.length; locIndex++ ) {
fallbackLocale = fallbackLocales[ locIndex ];
sourceMap[ fallbackLocale ] = source + '/' + fallbackLocale + '.json';
}
return this.load( sourceMap );
} else {
return this.messageStore.load( source, locale );
}
},
/**
* Does parameter and magic word substitution.
*
* @param {string} key Message key
* @param {Array} parameters Message parameters
* @return {string}
*/
parse: function ( key, parameters ) {
var message = this.localize( key );
// FIXME: This changes the state of the I18N object,
// should probably not change the 'this.parser' but just
// pass it to the parser.
this.parser.language = $.i18n.languages[ $.i18n().locale ] || $.i18n.languages[ 'default' ];
if ( message === '' ) {
message = key;
}
return this.parser.parse( message, parameters );
}
};
/**
* Process a message from the $.I18N instance
* for the current document, stored in jQuery.data(document).
*
* @param {string} key Key of the message.
* @param {string} param1 [param...] Variadic list of parameters for {key}.
* @return {string|$.I18N} Parsed message, or if no key was given
* the instance of $.I18N is returned.
*/
$.i18n = function ( key, param1 ) {
var parameters,
i18n = $.data( document, 'i18n' ),
options = typeof key === 'object' && key;
// If the locale option for this call is different then the setup so far,
// update it automatically. This doesn't just change the context for this
// call but for all future call as well.
// If there is no i18n setup yet, don't do this. It will be taken care of
// by the `new I18N` construction below.
// NOTE: It should only change language for this one call.
// Then cache instances of I18N somewhere.
if ( options && options.locale && i18n && i18n.locale !== options.locale ) {
i18n.locale = options.locale;
}
if ( !i18n ) {
i18n = new I18N( options );
$.data( document, 'i18n', i18n );
}
if ( typeof key === 'string' ) {
if ( param1 !== undefined ) {
parameters = slice.call( arguments, 1 );
} else {
parameters = [];
}
return i18n.parse( key, parameters );
} else {
// FIXME: remove this feature/bug.
return i18n;
}
};
$.fn.i18n = function () {
var i18n = $.data( document, 'i18n' );
if ( !i18n ) {
i18n = new I18N();
$.data( document, 'i18n', i18n );
}
return this.each( function () {
var $this = $( this ),
messageKey = $this.data( 'i18n' ),
lBracket, rBracket, type, key;
if ( messageKey ) {
lBracket = messageKey.indexOf( '[' );
rBracket = messageKey.indexOf( ']' );
if ( lBracket !== -1 && rBracket !== -1 && lBracket < rBracket ) {
type = messageKey.slice( lBracket + 1, rBracket );
key = messageKey.slice( rBracket + 1 );
if ( type === 'html' ) {
$this.html( i18n.parse( key ) );
} else {
$this.attr( type, i18n.parse( key ) );
}
} else {
$this.text( i18n.parse( messageKey ) );
}
} else {
$this.find( '[data-i18n]' ).i18n();
}
} );
};
function getDefaultLocale() {
var locale = $( 'html' ).attr( 'lang' );
if ( !locale ) {
locale = navigator.language || navigator.userLanguage || '';
}
return locale;
}
$.i18n.languages = {};
$.i18n.messageStore = $.i18n.messageStore || {};
$.i18n.parser = {
// The default parser only handles variable substitution
parse: function ( message, parameters ) {
return message.replace( /\$(\d+)/g, function ( str, match ) {
var index = parseInt( match, 10 ) - 1;
return parameters[ index ] !== undefined ? parameters[ index ] : '$' + match;
} );
},
emitter: {}
};
$.i18n.fallbacks = {};
$.i18n.debug = false;
$.i18n.log = function ( /* arguments */ ) {
if ( window.console && $.i18n.debug ) {
window.console.log.apply( window.console, arguments );
}
};
/* Static members */
I18N.defaults = {
locale: getDefaultLocale(),
fallbackLocale: 'en',
parser: $.i18n.parser,
messageStore: $.i18n.messageStore
};
// Expose constructor
$.i18n.constructor = I18N;
}( jQuery ) );

@ -0,0 +1,499 @@
/* global pluralRuleParser */
( function ( $ ) {
'use strict';
// jscs:disable
var language = {
// CLDR plural rules generated using
// libs/CLDRPluralRuleParser/tools/PluralXML2JSON.html
pluralRules: {
ak: {
one: 'n = 0..1'
},
am: {
one: 'i = 0 or n = 1'
},
ar: {
zero: 'n = 0',
one: 'n = 1',
two: 'n = 2',
few: 'n % 100 = 3..10',
many: 'n % 100 = 11..99'
},
ars: {
zero: 'n = 0',
one: 'n = 1',
two: 'n = 2',
few: 'n % 100 = 3..10',
many: 'n % 100 = 11..99'
},
as: {
one: 'i = 0 or n = 1'
},
be: {
one: 'n % 10 = 1 and n % 100 != 11',
few: 'n % 10 = 2..4 and n % 100 != 12..14',
many: 'n % 10 = 0 or n % 10 = 5..9 or n % 100 = 11..14'
},
bh: {
one: 'n = 0..1'
},
bn: {
one: 'i = 0 or n = 1'
},
br: {
one: 'n % 10 = 1 and n % 100 != 11,71,91',
two: 'n % 10 = 2 and n % 100 != 12,72,92',
few: 'n % 10 = 3..4,9 and n % 100 != 10..19,70..79,90..99',
many: 'n != 0 and n % 1000000 = 0'
},
bs: {
one: 'v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11',
few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14'
},
cs: {
one: 'i = 1 and v = 0',
few: 'i = 2..4 and v = 0',
many: 'v != 0'
},
cy: {
zero: 'n = 0',
one: 'n = 1',
two: 'n = 2',
few: 'n = 3',
many: 'n = 6'
},
da: {
one: 'n = 1 or t != 0 and i = 0,1'
},
dsb: {
one: 'v = 0 and i % 100 = 1 or f % 100 = 1',
two: 'v = 0 and i % 100 = 2 or f % 100 = 2',
few: 'v = 0 and i % 100 = 3..4 or f % 100 = 3..4'
},
fa: {
one: 'i = 0 or n = 1'
},
ff: {
one: 'i = 0,1'
},
fil: {
one: 'v = 0 and i = 1,2,3 or v = 0 and i % 10 != 4,6,9 or v != 0 and f % 10 != 4,6,9'
},
fr: {
one: 'i = 0,1'
},
ga: {
one: 'n = 1',
two: 'n = 2',
few: 'n = 3..6',
many: 'n = 7..10'
},
gd: {
one: 'n = 1,11',
two: 'n = 2,12',
few: 'n = 3..10,13..19'
},
gu: {
one: 'i = 0 or n = 1'
},
guw: {
one: 'n = 0..1'
},
gv: {
one: 'v = 0 and i % 10 = 1',
two: 'v = 0 and i % 10 = 2',
few: 'v = 0 and i % 100 = 0,20,40,60,80',
many: 'v != 0'
},
he: {
one: 'i = 1 and v = 0',
two: 'i = 2 and v = 0',
many: 'v = 0 and n != 0..10 and n % 10 = 0'
},
hi: {
one: 'i = 0 or n = 1'
},
hr: {
one: 'v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11',
few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14'
},
hsb: {
one: 'v = 0 and i % 100 = 1 or f % 100 = 1',
two: 'v = 0 and i % 100 = 2 or f % 100 = 2',
few: 'v = 0 and i % 100 = 3..4 or f % 100 = 3..4'
},
hy: {
one: 'i = 0,1'
},
is: {
one: 't = 0 and i % 10 = 1 and i % 100 != 11 or t != 0'
},
iu: {
one: 'n = 1',
two: 'n = 2'
},
iw: {
one: 'i = 1 and v = 0',
two: 'i = 2 and v = 0',
many: 'v = 0 and n != 0..10 and n % 10 = 0'
},
kab: {
one: 'i = 0,1'
},
kn: {
one: 'i = 0 or n = 1'
},
kw: {
one: 'n = 1',
two: 'n = 2'
},
lag: {
zero: 'n = 0',
one: 'i = 0,1 and n != 0'
},
ln: {
one: 'n = 0..1'
},
lt: {
one: 'n % 10 = 1 and n % 100 != 11..19',
few: 'n % 10 = 2..9 and n % 100 != 11..19',
many: 'f != 0'
},
lv: {
zero: 'n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19',
one: 'n % 10 = 1 and n % 100 != 11 or v = 2 and f % 10 = 1 and f % 100 != 11 or v != 2 and f % 10 = 1'
},
mg: {
one: 'n = 0..1'
},
mk: {
one: 'v = 0 and i % 10 = 1 or f % 10 = 1'
},
mo: {
one: 'i = 1 and v = 0',
few: 'v != 0 or n = 0 or n != 1 and n % 100 = 1..19'
},
mr: {
one: 'i = 0 or n = 1'
},
mt: {
one: 'n = 1',
few: 'n = 0 or n % 100 = 2..10',
many: 'n % 100 = 11..19'
},
naq: {
one: 'n = 1',
two: 'n = 2'
},
nso: {
one: 'n = 0..1'
},
pa: {
one: 'n = 0..1'
},
pl: {
one: 'i = 1 and v = 0',
few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14',
many: 'v = 0 and i != 1 and i % 10 = 0..1 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 12..14'
},
prg: {
zero: 'n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19',
one: 'n % 10 = 1 and n % 100 != 11 or v = 2 and f % 10 = 1 and f % 100 != 11 or v != 2 and f % 10 = 1'
},
pt: {
one: 'i = 0..1'
},
ro: {
one: 'i = 1 and v = 0',
few: 'v != 0 or n = 0 or n != 1 and n % 100 = 1..19'
},
ru: {
one: 'v = 0 and i % 10 = 1 and i % 100 != 11',
few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14',
many: 'v = 0 and i % 10 = 0 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 11..14'
},
se: {
one: 'n = 1',
two: 'n = 2'
},
sh: {
one: 'v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11',
few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14'
},
shi: {
one: 'i = 0 or n = 1',
few: 'n = 2..10'
},
si: {
one: 'n = 0,1 or i = 0 and f = 1'
},
sk: {
one: 'i = 1 and v = 0',
few: 'i = 2..4 and v = 0',
many: 'v != 0'
},
sl: {
one: 'v = 0 and i % 100 = 1',
two: 'v = 0 and i % 100 = 2',
few: 'v = 0 and i % 100 = 3..4 or v != 0'
},
sma: {
one: 'n = 1',
two: 'n = 2'
},
smi: {
one: 'n = 1',
two: 'n = 2'
},
smj: {
one: 'n = 1',
two: 'n = 2'
},
smn: {
one: 'n = 1',
two: 'n = 2'
},
sms: {
one: 'n = 1',
two: 'n = 2'
},
sr: {
one: 'v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11',
few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14'
},
ti: {
one: 'n = 0..1'
},
tl: {
one: 'v = 0 and i = 1,2,3 or v = 0 and i % 10 != 4,6,9 or v != 0 and f % 10 != 4,6,9'
},
tzm: {
one: 'n = 0..1 or n = 11..99'
},
uk: {
one: 'v = 0 and i % 10 = 1 and i % 100 != 11',
few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14',
many: 'v = 0 and i % 10 = 0 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 11..14'
},
wa: {
one: 'n = 0..1'
},
zu: {
one: 'i = 0 or n = 1'
}
},
// jscs:enable
/**
* Plural form transformations, needed for some languages.
*
* @param {integer} count
* Non-localized quantifier
* @param {Array} forms
* List of plural forms
* @return {string} Correct form for quantifier in this language
*/
convertPlural: function ( count, forms ) {
var pluralRules,
pluralFormIndex,
index,
explicitPluralPattern = new RegExp( '\\d+=', 'i' ),
formCount,
form;
if ( !forms || forms.length === 0 ) {
return '';
}
// Handle for Explicit 0= & 1= values
for ( index = 0; index < forms.length; index++ ) {
form = forms[ index ];
if ( explicitPluralPattern.test( form ) ) {
formCount = parseInt( form.slice( 0, form.indexOf( '=' ) ), 10 );
if ( formCount === count ) {
return ( form.slice( form.indexOf( '=' ) + 1 ) );
}
forms[ index ] = undefined;
}
}
forms = $.map( forms, function ( form ) {
if ( form !== undefined ) {
return form;
}
} );
pluralRules = this.pluralRules[ $.i18n().locale ];
if ( !pluralRules ) {
// default fallback.
return ( count === 1 ) ? forms[ 0 ] : forms[ 1 ];
}
pluralFormIndex = this.getPluralForm( count, pluralRules );
pluralFormIndex = Math.min( pluralFormIndex, forms.length - 1 );
return forms[ pluralFormIndex ];
},
/**
* For the number, get the plural for index
*
* @param {integer} number
* @param {Object} pluralRules
* @return {integer} plural form index
*/
getPluralForm: function ( number, pluralRules ) {
var i,
pluralForms = [ 'zero', 'one', 'two', 'few', 'many', 'other' ],
pluralFormIndex = 0;
for ( i = 0; i < pluralForms.length; i++ ) {
if ( pluralRules[ pluralForms[ i ] ] ) {
if ( pluralRuleParser( pluralRules[ pluralForms[ i ] ], number ) ) {
return pluralFormIndex;
}
pluralFormIndex++;
}
}
return pluralFormIndex;
},
/**
* Converts a number using digitTransformTable.
*
* @param {number} num Value to be converted
* @param {boolean} integer Convert the return value to an integer
* @return {string} The number converted into a String.
*/
convertNumber: function ( num, integer ) {
var tmp, item, i,
transformTable, numberString, convertedNumber;
// Set the target Transform table:
transformTable = this.digitTransformTable( $.i18n().locale );
numberString = String( num );
convertedNumber = '';
if ( !transformTable ) {
return num;
}
// Check if the restore to Latin number flag is set:
if ( integer ) {
if ( parseFloat( num, 10 ) === num ) {
return num;
}
tmp = [];
for ( item in transformTable ) {
tmp[ transformTable[ item ] ] = item;
}
transformTable = tmp;
}
for ( i = 0; i < numberString.length; i++ ) {
if ( transformTable[ numberString[ i ] ] ) {
convertedNumber += transformTable[ numberString[ i ] ];
} else {
convertedNumber += numberString[ i ];
}
}
return integer ? parseFloat( convertedNumber, 10 ) : convertedNumber;
},
/**
* Grammatical transformations, needed for inflected languages.
* Invoked by putting {{grammar:form|word}} in a message.
* Override this method for languages that need special grammar rules
* applied dynamically.
*
* @param {string} word
* @param {string} form
* @return {string}
*/
// eslint-disable-next-line no-unused-vars
convertGrammar: function ( word, form ) {
return word;
},
/**
* Provides an alternative text depending on specified gender. Usage
* {{gender:[gender|user object]|masculine|feminine|neutral}}. If second
* or third parameter are not specified, masculine is used.
*
* These details may be overriden per language.
*
* @param {string} gender
* male, female, or anything else for neutral.
* @param {Array} forms
* List of gender forms
*
* @return {string}
*/
gender: function ( gender, forms ) {
if ( !forms || forms.length === 0 ) {
return '';
}
while ( forms.length < 2 ) {
forms.push( forms[ forms.length - 1 ] );
}
if ( gender === 'male' ) {
return forms[ 0 ];
}
if ( gender === 'female' ) {
return forms[ 1 ];
}
return ( forms.length === 3 ) ? forms[ 2 ] : forms[ 0 ];
},
/**
* Get the digit transform table for the given language
* See http://cldr.unicode.org/translation/numbering-systems
*
* @param {string} language
* @return {Array|boolean} List of digits in the passed language or false
* representation, or boolean false if there is no information.
*/
digitTransformTable: function ( language ) {
var tables = {
ar: '٠١٢٣٤٥٦٧٨٩',
fa: '۰۱۲۳۴۵۶۷۸۹',
ml: '൦൧൨൩൪൫൬൭൮൯',
kn: '೦೧೨೩೪೫೬೭೮೯',
lo: '໐໑໒໓໔໕໖໗໘໙',
or: '୦୧୨୩୪୫୬୭୮୯',
kh: '០១២៣៤៥៦៧៨៩',
nqo: '߀߁߂߃߄߅߆߇߈߉', // Note that the digits go right to left
pa: '੦੧੨੩੪੫੬੭੮੯',
gu: '૦૧૨૩૪૫૬૭૮૯',
hi: '०१२३४५६७८९',
my: '၀၁၂၃၄၅၆၇၈၉',
ta: '௦௧௨௩௪௫௬௭௮௯',
te: '౦౧౨౩౪౫౬౭౮౯',
th: '๐๑๒๓๔๕๖๗๘๙', // FIXME use iso 639 codes
bo: '༠༡༢༣༤༥༦༧༨༩' // FIXME use iso 639 codes
};
if ( !tables[ language ] ) {
return false;
}
return tables[ language ].split( '' );
}
};
$.extend( $.i18n.languages, {
default: language
} );
}( jQuery ) );

@ -0,0 +1,126 @@
/*!
* jQuery Internationalization library - Message Store
*
* Copyright (C) 2012 Santhosh Thottingal
*
* jquery.i18n is dual licensed GPLv2 or later and MIT. You don't have to do anything special to
* choose one license or the other and you don't have to notify anyone which license you are using.
* You are free to use UniversalLanguageSelector in commercial projects as long as the copyright
* header is left intact. See files GPL-LICENSE and MIT-LICENSE for details.
*
* @licence GNU General Public Licence 2.0 or later
* @licence MIT License
*/
( function ( $ ) {
'use strict';
var MessageStore = function () {
this.messages = {};
this.sources = {};
};
function jsonMessageLoader( url ) {
var deferred = $.Deferred();
$.getJSON( url )
.done( deferred.resolve )
.fail( function ( jqxhr, settings, exception ) {
$.i18n.log( 'Error in loading messages from ' + url + ' Exception: ' + exception );
// Ignore 404 exception, because we are handling fallabacks explicitly
deferred.resolve();
} );
return deferred.promise();
}
/**
* See https://github.com/wikimedia/jquery.i18n/wiki/Specification#wiki-Message_File_Loading
*/
MessageStore.prototype = {
/**
* General message loading API This can take a URL string for
* the json formatted messages.
* <code>load('path/to/all_localizations.json');</code>
*
* This can also load a localization file for a locale <code>
* load( 'path/to/de-messages.json', 'de' );
* </code>
* A data object containing message key- message translation mappings
* can also be passed Eg:
* <code>
* load( { 'hello' : 'Hello' }, optionalLocale );
* </code> If the data argument is
* null/undefined/false,
* all cached messages for the i18n instance will get reset.
*
* @param {string|Object} source
* @param {string} locale Language tag
* @return {jQuery.Promise}
*/
load: function ( source, locale ) {
var key = null,
deferred = null,
deferreds = [],
messageStore = this;
if ( typeof source === 'string' ) {
// This is a URL to the messages file.
$.i18n.log( 'Loading messages from: ' + source );
deferred = jsonMessageLoader( source )
.done( function ( localization ) {
messageStore.set( locale, localization );
} );
return deferred.promise();
}
if ( locale ) {
// source is an key-value pair of messages for given locale
messageStore.set( locale, source );
return $.Deferred().resolve();
} else {
// source is a key-value pair of locales and their source
for ( key in source ) {
if ( Object.prototype.hasOwnProperty.call( source, key ) ) {
locale = key;
// No {locale} given, assume data is a group of languages,
// call this function again for each language.
deferreds.push( messageStore.load( source[ key ], locale ) );
}
}
return $.when.apply( $, deferreds );
}
},
/**
* Set messages to the given locale.
* If locale exists, add messages to the locale.
*
* @param {string} locale
* @param {Object} messages
*/
set: function ( locale, messages ) {
if ( !this.messages[ locale ] ) {
this.messages[ locale ] = messages;
} else {
this.messages[ locale ] = $.extend( this.messages[ locale ], messages );
}
},
/**
*
* @param {string} locale
* @param {string} messageKey
* @return {boolean}
*/
get: function ( locale, messageKey ) {
return this.messages[ locale ] && this.messages[ locale ][ messageKey ];
}
};
$.extend( $.i18n.messageStore, new MessageStore() );
}( jQuery ) );
Loading…
Cancel
Save