summaryrefslogtreecommitdiffstats
path: root/templates/part.navigation.folder.php
AgeCommit message (Expand)Author
2014-12-02fix #680Bernhard Posselt
2014-11-18testBernhard Posselt
2014-11-18testBernhard Posselt
2014-11-18fix #365Bernhard Posselt
2014-11-18fix #368Bernhard Posselt
2014-10-21first try to set indention limit at 80 characters in phpBernhard Posselt
2014-09-25add colon for deleted feed captionBernhard Posselt
2014-09-19Show full unread count when hovering over the unread countBernhard Posselt
2014-09-16classBernhard Posselt
2014-09-13also delete feeds when their parent folder is being deletedBernhard Posselt
2014-09-13remove angular-animate from build, update bower packagesBernhard Posselt
2014-09-13delete feed + undoBernhard Posselt
2014-09-12rename folderBernhard Posselt
2014-09-12add links to desktop/mobile sync clients in the readmeBernhard Posselt
2014-09-12adding feeds and folders, lady and gentlemen :PBernhard Posselt
2014-09-12working on creating foldersBernhard Posselt
2014-09-12create folders!Bernhard Posselt
2014-09-12add folder stylesBernhard Posselt
rd.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# no need for shebang - this file is included from other scripts

LOOPSLEEP_DATE="$(which date)"
if [ -z "$LOOPSLEEP_DATE" ]
    then
    echo >&2 "$0: ERROR: Cannot find the command 'date' in the system path."
    exit 1
fi

# -----------------------------------------------------------------------------
# use the date command as a high resolution timer

now_ms=
LOOPSLEEPMS_HIGHRES=1
test "$($LOOPSLEEP_DATE +%N)" = "%N" && LOOPSLEEPMS_HIGHRES=0
current_time_ms_from_date() {
    if [ $LOOPSLEEPMS_HIGHRES -eq 0 ]
    then
        now_ms="$($LOOPSLEEP_DATE +'%s')000"
    else
        now_ms="$(( $( $LOOPSLEEP_DATE +'%s * 1000 + %-N / 1000000' ) ))"
    fi
}

# -----------------------------------------------------------------------------
# use /proc/uptime as a high resolution timer

current_time_ms_from_date
current_time_ms_from_uptime_started="${now_ms}"
current_time_ms_from_uptime_last="${now_ms}"
current_time_ms_from_uptime_first=0
current_time_ms_from_uptime() {
    local up rest arr=() n

    read up rest </proc/uptime
    if [ $? -ne 0 ]
        then
        echo >&2 "$0: Cannot read /proc/uptime - falling back to current_time_ms_from_date()."
        current_time_ms="current_time_ms_from_date"
        current_time_ms_from_date
        current_time_ms_accuracy=1
        return
    fi

    arr=(${up//./ })

    if [ ${#arr[1]} -lt 1 ]
        then
        n="${arr[0]}000"
    elif [ ${#arr[1]} -lt 2 ]
        then
        n="${arr[0]}${arr[1]}00"
    elif [ ${#arr[1]} -lt 3 ]
        then
        n="${arr[0]}${arr[1]}0"
    else
        n="${arr[0]}${arr[1]}"
    fi

    now_ms=$((current_time_ms_from_uptime_started - current_time_ms_from_uptime_first + n))

    if [ "${now_ms}" -lt "${current_time_ms_from_uptime_last}" ]
        then
        echo >&2 "$0: Cannot use current_time_ms_from_uptime() - new time ${now_ms} is older than the last ${current_time_ms_from_uptime_last} - falling back to current_time_ms_from_date()."
        current_time_ms="current_time_ms_from_date"
        current_time_ms_from_date
        current_time_ms_accuracy=1
    fi

    current_time_ms_from_uptime_last="${now_ms}"
}
current_time_ms_from_uptime
current_time_ms_from_uptime_first="$((now_ms - current_time_ms_from_uptime_started))"
current_time_ms_from_uptime_last="${current_time_ms_from_uptime_first}"
current_time_ms="current_time_ms_from_uptime"
current_time_ms_accuracy=10
if [ "${current_time_ms_from_uptime_first}" -eq 0 ]
    then
    echo >&2 "$0: Invalid setup for current_time_ms_from_uptime() - falling back to current_time_ms_from_date()."
    current_time_ms="current_time_ms_from_date"
    current_time_ms_accuracy=1
fi

# -----------------------------------------------------------------------------
# use read with timeout for sleep

mysleep="mysleep_read"

mysleep_fifo="${NETDATA_CACHE_DIR-/tmp}/.netdata_bash_sleep_timer_fifo"
[ ! -e "${mysleep_fifo}" ] && mkfifo "${mysleep_fifo}"
[ ! -e "${mysleep_fifo}" ] && mysleep="sleep"

mysleep_read() {
    read -t "${1}" <>"${mysleep_fifo}"
    ret=$?
    if [ $ret -le 128 ]
        then
        echo >&2 "$0: Cannot use read for sleeping (return code ${ret})."
        mysleep="sleep"
        ${mysleep} "${1}"
    fi
}


# -----------------------------------------------------------------------------
# this function is used to sleep a fraction of a second
# it calculates the difference between every time is called
# and tries to align the sleep time to give you exactly the
# loop you need.

LOOPSLEEPMS_LASTRUN=0
LOOPSLEEPMS_NEXTRUN=0
LOOPSLEEPMS_LASTSLEEP=0
LOOPSLEEPMS_LASTWORK=0

loopsleepms() {
    local tellwork=0 t="${1}" div s m now mstosleep

    if [ "${t}" = "tellwork" ]
    then
        tellwork=1
        shift
        t="${1}"
    fi

    # $t = the time in seconds to wait

    # if high resolution is not supported
    # just sleep the time requested, in seconds
    if [ ${LOOPSLEEPMS_HIGHRES} -eq 0 ]
    then
        sleep ${t}
        return
    fi

    # get the current time, in ms in ${now_ms}
    ${current_time_ms}

    # calculate ms since last run
    [ ${LOOPSLEEPMS_LASTRUN} -gt 0 ] && \
        LOOPSLEEPMS_LASTWORK=$((now_ms - LOOPSLEEPMS_LASTRUN - LOOPSLEEPMS_LASTSLEEP))
    # echo "# last loop's work took $LOOPSLEEPMS_LASTWORK ms"
    
    # remember this run
    LOOPSLEEPMS_LASTRUN=${now_ms}

    # calculate the next run
    LOOPSLEEPMS_NEXTRUN=$(( ( now_ms - ( now_ms % ( t * 1000 ) ) ) + ( t * 1000 ) ))

    # calculate ms to sleep
    mstosleep=$(( LOOPSLEEPMS_NEXTRUN - now_ms + current_time_ms_accuracy ))
    # echo "# mstosleep is $mstosleep ms"

    # if we are too slow, sleep some time
    test ${mstosleep} -lt 200 && mstosleep=200

    s=$(( mstosleep / 1000 ))
    m=$(( mstosleep - (s * 1000) ))
    [ "${m}" -lt 100 ] && m="0${m}"
    [ "${m}" -lt 10  ] && m="0${m}"

    test $tellwork -eq 1 && echo >&2 " >>> PERFORMANCE >>> WORK TOOK ${LOOPSLEEPMS_LASTWORK} ms ( $((LOOPSLEEPMS_LASTWORK * 100 / 1000)).$((LOOPSLEEPMS_LASTWORK % 10))% cpu ) >>> SLEEPING ${mstosleep} ms"

    # echo "# sleeping ${s}.${m}"
    # echo
    ${mysleep} ${s}.${m}

    # keep the values we need
    # for our next run
    LOOPSLEEPMS_LASTSLEEP=$mstosleep
}

# test it
#while [ 1 ]
#do
#    r=$(( (RANDOM * 2000 / 32767) ))
#    s=$((r / 1000))
#    m=$((r - (s * 1000)))
#    [ "${m}" -lt 100 ] && m="0${m}"
#    [ "${m}" -lt 10  ] && m="0${m}"
#    echo "${r} = ${s}.${m}"
#
#    # the work
#    ${mysleep} ${s}.${m}
#
#    # the alignment loop
#    loopsleepms tellwork 1
#done