The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
2 posters

    Updated : Add pagination to the mobile version

    كونان2000
    كونان2000
    Forumember


    Male Posts : 284
    Reputation : 120
    Language : Arabic

    Updated :  Add pagination to the mobile version Empty Updated : Add pagination to the mobile version

    Post by كونان2000 June 10th 2021, 11:05 pm

    Hello ,
    I have improved the numbering code here  https://help.forumotion.com/t136884-add-pagination-to-the-mobile-version?highlight=mobile ,
    Why not replace the old with the new?
    Updated :  Add pagination to the mobile version Ocia_a14
    java
    Code:


    $(function() {
      var perpage = 5, // amount of messages before a new page is added
      p = document.getElementsByTagName('P'), l = window.location.pathname, current, last, tid = l.replace(/\/t(\d+).*/,'$1'), tname = l.replace(/(\/t\d+|\/t\d+p\d+)(-.*)/,'$2'), style = document.createElement('STYLE'), css = '', i,j;
     
      if (typeof _userdata.page_desktop === '.mobile_title') return;
      style.type = 'text/css';
      if (style.styleSheet) style.styleSheet.cssText = css;
      else style.appendChild(document.createTextNode(css));
      document.getElementsByTagName('HEAD')[0].appendChild(style);
     
      for (i=0; i<p.length; i++) {
        if (/mobile_title_content/.test(p[i].className)) {
          current = Number(p[i].innerHTML.replace(/.*?<strong>(\d+)<\/strong>.*?<strong>\d+<\/strong>/i,'$1'));
          last = Number(p[i].innerHTML.replace(/.*?<strong>\d+<\/strong>.*?<strong>(\d+)<\/strong>/i,'$1'));
        }
      }
     
      if (last >= current) {
        var b = document.getElementsByTagName('DIV'), title = document.createElement('DIV'), cen = document.createElement('DIV'), left = document.createElement('DIV'), right = document.createElement('DIV'), c = 1, d = 0;
        title.className = 'mobile_title', left.className = 'left scroller', right.className = 'right scroller', cen.className = 'mobile_title_content', cen.setAttribute('style','left:85px;right:85px;text-overflow:clip;');
        for (j=0; j<b.length; j++) if (/mobile_title/.test(b[j].className)) if (/\d+/.test(b[j].nextSibling.id) || /poll/.test(b[j].nextSibling.className)) b[j].parentNode.insertBefore(title,b[j].nextSibling);
        title.appendChild(cen), title.appendChild(left), title.appendChild(right);
      
        left.onmousedown = function() { cen.scrollLeft -= 100 };
        right.onmousedown = function() { cen.scrollLeft += 100 };
     
        while (d < 2) {
          if (d == 0 && current > 1) newPage('p.mobile_prev_button block', '<p>First</p>', '/t' + tid + tname, title);
          else if (d == 1 && current != last) newPage('p.mobile_next_button block', '<p></p>', '/t' + tid + 'p' + Number(perpage * last - perpage) + tname, title);
          d += 1;
        } while (last + 1 > c) {
          if (c == current) newPage('p.mobile_next_button block pagi pagactif', c, 'javascript:void(0);', cen, 'currentPage');
          else newPage('p.mobile_next_button block pagi', c, '/t' + tid + 'p' + Number(perpage * c - perpage) + tname, cen);
          c += 1;
        }
        cen.scrollLeft = document.getElementById('currentPage').offsetLeft;
      }
      function newPage(classname, html, href, par, id) {var page = document.createElement('A'); page.className = classname, page.innerHTML = html, page.href = href, par.appendChild(page); if (id) page.id = id}
    });

    css
    Code:


    .mobile_title_content a {
        font-size: 25px;
        color: blue;
      background-color: #2C353B;
        border-radius: 3px;
        color: #FFF;
        display: inline-block;
        font-size: 1.2rem;
        font-weight: 400;
        line-height: 30px;
        margin: 0 6px 0 0;
        padding: 0;
        text-align: center;
        text-decoration: none;
        width: 36px;
    }

    This tutorial was written by Ange Tuteur.
     Updated by نوار2000

    TonnyKamper and poesia-verses like this post

    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3523
    Language : English
    Location : United States

    Updated :  Add pagination to the mobile version Empty Re: Updated : Add pagination to the mobile version

    Post by SLGray June 11th 2021, 2:20 am

    This is nit where you post tutorials.   Please send it in a PM to a staff member.

    Topic Locked



    Updated :  Add pagination to the mobile version Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.

      Current date/time is November 11th 2024, 5:23 pm