<commit_before>/*
 * Copyright 2014 Ambris
 *
 * Project : Very simple PDF viewer jQuery plugin
 * Version : 0.1
 * author: <NAME> (<EMAIL>)
 *
 * Licensed under the Apache License, Version 2.0(the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http: //www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
(function($) {

    var customStyle = {
        width: '100px',
        height: '100px',
        overflow: 'scroll',
        position: 'absolute',
        top: '-9999px'
    };

    var $scrollDiv = $("<div>").css(customStyle);
    var scrollDiv = $scrollDiv.get(0);
    $("body").append($scrollDiv);

    var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
    var scrollbarHeight = scrollDiv.offsetHeight - scrollDiv.clientHeight;
    document.body.removeChild(scrollDiv);

    $.scrollbar = {
        width: function() {
            return scrollbarWidth;
        },

        height: function() {
            return scrollbarHeight;
        }
    };
})(jQuery);


(function($) {
    $.pdfviewer = function(element, options) {

        var defaults = {
            href: '', // for demonstration purpose
            scale: 1.0,
            autoFit: false,
            toolbar_template: '<div class="pdf-toolbar">' +
                '<button id="pdf-prev">Previous</button>' +
                '<button id="pdf-next">Next</button>' +
                '<span class="pdf-pager">Page:<span id="pdf-page-num"></span>/<span id="pdf-page-count"></span></span>' +
                '<button id="pdf-autofit-height">Adjust Height</button>' +
                '<button id="pdf-autofit-width">Adjust Width</button>' +
                '<button id="pdf-autofit">Auto fit</button>' +
                '</div>',
            viewer_template: '<div class="pdf-canvas"><canvas id="pdf-the-canvas"></canvas></div>',

            onPrevPage: function() {
                return true;
            },
            onNextPage: function() {
                return true;
            },
            onDocumentLoaded: function() {},
            onBeforeRenderPage: function(num) {
                return true;
            },
            onRenderedPage: function(num) {}
        }

        var plugin = this;

        plugin.settings = {};

        var $element = $(element), // reference to the jQuery version of DOM element
            element = element, // reference to the actual DOM element
            elt_width = $element.innerWidth(),
            elt_heigth = $element.innerHeight();

        var pdfDoc = null,
            pageNum = 1,
            pageRendering = false,
            pageNumPending = null,
            scale = 1.0,
            canvas = null,
            ctx = null;

        plugin.init = function() {

            options = options || {};
            options.href = options.href || $element.data('href');

            plugin.settings = $.extend({}, defaults, options);

            $element.html(build());

            if (!PDFJS) {
                console.log('pdf.js not loaded. Add "pdf.js" to your page.');
                return this;
            }

            PDFJS.disableWorker = true;

            scale = plugin.settings.scale;
            canvas = $('#pdf-the-canvas', element).get(0);<commit_msg>add support for pdf.js custom directory<commit_after>/*
 * Copyright 2014 Ambris
 *
 * Project : Very simple PDF viewer jQuery plugin
 * Version : 0.1
 * author: <NAME> (<EMAIL>)
 *
 * Licensed under the Apache License, Version 2.0(the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http: //www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
(function($) {

    var customStyle = {
        width: '100px',
        height: '100px',
        overflow: 'scroll',
        position: 'absolute',
        top: '-9999px'
    };

    var $scrollDiv = $("<div>").css(customStyle);
    var scrollDiv = $scrollDiv.get(0);
    $("body").append($scrollDiv);

    var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
    var scrollbarHeight = scrollDiv.offsetHeight - scrollDiv.clientHeight;
    document.body.removeChild(scrollDiv);

    $.scrollbar = {
        width: function() {
            return scrollbarWidth;
        },

        height: function() {
            return scrollbarHeight;
        }
    };
})(jQuery);


(function($) {
    $.pdfviewer = function(element, options) {

        var defaults = {
            href: '', // for demonstration purpose
            scale: 1.0,
            autoFit: false,
            toolbar_template: '<div class="pdf-toolbar">' +
                '<button id="pdf-prev">Previous</button>' +
                '<button id="pdf-next">Next</button>' +
                '<span class="pdf-pager">Page:<span id="pdf-page-num"></span>/<span id="pdf-page-count"></span></span>' +
                '<button id="pdf-autofit-height">Adjust Height</button>' +
                '<button id="pdf-autofit-width">Adjust Width</button>' +
                '<button id="pdf-autofit">Auto fit</button>' +
                '</div>',
            viewer_template: '<div class="pdf-canvas"><canvas id="pdf-the-canvas"></canvas></div>',

            onPrevPage: function() {
                return true;
            },
            onNextPage: function() {
                return true;
            },
            onDocumentLoaded: function() {},
            onBeforeRenderPage: function(num) {
                return true;
            },
            onRenderedPage: function(num) {}
        }

        var plugin = this;

        plugin.settings = {};

        var $element = $(element), // reference to the jQuery version of DOM element
            element = element, // reference to the actual DOM element
            elt_width = $element.innerWidth(),
            elt_heigth = $element.innerHeight();

        var pdfDoc = null,
            pageNum = 1,
            pageRendering = false,
            pageNumPending = null,
            scale = 1.0,
            canvas = null,
            ctx = null;

        plugin.init = function() {

            options = options || {};
            options.href = options.href || $element.data('href');

            plugin.settings = $.extend({}, defaults, options);

            $element.html(build());

            if (!PDFJS) {
                console.log('pdf.js not loaded. Add "pdf.js" to your page.');
                return this;
            }

            PDFJS.workerSrc = (function() {
                'use strict';
                var scriptTagContainer = document.body ||
                    document.getElementsByTagName('head')[0];
                var pdfjsSrc = $("script[src*='pdf.js']").get(0).src;
                return pdfjsSrc && pdfjsSrc.replace(/(\.js$)|(\.js(\?.*))$/i, '.worker.js$3');
            })();
            PDFJS.disableWorker = true;

            scale = plugin.settings.scale;
            canvas = $('#pdf-the-canvas', element).get(0);
{'fraction_non_alphanumeric': 0.13408406442320284, 'fraction_numerical': 0.0074636637423071885, 'mean_word_length': 1.915267175572519, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '290157', 'n_tokens_mistral': 2096, 'n_tokens_neox': 1999, 'n_words': 541}