code minimal opérationnel
This commit is contained in:
parent
82b8fbc553
commit
8d19531e79
4 changed files with 54 additions and 7 deletions
|
@ -9,6 +9,18 @@
|
||||||
<div>
|
<div>
|
||||||
#ACTION_FORMULAIRE
|
#ACTION_FORMULAIRE
|
||||||
|
|
||||||
|
<div class="editer_groupe">
|
||||||
|
#SET{name,urlmobile}
|
||||||
|
#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}}
|
||||||
|
#SET{obli,"obligatoire"}
|
||||||
|
<div class="editer editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]">
|
||||||
|
<label for="#GET{name}">URL redirection mobile</label>
|
||||||
|
[<span class="erreur_message">(#GET{erreurs})</span>]
|
||||||
|
<input type="text" class="text urlmobile" name="#GET{name}" id="#GET{name}" value="#ENV{#GET{name}}" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<input type="hidden" name="_meta_casier" value="redirectmobile" />
|
<input type="hidden" name="_meta_casier" value="redirectmobile" />
|
||||||
<p class="boutons"><span class="image_loading"> </span><input type="submit" class="submit" value="<:bouton_enregistrer|attribut_html:/>" /></p>
|
<p class="boutons"><span class="image_loading"> </span><input type="submit" class="submit" value="<:bouton_enregistrer|attribut_html:/>" /></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,18 +7,13 @@
|
||||||
logo="prive/themes/spip/images/redirectmobile-xx.svg"
|
logo="prive/themes/spip/images/redirectmobile-xx.svg"
|
||||||
documentation=""
|
documentation=""
|
||||||
>
|
>
|
||||||
<!--
|
|
||||||
Paquet généré le 2020-12-26 10:34:32
|
|
||||||
-->
|
|
||||||
|
|
||||||
<nom>Redirect Mobile</nom>
|
<nom>Redirect Mobile</nom>
|
||||||
|
|
||||||
|
|
||||||
<auteur lien='https://gamuza.fr'>tofulm</auteur>
|
<auteur lien='https://gamuza.fr'>tofulm</auteur>
|
||||||
|
|
||||||
<licence>GNU/GPL</licence>
|
<licence>GNU/GPL</licence>
|
||||||
|
|
||||||
<pipeline nom="autoriser" inclure="redirectmobile_autorisations.php" />
|
<pipeline nom="autoriser" inclure="redirectmobile_autorisations.php" />
|
||||||
|
<pipeline nom="jquery_plugins" inclure="redirectmobile_pipelines.php" />
|
||||||
|
|
||||||
</paquet>
|
</paquet>
|
||||||
|
|
34
redirectMobile.js.html
Normal file
34
redirectMobile.js.html
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#HTTP_HEADER{Content-Type: text/javascript; charset=utf-8}
|
||||||
|
#HTTP_HEADER{Vary: Accept-Encoding}
|
||||||
|
[(#REM)<script>]
|
||||||
|
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
redirectPWA();
|
||||||
|
});
|
||||||
|
|
||||||
|
// redirection vers le site PWA
|
||||||
|
async function redirectPWA() {
|
||||||
|
if ('userAgent' in navigator) {
|
||||||
|
try {
|
||||||
|
if( navigator.userAgent.match(/iPhone/i)
|
||||||
|
|| navigator.userAgent.match(/webOS/i)
|
||||||
|
|| navigator.userAgent.match(/Android/i)
|
||||||
|
|| navigator.userAgent.match(/iPad/i)
|
||||||
|
|| navigator.userAgent.match(/iPod/i)
|
||||||
|
|| navigator.userAgent.match(/BlackBerry/i)
|
||||||
|
|| navigator.userAgent.match(/Windows Phone/i)
|
||||||
|
){
|
||||||
|
var question = confirm("Voulez-vous consulter la version mobile de ce site ?")
|
||||||
|
if (question){
|
||||||
|
var url = "#CONFIG{redirectmobile/urlmobile}";
|
||||||
|
window.location = url;
|
||||||
|
} else {
|
||||||
|
console.log("version desktop");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.log('Redirect vers site mobile indisponible');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,3 +12,9 @@
|
||||||
if (!defined('_ECRIRE_INC_VERSION')) {
|
if (!defined('_ECRIRE_INC_VERSION')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function redirectmobile_jquery_plugins($scripts) {
|
||||||
|
$scripts[] = produire_fond_statique('redirectMobile.js');
|
||||||
|
return $scripts;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue