SearchTermsCloud

    目次
    ヘッダーがありません
    /**
     * Terms Cloud
     * Provides a visual cloud of commonly searched terms
     */
    
    var uri = $uri ?? page.uri;
    var limit = $limit ?? 20;
    
    var dateSince = $dateSince;
    var dateBefore = $dateBefore ?? date.now;
    var term = $term; 
    
    // fetch the terms
    var queryTerms = searchanalytics.Terms{
        limit: limit,
        since: dateSince,
        before: dateBefore
    };
    
    if (#queryTerms.terms < 1) {
        <div class="no-results">
            <div class="no-results-text">
                wiki.localize("MindTouch.SearchAnalytics.data.empty")
            </div>
        </div>
    } else {
    
    // Begin output
    <div class="mt-search-terms-cloud">
    
    // results output
    var max = list.reduce(queryTerms.terms, "(($item.count >= $value) ? $item.count : $value)", 0);
    
    // sort terms alphabetically
    var alphaTerms = list.sort(queryTerms.terms, "term");
    
    <ul class="terms">
    foreach (var queryTerm in alphaTerms)
    {
        var average = queryTerm.count / max;
        var class = "term rate-";
        if (average > .75) {
            let class ..= "fire";
        } else if (average > .5) {
            let class ..= "high";
        } else if (average > .25) {
            let class ..= "med";
        } else {
            let class ..= "low";
        }
    
        if (term == queryTerm.term) {
            let class ..= " active";
        }
    
        <li class=(class)>
            <a href=(uri & {term: queryTerm.term})>queryTerm.term</a>
        </li>
    }
    </ul>
    </div>
    } // end no-results
    タグ (タグ編集)
    • No tags

    ファイル 0

     
    あなたはコメントを投稿するには ログイン しなければなりません。
    Powered by MindTouch Core