Intégrer cookies sur un script
Forum gratuit : Le forum des forums actifs :: Entraide & Support... :: Problème avec un script, un code :: Archives des problèmes avec un code
Page 1 sur 1 • Partagez
Intégrer cookies sur un script
Détails techniques
Version du forum : phpBB2Poste occupé : Administrateur
Navigateur(s) concerné(s) : Opera
Personnes concernées par le problème : Tous les utilisateurs
Lien du forum : http://altitudetropicale.forums-actifs.com/index.forum
Description du problème
Bonjour à tous,auriez vous une idée pour intégrer un cookie sur ce script afin que si la div a été activée et non refermée, qu'elle s'affiche même si la page est réactualisée et, intégrer la mention 'désactiver les onglets lorsque le sélecteur est sur display block ?
- Code:
<button id="baba">
Activer le système à onglets
</button>
<div id="cat-onglets">
</div>
<script>
document.querySelector("#baba").onclick = function() {
if (window.getComputedStyle(document.querySelector('#cat-onglets ')).display=='none'){
document.querySelector("#cat-onglets ").style.display="block";
} else {
document.querySelector("#cat-onglets ").style.display="none";
}
}
</script>
Merci par avance pour votre aide.
Re: Intégrer cookies sur un script
Hello Stéphane ,
dans le même concept ce script devrait faire l'affaire:
Le contenu (affiché/masqué ) se trouve ici:
.
a++
dans le même concept ce script devrait faire l'affaire:
- Code:
<button id="M14_No_Actif">Activer le système à onglets</button>
<button id="M14_Actif"style="display:none;">Désactiver le système à onglets</button>
<div id="cat-onglets"style="display:none;">Contenu</div>
<script>
$(function(){
$('#M14_No_Actif').click(function(){
$(this).hide();
$('#cat-onglets,#M14_Actif').show();
window.localStorage && localStorage.setItem('M14_Onglet',1)
});
$('#M14_Actif').click(function(){
$('#M14_Actif,#cat-onglets').hide();
$('#M14_No_Actif').show();
window.localStorage && localStorage.removeItem('M14_Onglet')
});
window.localStorage && localStorage.getItem('M14_Onglet') && (
$('#M14_No_Actif').hide(),
$('#cat-onglets,#M14_Actif').show()
)
});
</script>
Le contenu (affiché/masqué ) se trouve ici:
- Code:
<div id="cat-onglets"style="display:none;">Contenu</div>
.
a++
Invité- Invité
Re: Intégrer cookies sur un script
Bonjour Philippe,
un grand merci pour cette aide.
Je teste le script de suite pour l'utilisation que je souhaite en faire.
un grand merci pour cette aide.
Je teste le script de suite pour l'utilisation que je souhaite en faire.
Re: Intégrer cookies sur un script
Re,
pas de soucis Stéphane
a++
pas de soucis Stéphane
a++
Invité- Invité
Re: Intégrer cookies sur un script
sur une page html , le script rempli sa fonction à merveille.
Vu que me suis contenté de donner que le script de base en pensant qu'il suffirait de rajouter un cookie, j'ai un peu faussé la donne pour la résolution du problème.
je vais donner un peu plus de détails.
Il y a peu, par le biais de l'aide que tu m'as fournie sur Milouze14, on a installé le système des favoris et, j'en ai profité pour offrir aux membres un affichage pleine page de l'index (demande faite par une majorité de membres).
Juste après installation du sytème, j'a quelques membres qui ont regretté ce système des onglets.
Comme je suis une bonne poire j'ai accédé à cette demande en testant deux systèmes d'onglets qui étaient tout aussi compatible l'un que l'autre. j'ai fini par adopter celui d'ange tuteur pour les catégories en onglets
voici le js modifié en fonction de mon index_box
- Code:
$(function() {
'DEVELOPED BY ANGE TUTEUR';
'NO DISTRIBUTION WITHOUT CONSENT OF THE AUTHOR';
'ORIGIN : http://fmdesign.forumotion.com/t472-category-tabs#5772';
// automatically detects the version
var version = $('.bodylinewidth')[0] ? 0 : document.getElementById('wrap') ? 1 : $('div.pun')[0] ? 2 : document.getElementById('ipbwrapper') ? 3 : document.getElementById('fa_edge') ? 4 : 'badapple';
if (version == 'badapple') {
if (window.console && console.warn) console.warn('The plugin "fa_tabs" is not supported for your forum version.');
return;
}
window.fa_tabs = {
active : my_getcookie('fa_tab_active') || 0, // active tab
list : [], // category list
version : version, // forum version
// language settings
lang : {
title : 'Sélectionner une catégorie',
placeholder : 'Categorie',
all : 'Toutes'
},
// selectors
select : {
content : !version ? '#content-container td:has(> img[height="5"])' : 'main-content',
category : ['table.M14_forumline:has(.secondarytitle)', '.forabg', '.main:has(.tcr) .main-head', '.borderwrap:has(.index-box)', '.forum-category'][version]
},
// function for changing the active category
change : function(index) {
my_setcookie('fa_tab_active', index); // save the active tab to a cookie
// actions to run if the tab is not "all"
if (index != 'all') {
if (fa_tabs.active == 'all') {
fa_tabs.tab[0].previousSibling.className = '';
fa_tabs.display('none');
} else {
fa_tabs.tab[fa_tabs.active].className = '';
fa_tabs.list[fa_tabs.active].style.display = 'none';
}
fa_tabs.tab[index].className = 'fa_tabactif';
fa_tabs.list[index].style.display = '';
if (fa_tabs.version == 2) {
if (fa_tabs.active != 'all') fa_tabs.list[fa_tabs.active].nextSibling.style.display = 'none';
fa_tabs.list[index].nextSibling.style.display = '';
}
} else {
if (fa_tabs.active != 'all') fa_tabs.tab[fa_tabs.active].className = '';
fa_tabs.tab[0].previousSibling.className = 'fa_tabactif';
fa_tabs.display('');
}
fa_tabs.active = index;
},
// change the display of all categories
display : function(state) {
for (var i = 0, j = fa_tabs.list.length; i < j; i++) {
fa_tabs.list[i].style.display = state;
if (version == 2) fa_tabs.list[i].nextSibling.style.display = state;
};
},
// stop tab scrolling
stop : function() {
if (fa_tabs.interval) {
window.clearInterval(fa_tabs.interval);
fa_tabs.interval = null;
}
},
// scroll tablist
scroll : function(by, max) {
if (!fa_tabs.interval) {
var node = document.getElementById('fa_tablist').firstChild.firstChild;
fa_tabs.interval = window.setInterval(function() {
var margin = +node.style.marginLeft.replace(/px/, '');
(by < 0 && margin <= max) || (by > 0 && margin >= max) ? fa_tabs.stop() : node.style.marginLeft = margin + by + 'px';
}, 1);
}
}
};
// startup variables
var frag = document.createDocumentFragment(),
container = $('<div id="fa_category_tabs"><h2 id="fa_tabs_title">' + fa_tabs.lang.title + '</h2></div>')[0],
tablist = $('<div id="fa_tablist"><div class="inner_tabs"><div></div></div></div>')[0],
catglist = $('<div id="fa_catglist" />')[0],
a = $(fa_tabs.select.category, !version ? $(fa_tabs.select.content)[0] : document.getElementById(fa_tabs.select.content)),
i = 0,
j = a.length,
htmlStr = '<a href="javascript:fa_tabs.change(\'all\');">' + fa_tabs.lang.all + '</a>';
// drop off the main container before the first category
a[0] && a[0].parentNode.insertBefore(container, a[0]);
// loop through each category
for (; i < j; i++) {
if (version == 2) var next = a[i].nextSibling;
// create our tabs
htmlStr += '<a href="javascript:fa_tabs.change(' + i + ');">' + ($('H2:first', a[i]).text() || fa_tabs.lang.placeholder + ' ' + i) + '</a>';
// append the category to the list and hide it
catglist.appendChild(a[i]);
a[i].style.display = 'none';
// get the next sibling as well for punbb
if (version == 2) {
catglist.appendChild(next);
next.style.display = 'none';
}
fa_tabs.list[i] = a[i]; // cache the category to the array
}
if (fa_tabs.list[0]) {
tablist.firstChild.firstChild.innerHTML = htmlStr; // fill in the tablist
fa_tabs.tab = [].slice.call(tablist.getElementsByTagName('A')); // create an array for the tabs
fa_tabs.tab.shift(); // remove the all tab
fa_tabs.change(fa_tabs.active); // setup the active tab
// finally add the content to the document
frag.appendChild(tablist);
frag.appendChild(catglist);
container.appendChild(frag);
window.setTimeout(function() {
if (tablist.firstChild.scrollWidth > tablist.firstChild.clientWidth) {
tablist.className = 'fa_tabs_overflow';
tablist.firstChild.firstChild.style.marginLeft = '0px';
tablist.insertAdjacentHTML('beforeend', '<a class="tab_scroller scroll_left" href="#" onmousedown="fa_tabs.scroll(1, 0); return false;" onclick="fa_tabs.stop(); return false;" onmouseout="fa_tabs.stop();"><</a><a class="tab_scroller scroll_right" href="#" onmousedown="fa_tabs.scroll(-1, -' + (tablist.firstChild.scrollWidth - tablist.firstChild.clientWidth) + '); return false;" onclick="fa_tabs.stop(); return false;" onmouseout="fa_tabs.stop();">></a>');
}
}, 100);
}
});
$('head').append('<style type="text/css">#fa_tabs_title{color:#333;font-size:24px;font-weight:400;font-family:arial,sans-serif;margin:3px;line-height:24px}.inner_tabs a,a.tab_scroller{font-family:arial,sans-serif;height:20px;line-height:20px}#fa_tablist{position:relative;white-space:nowrap; text-align: center;}#fa_tablist.fa_tabs_overflow{padding:0 18px}.inner_tabs{overflow:hidden;padding-bottom:1px;margin-bottom:-1px, text-align: center;}a.tab_scroller{color:#FFF;background:#333;font-size:16px;text-align:center;position:absolute;bottom:2px;width:15px;opacity:.1}a.tab_scroller.scroll_left{left:0}a.tab_scroller.scroll_right{right:0}#fa_tablist:hover a.tab_scroller{opacity:.7}#fa_tablist a.tab_scroller:hover{opacity:1}#fa_catglist{background:transparent;}.inner_tabs a{color:#fff!important;background:transparen;border:2px solid #678500;font-size:11px;font-weight:700;display:inline-block;padding:0 10px;margin:3px 3px 0;border-radius:30px}.inner_tabs a.fa_tabactif,.inner_tabs a:hover{background:rgba(255,0,0,.2);position:relative;bottom:-1px;opacity:1}</style>');
Ce js s'est trouvé être compatible avec le système des favoris .
Bon, là, je me suis dit super tout fonctionne, ne reste plus qu'a trouver un script qui me permette de cacher les onglets afin de ne pas gêner ceux qui ne veulent pas de ce système.
Le script donné plus haut a rempli cette fonction mais hélas, il faut ré-activer les onglets à chaque ré-actualisation.
J'a testé le script que tu m'as fourni en essayant de l'adapter avec l'id du script d'ange tuteur (l'id passe de cat-onglets à fa_tablist).
Voici le script (j'ai supprimé la div vu qu'elle est générée par le js d'Ange tuteur)
- Code:
<button id="M14_No_Actif">Activer le système à onglets</button>
<button id="M14_Actif"style="display:none;">Désactiver le système à onglets</button>
<script>
$(function(){
$('#M14_No_Actif').click(function(){
$(this).hide();
$('#fa_tablist,#M14_Actif').show();
window.localStorage && localStorage.setItem('M14_Onglet',1)
});
$('#M14_Actif').click(function(){
$('#M14_Actif,#fa_tablist').hide();
$('#M14_No_Actif').show();
window.localStorage && localStorage.removeItem('M14_Onglet')
});
window.localStorage && localStorage.getItem('M14_Onglet') && (
$('#M14_No_Actif').hide(),
$('#fa_tablist,#M14_Actif').show()
)
});
</script>
Le script fonctionne à merveille pour ceux qui font le choix d'activer les onglets mais, ceux qui ne l'activent pas ont un affichage direct des onglets lors de la ré-actualisation.
Je donne les autres renseignements nécessaires à la résolution du soucis
l'index box
- Spoiler:
- Code:
<style>
.M14_imgFofo{float: left;margin-top: 50px;}
</style>
<table id="M14_Alerte"style="display:none;">
<tr>
<td align="left">
<div id="pres">
<br /><br />
Bonjour ,<br />
merci de vous être inscrit sur le forum.<br />Pour améliorer l'esprit de convivialité, veuillez vous présenter afin que la communauté puisse vous connaitre.<br />Cette simple formalité vous ouvrira l’accès à l'ensemble du forum.<br /><br />
Afin de faciliter votre présentation, un formulaire est à votre disposition. Si vous souhaitez l'utiliser, cliquez <a href="/h8-formulaire-de-presentation"title=" ici ">ici</a>.<br /><br />
Si vous souhaitez faire une présentation simple, cliquez <a href="/f9-presentation-des-nouveaux-membres"title="ici">ici</a>.<br /><br />
Merci de votre compréhension
<br /></div>
</td>
</tr>
</table>
<div id="infogeneral">
<table width="100%" border="0" cellspacing="1" cellpadding="0" align="center">
<tr>
<td valign="bottom">
<!-- BEGIN switch_user_logged_in -->
<div data-off="NON" data-on="OUI" data-sentence="Recevoir nos dernières news : " id="wonderpush-subscription-switch">
</div>
<span class="statmembre"> {CURRENT_TIME}<br /> </span>
<!-- END switch_user_logged_in -->
<span class="nav nav-clean"> <a class="nav" href="{U_INDEX}">Index des forums</a>{NAV_CAT_DESC}</span><br/>
<button id="M14_No_Actif">Activer le système à onglets</button>
<button id="M14_Actif"style="display:none;">Désactiver le système à onglets</button>
<script>
$(function(){
$('#M14_No_Actif').click(function(){
$(this).hide();
$('#fa_tablist,#M14_Actif').show();
window.localStorage && localStorage.setItem('M14_Onglet',1)
});
$('#M14_Actif').click(function(){
$('#M14_Actif,#fa_tablist').hide();
$('#M14_No_Actif').show();
window.localStorage && localStorage.removeItem('M14_Onglet')
});
window.localStorage && localStorage.getItem('M14_Onglet') && (
$('#M14_No_Actif').hide(),
$('#fa_tablist,#M14_Actif').show()
)
});
</script>
</td>
</tr>
<tr>
<div class="bullet"style="display:none;"></div>
<td class="gensmall" align="right" valign="bottom">
<input class="burger-check" id="burger-check" type="checkbox"/>
<label for="burger-check" class="burger"></label>
<nav id="navigation1" class="navigation">
<div class="bu">
<ul>
<!-- BEGIN switch_user_logged_out -->
<style>.bullet{margin-top:60px;margin-left: 35px;}</style>
<li><a class="gensmall" href="/profile?mode=sendpassword" target="_blank">Récupérer un nouveau mot de passe</a> </li>
<!-- END switch_user_logged_out -->
<!-- BEGIN switch_user_logged_in -->
<style>.bullet:after { top: 110px!important;}.bullet:before { top: 84px!important}</style>
<li> <a class="gensmall" href="{U_SEARCH_NEW}">{L_SEARCH_NEW}</a> </li>
<li> <a class="gensmall" href="{U_SEARCH_SELF}">{L_SEARCH_SELF}</a> </li>
<li><a class="gensmall" href="{U_SEARCH_UNANSWERED}">{L_SEARCH_UNANSWERED}</a> </li>
<!-- END switch_user_logged_in -->
</ul>
</div>
</nav>
</td>
</tr>
</table>
</div>
<!-- BEGIN catrow --><!-- BEGIN tablehead --> <table class="M14_forumline" width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<th colspan="{catrow.tablehead.INC_SPAN}" nowrap="nowrap" width="100%" class="secondarytitle"> {catrow.tablehead.L_FORUM} </th>
<th nowrap="nowrap" width="50"style="display:none;">{L_TOPICS}</th>
<th nowrap="nowrap" width="50"style="display:none;">{L_POSTS}</th>
</tr>
<!-- END tablehead -->
<!-- BEGIN cathead -->
<tr>
<!-- BEGIN inc -->
<td class="{catrow.cathead.inc.INC_CLASS}" width="46"><img src="{SPACER}" height="0" width="46" /></td>
<!-- END inc -->
<td class="{catrow.cathead.CLASS_CAT}" colspan="{catrow.cathead.INC_SPAN}" width="100%">
<h{catrow.cathead.LEVEL} class="hierarchy">
<span class="cattitle">
<a class="cattitle" title="{catrow.cathead.CAT_DESC}" href="{catrow.cathead.U_VIEWCAT}">{catrow.cathead.CAT_TITLE}</a>
</span>
</h{catrow.cathead.LEVEL}>
</td>
<td class="{catrow.cathead.CLASS_ROWPIC}" colspan="3" align="right"> </td>
</tr>
<!-- END cathead -->
<!-- BEGIN forumrow -->
<tr>
<td width="70%">
<!-- BEGIN inc -->
<div class="{catrow.forumrow.inc.INC_CLASS}" width="46"><img src="{SPACER}" height="0" width="46" alt="." /></div>
<!-- END inc -->
<div class="M14_imgFofo" align="center" valign="middle">
<img title="{catrow.forumrow.L_FORUM_FOLDER_ALT}" src="{catrow.forumrow.FORUM_FOLDER_IMG}" alt="{catrow.forumrow.L_FORUM_FOLDER_ALT}" />
</div>
<div class="categ">
<h{catrow.forumrow.LEVEL} class="hierarchy">
<span class="forumlink">
<a class="forumlink" href="{catrow.forumrow.U_VIEWFORUM}">{catrow.forumrow.FORUM_NAME}</a><br />
</span>
</h{catrow.forumrow.LEVEL}>
<div style="text-align:justify;"> <div class="cato">
{catrow.forumrow.FORUM_DESC}</div></div>
<span class="gensmall">
<!-- BEGIN switch_moderators_links -->
{catrow.forumrow.switch_moderators_links.L_MODERATOR}{catrow.forumrow.switch_moderators_links.MODERATORS}
<!-- END switch_moderators_links -->
</span>
</div>
<div class="linf">{catrow.forumrow.L_LINKS}{catrow.forumrow.LINKS}</div>
</td>
<td width="30%"align="right" valign="middle">
<!-- BEGIN ads -->
<span class="AD_LastPA">
<span class="lastpost-avatar"><img src="{catrow.forumrow.ads.IMG}" alt="{catrow.forumrow.ads.TITLE}" /></span>
<span class="AD_LastInfos">
<b><a href="{catrow.forumrow.ads.LINK}">{catrow.forumrow.ads.TITLE}</a></b><br />
{catrow.forumrow.ads.DATE}<br />
{catrow.forumrow.ads.LOCATION}
</span>
</span>
<!-- END ads -->
<div class="cata"> <!-- BEGIN avatar -->
<div style="width: 150px;"></div>
<span class="lastpost-avatar">{catrow.forumrow.avatar.LAST_POST_AVATAR}</span>
<!-- END avatar -->
<span class="gensmall"> <div class="stats"> {catrow.forumrow.TOPICS}sujets<br />{catrow.forumrow.POSTS} messages</div> </span> </div>
<div class="catb">
<span class="gensmall last-post">{catrow.forumrow.LAST_POST}</span>
<!-- BEGIN switch_topic_title -->
<div class="lasts"><a href="{catrow.forumrow.U_LATEST_TOPIC_POST}" title="{catrow.forumrow.LATEST_TOPIC_TITLE}"></a></div>
<!-- END switch_topic_title -->
</div>
</td>
</tr>
<!-- END forumrow -->
<!-- BEGIN catfoot -->
<tr>
<!-- BEGIN inc -->
<td class="{catrow.catfoot.inc.INC_CLASS}" width="46"><img src="{SPACER}" height="0" width="46" /></td>
<!-- END inc -->
<td class="spaceRow" colspan="{catrow.catfoot.INC_SPAN}" height="1"><img src="{SPACER}" alt="" height="1" width="1" /></td>
</tr>
<!-- END catfoot -->
<!-- BEGIN tablefoot -->
</table><img src="{SPACER}" alt="" height="5" width="1" /><!-- END tablefoot --><!-- END catrow -->
- Spoiler:
- Code:
$(function() {
'DEVELOPED BY ANGE TUTEUR';
'NO DISTRIBUTION WITHOUT CONSENT OF THE AUTHOR';
'ORIGIN : http://fmdesign.forumotion.com/t501-starred-forums#6825';
if (/\/c\d+-/.test(window.location.href)) return; // return if category
// automatically detects the version
var version = $('.bodylinewidth')[0] ? 0 : document.getElementById('wrap') ? 1 : $('div.pun')[0] ? 2 : document.getElementById('ipbwrapper') ? 3 : document.getElementById('fa_edge') ? 4 : 'badapple';
// error notifications
if (version == 'badapple' || !window.JSON || !window.localStorage) {
var errString = 'The plugin "fa_starred" could not be executed because : ';
if (version == 'badapple') errString += '\nYour forum version is not supported.';
if (!window.JSON) errString += '\nJSON is not supported by your browser';
if (!window.localStorage) errString += '\nThe Storage API is not support by your browser.';
window.console && console.error ? console.error(errString) : alert(errString);
return;
}
// get fontawesome if unavailable
if (!$('link[href$="font-awesome.min.css"]')[0]) {
document.getElementsByTagName('HEAD')[0].insertAdjacentHTML('beforeend', '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.0/css/font-awesome.min.css" />');
}
window.fa_starred = {
version : version, // forum version
forums : localStorage.fa_starred_forums ? JSON.parse(localStorage.fa_starred_forums) : null,
lang :
{
star : 'Mettre ce forum en favoris',
unstar : 'Supprimer ce forum des favoris',
starred : '<center style="cursor:pointer;"title="Cette partie regroupe tous vos forums favoris">Forums favoris</center>'
},
icon : {
star :'<img src="https://i62.servimg.com/u/f62/11/93/85/24/ytoile10.png"/>',
unstar :'<img src="https://i62.servimg.com/u/f62/11/93/85/24/ytoile10.png"/>'
},
// selectors
select : {
content : version ? document.getElementById('main-content') : $('#content-container td:has(> img[height="5"])')[0],
category : ['.M14_forumline:has(.secondarytitle)', '.forabg', '.main:has(.tcr) .main-content', '.borderwrap:has(.index-box)', '.forum-category'][version],
forum : 'a.' + (version ? 'forumtitle' : 'forumlink'),
row : version == 1 ? 'li' : version == 4 ? '.forum-block' : 'tr'
},
// move the selected forum to the "starred" category
star : function(that, id, startup) {
if (!fa_starred.forums) fa_starred.forums = {};
if (!fa_starred.board) fa_starred.createStarBoard();
if (!fa_starred.forums[id]) {
// clone the row and add it to the star board
var clone = $(that).closest(fa_starred.select.row)[0].cloneNode(true),
rows = $(that).closest(fa_starred.select.row).parent().find(fa_starred.select.row);
// update the star attributes for the clone
$('.fa_star', clone).attr({
'onclick' : 'fa_starred.unstar(this, ' + id + '); return false',
'class' : 'fa_unstar',
'title' : fa_starred.lang.unstar
}).html('<i class="fa">' + fa_starred.icon.unstar + '</i>');
fa_starred.list.appendChild(clone); // append the clone to the starred category
$(that).closest(fa_starred.select.row)[0].style.display = 'none'; // hide the original row
// check if all forums are hidden for this category
for (var i = 0, j = rows.length, k = 0; i < j; i++) {
if (/none/.test(rows[i].style.display)) k++;
}
// hide the category if all forums are hidden
if (i == k) {
$(that).closest(fa_starred.select.category)[0].className += ' fa_star_hidden';
}
// jump to the star board if it's out of sight
if (!startup && document.getElementById('fa_star_board').getBoundingClientRect().top < 0) {
window.location.hash = '';
window.location.hash = '#fa_star_board';
}
// update storage
fa_starred.forums[id] = 1;
localStorage.fa_starred_forums = JSON.stringify(fa_starred.forums);
}
},
// unstar the selected forum
unstar : function (that, id) {
var forum, catg, i = 0, j;
fa_starred.list.removeChild($(that).closest(fa_starred.select.row)[0]); // remove cloned row
// update variables
forum = $(fa_starred.select.forum + '[href^="/f' + id + '-"]')[0]; // original forum
catg = $(forum).closest(fa_starred.select.category)[0]; // original category
$(forum).closest(fa_starred.select.row)[0].style.display = ''; // show the original forum's row
// show the category if all forums were hidden
if (/fa_star_hidden/.test(catg.className)) {
catg.className = catg.className.replace(/fa_star_hidden/, '');
}
// delete the starred forum and check if there are anymore stars
delete fa_starred.forums[id];
for (j in fa_starred.forums) {
if (fa_starred.forums[j]) i++;
}
// update storage
if (i) {
localStorage.fa_starred_forums = JSON.stringify(fa_starred.forums);
} else {
fa_starred.forums = null;
localStorage.removeItem('fa_starred_forums');
// remove nodes
if (version == 2) {
fa_starred.board.parentNode.removeChild(fa_starred.board.previousSibling); // remove header for punbb
}
fa_starred.board.parentNode.removeChild(fa_starred.board);
// delete node references
delete fa_starred.board;
delete fa_starred.list;
}
},
// create the "starred" category
createStarBoard : function() {
var catg = $(fa_starred.select.category, fa_starred.select.content)[0],
board = catg ? catg.cloneNode(true) : null,
rows = $(fa_starred.select.row, board);
if (!catg) return;
board.id = 'fa_star_board';
board.style.display = '';
if (version != 2) {
board.getElementsByTagName('H2')[0].innerHTML = fa_starred.lang.starred; // change category title
}
// find forum list and remove exisiting rows in the clone
fa_starred.list = rows[0].parentNode;
rows.remove();
// punbb insertion method
if (version == 2) {
var head = catg.previousSibling.cloneNode(true);
head.getElementsByTagName('H2')[0].innerHTML = fa_starred.lang.starred;
catg.parentNode.insertBefore(board, catg.previousSibling);
board.parentNode.insertBefore(head, board);
} else {
catg.parentNode.insertBefore(board, catg); // default insertion
}
fa_starred.board = board;
}
};
fa_starred.select.row += ':has(' + fa_starred.select.forum + ')'; // update row selector
// general startup
var a = $(fa_starred.select.forum, fa_starred.select.content),
i = 0,
j = a.length,
k,
id;
// setup star board and reset forum states if starred
if (fa_starred.forums) {
if (!fa_starred.board) fa_starred.createStarBoard();
for (k in fa_starred.forums) {
fa_starred.forums[k] = 0;
}
}
// setup stars and starred forums
for (; i < j; i++) {
id = a[i].href.replace(/.*?\/f(\d+).*/, '$1');
a[i].insertAdjacentHTML('afterend', '<a href="#" class="fa_star" onclick="fa_starred.star(this, ' + id + '); return false;" title="' + fa_starred.lang.star + '"><i class="fa">' + fa_starred.icon.unstar + '</i></a>');
if (fa_starred.forums) {
for (k in fa_starred.forums) {
if (k == id) {
fa_starred.star(a[i], id, true);
}
}
}
}
document.getElementsByTagName('HEAD')[0].insertAdjacentHTML('beforeend', '<style type="text/css">a.fa_star,a.fa_unstar{color:#999!important;font-size:16px;vertical-align:-2px;opacity:0;margin-left: 98%!important; margin-top: -2.4%!important;display: inline-block;}a.fa_star:hover,a.fa_unstar,li:hover a.fa_star,tr:hover a.fa_star{opacity:1}a.fa_star i,a.fa_unstar i{position:relative}a.fa_star i:hover:after,a.fa_unstar i:after{content:"' + fa_starred.icon.star + '";position:absolute;left:0;bottom:0}a.fa_unstar i:hover:after{content:""}.fa_star_hidden {display:none!important}a.fa_star i.fa{background:#c1da55;border-radius:50px;padding:3px;border:1px solid #fff}</style>');
});
test effectué sur ce forum :
http://crevettes-passion.forumgratuit.org
Désolé pour ce roman
-----------------------------------------------------------------------------------------------------------------------------------------------------------
edit: je suis une grosse buse
il suffisait de remplacer dans le js des onglets
- Code:
tablist = $('<div id="fa_tablist"><div class="inner_tabs"><div></div></div></div>')[0],
catglist = $('<div id="fa_catglist" />')[0],
- Code:
tablist = $('<div id="fa_tablist"style="display:none;"><div class="inner_tabs"><div></div></div></div>')[0],
Philippe, dis moi si je n'ai pas fait une bourde; on ne sait jamais.
Re: Intégrer cookies sur un script
Hello Stéphane,
tu as choisie l'option la plus fiable et surtout la plus courte .
Cela fonctionne sur mon fofo de tests ,donc pas de soucis .
a++
Philippe, dis moi si je n'ai pas fait une bourde; on ne sait jamais.
tu as choisie l'option la plus fiable et surtout la plus courte .
Cela fonctionne sur mon fofo de tests ,donc pas de soucis .
a++
Invité- Invité
Re: Intégrer cookies sur un script
Merci Philippe
Sujets similaires
» cookies sur script
» Comment intégrer ce Script
» Script horaire à intégrer sur mon forum
» Un problème de script qui avait été résolu en decembre dernier...https://forum.forumactif.com/t394372-script-image-ne-fonctionne-plus
» [bug script] Notification toolbar avec script
» Comment intégrer ce Script
» Script horaire à intégrer sur mon forum
» Un problème de script qui avait été résolu en decembre dernier...https://forum.forumactif.com/t394372-script-image-ne-fonctionne-plus
» [bug script] Notification toolbar avec script
Forum gratuit : Le forum des forums actifs :: Entraide & Support... :: Problème avec un script, un code :: Archives des problèmes avec un code
Page 1 sur 1
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum