Giter VIP home page Giter VIP logo

Comments (16)

alienx2 avatar alienx2 commented on May 21, 2024

credits by Darian Brown (http://www.thecave.info/) and modified by me.

sample

version 1.00 final released! =)

Looking for code? Please look below.

from muximux.

mescon avatar mescon commented on May 21, 2024

People who want this are free to add it, so I wont close the issue for the time being - however, this is beyong the scope of Muximux itself so it will most likely not be included in the official repo.

from muximux.

alienx2 avatar alienx2 commented on May 21, 2024

ok this is like add-on for muximux =)

from muximux.

monsieurpouet avatar monsieurpouet commented on May 21, 2024

I've a little issue:
capture

Why I've a scrollbar ? :(

from muximux.

alienx2 avatar alienx2 commented on May 21, 2024

@monsieurpouet >
same problem here: #49

SOLUTION: find <nav> then replace with <nav style='overflow-y: hidden;'> in muximux.php

Great news! very soon to update code with click to refresh on it =)

from muximux.

monsieurpouet avatar monsieurpouet commented on May 21, 2024

It must put ' instead of ".
If not, this don't work.

Like that:

Thanks for your answer :)

from muximux.

alienx2 avatar alienx2 commented on May 21, 2024

@monsieurpouet oops.. sorry =) i made code without testing.... I'm glad you like this feature.

from muximux.

JudsonHat avatar JudsonHat commented on May 21, 2024

Great news! very soon to update code with click to refresh on it =)

@alienx2 Thanks for your contribution to this project. Did you find a way to refresh the disk space information with a click?

from muximux.

alienx2 avatar alienx2 commented on May 21, 2024

@judhat2... yes im completed script for click to refresh but im about to release final version with 3 mode: timer, click and regular and i'm making easy to install this feature for everyone. stay tuned! =)

from muximux.

JudsonHat avatar JudsonHat commented on May 21, 2024

Thanks, good to hear!

from muximux.

alienx2 avatar alienx2 commented on May 21, 2024

Diskspace Monitor Add-on for Muximux Version 1.00 final

copy and paste code to notepad and save it as "diskspace.php" to where muximux installed folder.

How to Install?

(2 Steps only)
Edit index.php with any code editor or notepad and following:

  1. Add this line after "require 'muximux.php';":
    require('diskspace.php');

  2. Insert this line to <head> </head>:
    <?php echo insertscript('install'); ?>

Added Features:

  • Mode: Click, Timer, Normal
  • Text format
  • Easy to Install for everyone. Just 2 lines only
  • Easy to config
<?php
##########################################################
##########################################################
//                   Created by AlienX2                  //
##########################################################
##########################################################
####### HOW TO INSTALL ###################################
#   * Add to index.php after "require 'muximux.php';":   #
#       require('diskspace.php');                        #
#                                                        #
#   * Add to index.php in <head> </head>:                #
/*      <?php echo insertscript('install'); ?>          */
#                                                        #
##########################################################
##########################################################
###### SETTINGS ##########################################
#   
#   // 'click' = click to refresh; 
#   // 'time' = refresh per time;
#   // 'none' = nothing, just reload page.
    $mode = 'none'; 
#   
#   // 'percent' = percent of how big used of space;
#   // 'ut' = Used space / Total Space;
#   // 'ft' = Free space / Total Space;
#   // 'free' = Free space of size;
    $textbar_type = 'ft';
#   
#   // Required: $mode='time';
#   // xxxx seconds
#   // e.g. '60' seconds = 1 minute; '300' seconds = 5 mins; '900' seconds = 15mins;
    $time = '5';
#   
#   // drive path in '' . e.g. 'd:/' or '/mnt/DownloadHDD'
    $monitor_path = '/mnt/LinuxHOME'; 
#
##########################################################



if(isset($_GET['diskspace'])) {
    echo progressbar('update');
    //echo 'hello';
    return;
}

if(isset($_GET['percentofspace'])) {
    echo progressbar('dp').'%';
    return;
}

if(isset($_GET['html'])) {
    echo progressbar('html');
    return;
}

