<commit_before>/**
 * @(#)yobi.code.Browser1.js 2013.04.09
 *
 * Copyright NHN Corporation.
 * Released under the MIT license
 *
 * http://yobi.dev.naver.com/license
 */

(function(ns){

	var oNS = $yobi.createNamespace(ns);
	oNS.container[oNS.name] = function(htOptions){

	    var htVar = {};
        var htElement = {};

		/**
		 * 코드브라우저 초기화
		 * @param {Hash Table} htOptions
		 */
		function _init(htOptions){
		    _initVar(htOptions);
		    _initElement();
            _attachEvent();
		    
            // initialize branches
            if (htVar.oBranch.getValue() === "") {
                htVar.oBranch.selectByValue("HEAD");
            }
            htVar.sRootPath = "code/" + getBranch() + "/!/"; // dynaTree

	        $(window).trigger('hashchange');
            //_initDynaTree();
		}

		/**
		 * 변수 초기화
		 * initialize variables
		 * @param {Hash Table} htOptions
		 */
		function _initVar(htOptions){
		    htVar.sProjectName = htOptions.sProjectName || "";
		    htVar.sRootPath = "";
            htVar.htExtMap = null;
	        htVar.oEditor = null;
	        htVar.oSession = null;        
	        htVar.oBranch = new yobi.ui.Dropdown({
	            "elContainer" : $("#branches")
	        });
	        
	        htVar.rxImg = /\.(jpg|png|gif|tif|bmp|ico|jpeg)$/i;
	        htVar.rxGetHash = /^#/;
	        
	        htVar.bInitTree = false;
	        htVar.nFontSize = 13;
	        
            htVar.sTplListItem = '<tr>\
                <td><a href="${path}" class="${fileClass}" title="${name}"><span class="dynatree-icon vmiddle"></span>${name}</a></td>\
                <td class="messages"><span>${msg}</span></td>\
                <td class="date">${date}</td>\
                <td class="author">${avatar}</td>\
                </tr>';
                
            htVar.htOptSpinner = {
                lines: 10,    // The number of lines to draw
                length: 8,    // The length of each line
                width: 4,     // The line thickness
                radius: 8,    // The radius of the inner circle
                corners: 1,   // Corner roundness (0..1)
                rotate: 0,    // The rotation offset
                direction: 1, // 1: clockwise, -1: counterclockwise
                color: '#000',  // #rgb or #rrggbb
                speed: 1.5,     // Rounds per second
                trail: 60,      // Afterglow percentage
                shadow: false,  // Whether to render a shadow
                hwaccel: false, // Whether to use hardware acceleration
                className: 'spinner', // The CSS class to assign to the spinner
                zIndex: 2e9, // The z-index (defaults to 2000000000)
                top: 'auto', // Top position relative to parent in px
                left: 'auto' // Left position relative to parent in px
            };
		}
		
        /**
         * 엘리먼트 변수 초기화
         * initialize element variables
         */
        function _initElement(){
            htElement.welDynaTree = $("#folderList");
            htElement.welCodeTree = $(".code-tree");
            htElement.welCodeViewer = $('.code-viewer');
            htElement.welCodeViewerWrap = $(".code-viewer-wrap");
            htElement.welBtnResize = $(".btnResize");
            
            htElement.welBreadCrumbs = $("#breadcrumbs");
            htElement.welCommiter = $("#commiter");
            htElement.welCommitMsg = $("#commitMessage");
            htElement.welCommitRev = $("#revisionNo");
            htElement.welCommitDate = $("#commitDate");
            
            htElement.welShowImage = $("#showImage");
            htElement.welShowCode  = $("#showCode");
            htElement.welShowFile  = $("#showFile");
            
            htElement.welShowImageSrc = htElement.welShowImage.find("img");
            htElement.welShowFileName = htElement.welShowFile.find(".filename");
            htElement.welShowFileSize = htElement.welShowFile.find(".filesize");
            htElement.welShowFileHref = htElement.welShowFile.find(".filehref");
            
            htElement.welFileList = $("#fileList");
            htElement.welFileView = $("#fileView");
            htElement.welFileListContent = htElement.welFileList.find(".contents");
            htElement.welBtnRawCode = $("#rawCode");
            htElement.welBtnFullScreen = $("#fullScreen");
            htElement.welBtnFullScreenIcon = htElement.welBtnFullScreen.find("i");
            
            htElement.elSpinTarget = document.getElementById('spin');
        }

		/**
		 * 이벤트 초기화
		 */
		function _attachEvent(){
            $(window).on('hashchange', _onHashChange);
            
            htVar.oBranch.onChange(function(){
                _updateDynaTree();
                $(window).trigger('hashchange');
            });

            // related with resizeList           
            $(window).on("resize", _onResizeWindow);
            $(window).click(function(){ // for IE
                $(window).off("mousemove", _resizeList);
            });

            htElement.welBtnResize.on('drag',function(weEvt){
                _resizeList(weEvt);
            });
            // -- end of resizeList -- //
            
            htElement.welBtnFullScreen.click(_onClickBtnFullScreen);
            yobi.ShortcutKey.attach("ALT+ENTER", _onClickBtnFullScreen);
		}

        /**
         * 어떤 경로 sPath를 입력받아 URI의 path로 사용할 수 있도록 인코딩한다.
         *
         * sPath를 '/' 기준으로 자른 뒤 그 path segment 하나하나를 encodeURIComponent로
         * 각각 인코딩하고 그것들을 '/'를 separator로 하여 다시 이어붙여서 반환한다.
         *
         * @param {String} sPath
         */
        function encodePath(sPath) {
            segments = sPath.split('/');
            encodedSegments = [];
            for (var i = 0; i < segments.length; i++) {
                encodedSegments.push(encodeURIComponent(segments[i]));
            }
            return encodedSegments.join('/');
        }


		/**
		 * hashChange 이벤트 핸들러
		 * 파일 목록 또는 내용을 서버에 요청한다
		 * @param {Event} e
		 */
		function _onHashChange(e){
            var sPath = getHash().replace(htVar.rxGetHash, "");
            var sBranch = getBranch();

            if(sPath != ""){
                _initDynaTree();
                htVar.bInitTree = true;
            }

            $.ajax("code/" + sBranch + "/!" + encodePath(sPath), {<commit_msg>codebrowser: Fix code convention error.<commit_after>/**
 * @(#)yobi.code.Browser1.js 2013.04.09
 *
 * Copyright NHN Corporation.
 * Released under the MIT license
 *
 * http://yobi.dev.naver.com/license
 */

(function(ns){

	var oNS = $yobi.createNamespace(ns);
	oNS.container[oNS.name] = function(htOptions){

	    var htVar = {};
        var htElement = {};

		/**
		 * 코드브라우저 초기화
		 * @param {Hash Table} htOptions
		 */
		function _init(htOptions){
		    _initVar(htOptions);
		    _initElement();
            _attachEvent();
		    
            // initialize branches
            if (htVar.oBranch.getValue() === "") {
                htVar.oBranch.selectByValue("HEAD");
            }
            htVar.sRootPath = "code/" + getBranch() + "/!/"; // dynaTree

	        $(window).trigger('hashchange');
            //_initDynaTree();
		}

		/**
		 * 변수 초기화
		 * initialize variables
		 * @param {Hash Table} htOptions
		 */
		function _initVar(htOptions){
		    htVar.sProjectName = htOptions.sProjectName || "";
		    htVar.sRootPath = "";
            htVar.htExtMap = null;
	        htVar.oEditor = null;
	        htVar.oSession = null;        
	        htVar.oBranch = new yobi.ui.Dropdown({
	            "elContainer" : $("#branches")
	        });
	        
	        htVar.rxImg = /\.(jpg|png|gif|tif|bmp|ico|jpeg)$/i;
	        htVar.rxGetHash = /^#/;
	        
	        htVar.bInitTree = false;
	        htVar.nFontSize = 13;
	        
            htVar.sTplListItem = '<tr>\
                <td><a href="${path}" class="${fileClass}" title="${name}"><span class="dynatree-icon vmiddle"></span>${name}</a></td>\
                <td class="messages"><span>${msg}</span></td>\
                <td class="date">${date}</td>\
                <td class="author">${avatar}</td>\
                </tr>';
                
            htVar.htOptSpinner = {
                lines: 10,    // The number of lines to draw
                length: 8,    // The length of each line
                width: 4,     // The line thickness
                radius: 8,    // The radius of the inner circle
                corners: 1,   // Corner roundness (0..1)
                rotate: 0,    // The rotation offset
                direction: 1, // 1: clockwise, -1: counterclockwise
                color: '#000',  // #rgb or #rrggbb
                speed: 1.5,     // Rounds per second
                trail: 60,      // Afterglow percentage
                shadow: false,  // Whether to render a shadow
                hwaccel: false, // Whether to use hardware acceleration
                className: 'spinner', // The CSS class to assign to the spinner
                zIndex: 2e9, // The z-index (defaults to 2000000000)
                top: 'auto', // Top position relative to parent in px
                left: 'auto' // Left position relative to parent in px
            };
		}
		
        /**
         * 엘리먼트 변수 초기화
         * initialize element variables
         */
        function _initElement(){
            htElement.welDynaTree = $("#folderList");
            htElement.welCodeTree = $(".code-tree");
            htElement.welCodeViewer = $('.code-viewer');
            htElement.welCodeViewerWrap = $(".code-viewer-wrap");
            htElement.welBtnResize = $(".btnResize");
            
            htElement.welBreadCrumbs = $("#breadcrumbs");
            htElement.welCommiter = $("#commiter");
            htElement.welCommitMsg = $("#commitMessage");
            htElement.welCommitRev = $("#revisionNo");
            htElement.welCommitDate = $("#commitDate");
            
            htElement.welShowImage = $("#showImage");
            htElement.welShowCode  = $("#showCode");
            htElement.welShowFile  = $("#showFile");
            
            htElement.welShowImageSrc = htElement.welShowImage.find("img");
            htElement.welShowFileName = htElement.welShowFile.find(".filename");
            htElement.welShowFileSize = htElement.welShowFile.find(".filesize");
            htElement.welShowFileHref = htElement.welShowFile.find(".filehref");
            
            htElement.welFileList = $("#fileList");
            htElement.welFileView = $("#fileView");
            htElement.welFileListContent = htElement.welFileList.find(".contents");
            htElement.welBtnRawCode = $("#rawCode");
            htElement.welBtnFullScreen = $("#fullScreen");
            htElement.welBtnFullScreenIcon = htElement.welBtnFullScreen.find("i");
            
            htElement.elSpinTarget = document.getElementById('spin');
        }

		/**
		 * 이벤트 초기화
		 */
		function _attachEvent(){
            $(window).on('hashchange', _onHashChange);
            
            htVar.oBranch.onChange(function(){
                _updateDynaTree();
                $(window).trigger('hashchange');
            });

            // related with resizeList           
            $(window).on("resize", _onResizeWindow);
            $(window).click(function(){ // for IE
                $(window).off("mousemove", _resizeList);
            });

            htElement.welBtnResize.on('drag',function(weEvt){
                _resizeList(weEvt);
            });
            // -- end of resizeList -- //
            
            htElement.welBtnFullScreen.click(_onClickBtnFullScreen);
            yobi.ShortcutKey.attach("ALT+ENTER", _onClickBtnFullScreen);
		}

        /**
         * 어떤 경로 sPath를 입력받아 URI의 path로 사용할 수 있도록 인코딩한다.
         *
         * sPath를 '/' 기준으로 자른 뒤 그 path segment 하나하나를 encodeURIComponent로
         * 각각 인코딩하고 그것들을 '/'를 separator로 하여 다시 이어붙여서 반환한다.
         *
         * @param {String} sPath
         */
        function _encodePath(sPath) {
            var aSegment = sPath.split('/');
            var aEncodedSegment = [];

            for (var i = 0; i < aSegment.length; i++) {
                aEncodedSegment.push(encodeURIComponent(aSegment[i]));
            }

            return aEncodedSegment.join('/');
        }


		/**
		 * hashChange 이벤트 핸들러
		 * 파일 목록 또는 내용을 서버에 요청한다
		 * @param {Event} e
		 */
		function _onHashChange(e){
            var sPath = getHash().replace(htVar.rxGetHash, "");
            var sBranch = getBranch();

            if(sPath != ""){
                _initDynaTree();
                htVar.bInitTree = true;
            }

            $.ajax("code/" + sBranch + "/!" + _encodePath(sPath), {
{'fraction_non_alphanumeric': 0.1374586679263108, 'fraction_numerical': 0.0067705873090851834, 'mean_word_length': 1.6486655546288573, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '246376', 'n_tokens_mistral': 4140, 'n_tokens_neox': 3950, 'n_words': 714}