fixed not beeing able to open external recipes when internal exists

This commit is contained in:
vabene1111
2019-12-25 19:47:11 +01:00
parent 6a010587bf
commit 9d0a6e63f8
4 changed files with 28 additions and 7 deletions

View File

@@ -43,12 +43,15 @@
</div>
<script type="text/javascript">
function openRecipe(id) {
function openRecipe(id, force_external = false) {
var link = $('#a_recipe_open');
link.hide();
$('#div_loader').show();
$('#div_loader').show();
var url = "{% url 'api_get_file_link' recipe_id=12345 %}".replace(/12345/, id);
if (force_external) {
url = "{% url 'api_get_external_file_link' recipe_id=12345 %}".replace(/12345/, id);
}
link.text("{% trans 'Open Recipe' %}");
$('#modal_recipe').modal('show');
@@ -56,10 +59,10 @@
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
if ( /^((?!chrome|android).)*safari/i.test(navigator.userAgent)){
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
link.attr("href", this.responseText);
link.show();
}else{
} else {
window.open(this.responseText);
$('#modal_recipe').modal('hide');
}