function insertscript($type) {
    global $mode;
    global $time;

    if($type=='install') {

        $insertcode = "<script src='//code.jquery.com/jquery-1.12.0.min.js'></script><style type='text/css'>

    .diskspace {
        height:35px;
        float: right !important;
        margin-right: 5px;
        margin-top: 3px;
    }

    .progress {
/*          background: #747B8B;*/
        background:none;
            border: 2px solid #747B8B;
            height: 32px;
            width: 120px;
    }

    .progress .prgbar {
            position: relative;
            height: 32px;
            z-index: 999;
    }

    .prgbar {
        background:#f5f5f5 !important;
    }
    .progress .prgtext {
            color: gray;
            text-align: center;
            font-size: 13px;
            padding: 6px 0 0;
            width: 120px;
            position: absolute;
            z-index: 1000;
            text-shadow: 1px 1px #747B8B;
    }
    .progress .prginfo {
            margin: 3px 0;
    }

    </style>
    ";

    if ($mode == 'time') {
        $insertcode .= "
            <script>
                $(document).ready(function() {
                    $('".'<li class="diskspace" style="cursor:default !important;"></li>'."').insertBefore( 'ul.cd-tabs-navigation nav li:last-child' );

                    $.get('diskspace.php?html', function(data){
                        $('li.diskspace').html(data);
                    });

                    $.get('diskspace.php?percentofspace', function(data){
                        $('.progress .prgbar').width(data);
                    });
                });
            </script>
        <script>
            var refresh = setInterval(
                function (){
                    $.get('diskspace.php?percentofspace', function(data){
                        $('.progress .prgbar').width(data);
                    });

                    $.get('diskspace.php?percentofspace', function(data){
                        $('.progress .prgbar').width(data);
                    });

                    $('div.prgtext').load('diskspace.php?diskspace');

                    }, ".convertmilliseconds($time).");
        </script>
        ";
    } else if ($mode == 'click') {
        $insertcode .= "<script>
        $(document).ready(function() {
            $('".'<li class="diskspace"></li>'."').insertBefore( 'ul.cd-tabs-navigation nav li:last-child' );

            $.get('diskspace.php?html', function(data){
                $('li.diskspace').html(data);
            });

            $.get('diskspace.php?percentofspace', function(data){
                $('.progress .prgbar').width(data);
            });

            $('.diskspace').click(function() {
                $.get('diskspace.php?percentofspace', function(data){
                    $('.progress .prgbar').width(data);
                });

                $('.diskspace div.prgtext').load('diskspace.php?diskspace');
            });
        });
        </script>";
    } else { $insertcode .= "<script>
        $(document).ready(function() {
            $('".'<li class="diskspace" style="cursor:default !important;"></li>'."').insertBefore( 'ul.cd-tabs-navigation nav li:last-child' );

            $.get('diskspace.php?html', function(data){
                $('li.diskspace').html(data);
            });

            $.get('diskspace.php?percentofspace', function(data){
                $('.progress .prgbar').width(data);
            });
        });
        </script>

        "; }


    return $insertcode;


    }
}

function convertmilliseconds ($seconds) {
    return $seconds * 1000;
}

function progressbar($request = '') {

    global $monitor_path;
    global $textbar_type;

    $dfree = disk_free_space($monitor_path);
    $dt = disk_total_space($monitor_path);
    $du = $dt - $dfree;
    $dp = sprintf('%.2f',($du / $dt) * 100);
    $df = HumanSize($dfree);
    $dt = HumanSize($dt);
    $du = HumanSize($du);

    if($textbar_type == 'percent') {
        $data = $dp.' %';
    } else if($textbar_type == 'ut') {
        $data = $du." / ".$dt;
    } else if($textbar_type == 'ft') {
        $data = $df." / ".$dt;
    } else if($textbar_type == 'free') {
        $data = HumanSize($dfree, 2).' left';
    } else {
        $data = 'ERROR: $textbar_type is missing!';
    }

    if($request == 'dp') {
     return $dp;    
    } else if ($request == "update") {
        return $data;

        //return $df .'/'. $dt;
    } else if ($request == "html") {
     return 
        '<div class="progress">
           <div class="prgtext">'.$data.'</div><div class="prgbar"></div><div class="prginfo">
                   </div></div>';
    }

}

function HumanSize($bytes, $digit = 1)
{
    $types = array( 'B', 'KB', 'MB', 'GB', 'TB' );
            for( $i = 0; $bytes >= 1024 && $i < ( count( $types ) -1 ); $bytes /= 1024, $i++ );
                    return( round( $bytes, $digit ) . " " . $types[$i] );
}

?>

from muximux.

alienx2 avatar alienx2 commented on May 21, 2024

@judhat2 @monsieurpouet i just release code. Grab it =) Don't forget to install fresh muximux.

from muximux.

mescon avatar mescon commented on May 21, 2024

@alienx2 Nice job! FYI, you're inserting an instance of jQuery, when Muximux itself already loads jQuery. This creates a javascript conflict, so perhaps you could make it work with the bundled jquery version?

from muximux.

alienx2 avatar alienx2 commented on May 21, 2024

@mescon Thanks =) and i tried tested it not working without add jQuery. that's why i added.

from muximux.

alienx2 avatar alienx2 commented on May 21, 2024

@mescon i found you put jquery in index.php but very bottom instead of put in <head></head>... it didnt work with my code? even also jquery wont work?

from muximux.

mescon avatar mescon commented on May 21, 2024

@alienx2 All javascript is at the bottom for performance reasons. Read more here: https://developer.yahoo.com/performance/rules.html#js_bottom=

from muximux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.