<commit_before>/* jshint devel:true */
(function () {
    'use strict';
    //var actionType = 'create';
    var actionType = 'edit';
    var pageId = '';
    var domId = 'content-left-inner';
    var dataRules = {
        'lists': 'array',
        'items': 'item',
        'type': 'readonly',
        'theme': ['default', 'luxury', 'myFT', 'technology', 'lifestyle', 'ebook'],
        //'type': ['block', 'banner', 'header', 'footer'],
        'side': ['none', 'HomeRightRail','TagRightRail', 'MostPopular', 'HotVideos', 'MarketsData', 'videos', 'MostCommented'],
        'sideAlign': ['right', 'left'],
        'float': ['none', 'left', 'right', 'oneline', 'SideBySide', 'myFT', 'IconTitle', 'Card', 'eBook'],
        'showTag': ['no', 'yes'],
        'showTimeStamp': ['no', 'new stories', 'all'],
        'from': ['', 'MarketsData', 'SpecialReports', 'Columns', 'Channels', 'Events', 'MyTopics', 'Marketing', 'findpassword'],
        'sideOption': ['headlineOnly', 'leadOnly', 'imageAndText', 'textOverImage'],
        'preferLead': ['longlead', 'shortlead', 'none'],
        'feedType': ['all','story','video','interactive','photo','job', 'myFT', 'fav', 'ftc_columns', 'ft_columns'],
        'feedItems': 'number',
        'feedImage': ['optional','necessary','hide'],
        'language': ['', 'en', 'ce']
    };
    var dataRulesTitle = {
        'theme': 'Luxury是指乐尚街的配色风格，主要特点是Title和分割线为金色',
        'side': '采用事先写好的模版',
        'name': '仅供编辑内部沟通，不会被读者看见，尽量采用英文的name',
        'title': 'list的title会被读者看见，请使用中文',
        'url': '请尽量使用相对链接，比如［/tag/中国经济］',
        'sideAlign': ' 这个Block的侧边栏放在右边还是左边',
        'float': '如果某个list有文章没有配图，可以采用float到左边的方式来展示这个List，同时其余的list自动float到右边；如果想要某个list，如cover占据全部宽度，则设定其为oneline；如果想要像myFT那样一行一条内容，则选择myFT；想要强制设定这个List所有内容都采用同样的展现形式，则选择Card',
        'showTag': '程序会抓取tag字段中第一个tag做为primary tag来显示',
        'showTimeStamp': 'new stories代表只在文章发布的一个小时内显示时间，all代表在所有情况下都显示时间',
        'from': '选取事先写好的模版',
        'sideOption': 'headlineOnly表示只显示标题；leadOnly表示只显示lead，这个功能可以用来展示联系方式一类的文字信息；imageAndText显示方式类似微信公众号的图文信息，第一条出大图',
        'preferLead': '优先显示的lead类型',
        'feedType': '自动抓取的内容类型，如果选择all则四种类型都抓取，最新的先显示',
        'feedImage': 'Optional代表不要求抓出来的内容必须有配图，Necessary则要求内容必须有配图',
        'feedItems': '自动抓取内容的条数上限，如果这个list中有手动拖入的内容，则不显示自动抓取的内容',
        'feedTag': '自动抓取内容依据的标签，如果抓取条件复杂，也可以请技术帮助你输入mysql的查询语句',
        'language': '中文、英文或者中英文对照，只适用于story'
    };
    var toolkits = {
        'section': {
            'block': ['title', 'name', 'side', 'sideAlign'],
            'include': ['from', 'side', 'sideAlign'],
            'header': [],
            'banner': ['position'],
            'footer': []
        },
        'list': {
            'list': ['name', 'title', 'url', 'language', 'description', 'style', 'float', 'showTag', 'showTimeStamp', 'preferLead', 'sponsorAdId', 'sponsorLogoUrl', 'sponsorLink', 'sponsorNote', 'feedItems', 'feedTag', 'feedType', 'feedImage'],
            'SideMPU': ['name'],
            'SideWithItems':['name', 'title', 'url', 'sideOption', 'feedItems', 'feedTag', 'feedType'],
            'SideRanking': ['name', 'title', 'url', 'feedItems', 'feedTag', 'feedType']
        }
    };
    var devices = [
        {'name': 'PC or Mac', 'width': '', 'height': ''},
        {'name': 'iPhone 5', 'width': 320, 'height': 580},
        {'name': 'iPhone 6', 'width': 375, 'height': 627},
        {'name': 'iPhone 6 Plus', 'width': 414, 'height': 736},
        {'name': 'iPad LandScape', 'width': 1024, 'height': 748},
        {'name': 'iPad Portrait', 'width': 768, 'height': 1024},
        {'name': 'Huawei Mate 8', 'width': 540, 'height': 960},
        {'name': 'Google Nexus 7', 'width': 600, 'height': 960}
    ];
    var thisday = new Date();
    var thenow = thisday.getHours() * 10000 + thisday.getMinutes() * 100 + thisday.getSeconds();
    var todaydate = thisday.getFullYear() + '-' + (thisday.getMonth() + 1) + '-' + thisday.getDate();
    var pagemakerAPIRoot = '/falcon.php/pagemaker/';
    var storyAPIRoot = '/falcon.php/homepage/getstoryapi/';
    var gApiUrls = {
        //'home': 'api/page/home.json',
        'home': pagemakerAPIRoot + 'get/'+ getURLParameter('page') +'/' + todaydate + '?' + thenow,
        'homePOST': pagemakerAPIRoot + 'post/'+ getURLParameter('page') +'/' + todaydate,
        'blank': 'api/page/blank.json',
        'stories': storyAPIRoot + todaydate + '?' + thenow
    };
    var gApiUrlsLocal = {
        'home': 'api/page/home.json',
        'homePOST': 'api',
        'blank': 'api/page/blank.json',
        'stories': 'api/page/stories.json'
    };

    //drag and drop
    var dragSrcEl = null;
    var dragIndex;
    var dragOverIndex;
    var customPageJSON;

    // get parameter value from url

    /* jshint ignore:start */
    function getURLParameter(name) {
        return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;
    }
    /* jshint ignore:end */


    //将Unix时间戳转换为中文日期和星期
    function unixtochinese(thetime, datetype) {
        var todaystamp, dayArray, dayChar, thehour, theminute, ampm, currentDate, currentDateStamp, itemDateStamp;
        if (thetime === 'hide') {
            return '';
        }
        currentDate = new Date();
        currentDateStamp = currentDate.getFullYear() * 10000 + (currentDate.getMonth() + 1) * 100 + currentDate.getDate();
        thisday = new Date(thetime * 1000);
        itemDateStamp = thisday.getFullYear() * 10000 + (thisday.getMonth() + 1) * 100 + thisday.getDate();
        todaystamp = thisday.getFullYear() + '年' + (thisday.getMonth() + 1) + '月' + thisday.getDate() + '日 星期';
        dayArray = '日一二三四五六';
        dayChar = dayArray[thisday.getDay()];
        todaystamp += dayChar;
        thehour = thisday.getHours();
        thehour = ('0' + thehour).slice(-2);
        theminute = thisday.getMinutes();
        theminute = ('0' + theminute).slice(-2);
        ampm = (thehour < 12) ? 'AM' : 'PM';
        if (datetype === 1) {
            todaystamp = ' ' + thehour + ':' + theminute + ' ' + ampm;
        } else if (datetype === 2) {
            //console.log (currentDateStamp);
            //console.log (todaystamp);
            if (currentDateStamp === itemDateStamp) {
                todaystamp = thehour + ':' + theminute;
            } else {
                todaystamp = (thisday.getMonth() + 1) + '/' + thisday.getDate() + ' ' + thehour + ':' + theminute;
            }
        } else if (datetype === 3) {
            if (/^[0-9]{4}\-[0-9]{1,2}\-[0-9]{1,2}$/gi.test(thetime)) {
                //console.log (thetime);
                todaystamp = thetime.replace(/^[0-9]{4}\-([0-9]{1,2}\-[0-9]{1,2})$/g, '$1');
                todaystamp = todaystamp.replace(/^0/g, '').replace(/\-0/g, '/').replace('-', '/');
            } else {
                todaystamp = (thisday.getMonth() + 1) + '/' + thisday.getDate();
            }
        }
        return todaystamp;
    }

    function renderAPI(id, headline, timeStamp, timeStampType, longlead, shortlead, image, type, tag, customLink, relativestory, showRelativeStoryItems) {
        var editLink = '';
        var previewLink = '';
        var dataHTML = '';
        var oTimeStamp = timeStamp;
        var relativestoryHTML = '';
        var hasImageClass = '';
        var imageBG = '';
        if (typeof showRelativeStoryItems !== 'undefined') {
            showRelativeStoryItems = '<div class="item-info-item"><div class="item-info-title">Show Related Items: </div><input type="number" title="How Many Related Content Would You Like to Show in This Page? " name="showRelativeStoryItems" class="o-input-text" value="' + showRelativeStoryItems + '"></div>';
        } else {
            showRelativeStoryItems = '';
        }
        if (type === 'story') {
            editLink = 'https://backyard.ftchinese.com/falcon.php/story/edit/' + id;
            previewLink = 'http://www7.ftchinese.com/story/' + id;
        } else if (type === 'interactive') {
            editLink = 'https://backyard.ftchinese.com/falcon.php/ia/edit/' + id;
            previewLink = 'http://www7.ftchinese.com/interactive/' + id;
        } else if (type === 'photo') {
            editLink = 'https://backyard.ftchinese.com/falcon.php/pics/edit_photonews/' + id;
            previewLink = 'http://www7.ftchinese.com/photonews/' + id;
        } else if (type === 'video') {
            editLink = 'https://backyard.ftchinese.com/create_videostory.php?id=' + id;
            previewLink = 'http://www7.ftchinese.com/video/' + id;
        }
        if (timeStamp !== '') {
            timeStamp = unixtochinese(timeStamp, timeStampType);
        } else {
            timeStamp = '<div class="new-item"></div>';
        }<commit_msg>back up<commit_after>/* jshint devel:true */
(function () {
    'use strict';
    //var actionType = 'create';
    var actionType = 'edit';
    var pageId = '';
    var domId = 'content-left-inner';
    var dataRules = {
        'lists': 'array',
        'items': 'item',
        'type': 'readonly',
        'theme': ['default', 'luxury', 'myFT', 'technology', 'lifestyle', 'ebook'],
        //'type': ['block', 'banner', 'header', 'footer'],
        'side': ['none', 'HomeRightRail','TagRightRail', 'MostPopular', 'HotVideos', 'MarketsData', 'videos', 'MostCommented'],
        'sideAlign': ['right', 'left'],
        'float': ['none', 'left', 'right', 'oneline', 'SideBySide', 'myFT', 'IconTitle', 'Card', 'eBook'],
        'showTag': ['no', 'yes'],
        'showTimeStamp': ['no', 'new stories', 'all'],
        'from': ['', 'MarketsData', 'SpecialReports', 'Columns', 'Channels', 'Events', 'MyTopics', 'Marketing', 'findpassword'],
        'sideOption': ['headlineOnly', 'leadOnly', 'imageAndText', 'textOverImage'],
        'preferLead': ['longlead', 'shortlead', 'none'],
        'feedType': ['all','story','video','interactive','photo','job', 'myFT', 'fav', 'ftc_columns', 'ft_columns'],
        'feedItems': 'number',
        'feedImage': ['optional','necessary','hide'],
        'language': ['', 'en', 'ce']
    };
    var dataRulesTitle = {
        'theme': 'Luxury是指乐尚街的配色风格，主要特点是Title和分割线为金色',
        'side': '采用事先写好的模版',
        'name': '仅供编辑内部沟通，不会被读者看见，尽量采用英文的name',
        'title': 'list的title会被读者看见，请使用中文',
        'url': '请尽量使用相对链接，比如［/tag/中国经济］',
        'sideAlign': ' 这个Block的侧边栏放在右边还是左边',
        'float': '如果某个list有文章没有配图，可以采用float到左边的方式来展示这个List，同时其余的list自动float到右边；如果想要某个list，如cover占据全部宽度，则设定其为oneline；如果想要像myFT那样一行一条内容，则选择myFT；想要强制设定这个List所有内容都采用同样的展现形式，则选择Card',
        'showTag': '程序会抓取tag字段中第一个tag做为primary tag来显示',
        'showTimeStamp': 'new stories代表只在文章发布的一个小时内显示时间，all代表在所有情况下都显示时间',
        'from': '选取事先写好的模版',
        'sideOption': 'headlineOnly表示只显示标题；leadOnly表示只显示lead，这个功能可以用来展示联系方式一类的文字信息；imageAndText显示方式类似微信公众号的图文信息，第一条出大图',
        'preferLead': '优先显示的lead类型',
        'feedType': '自动抓取的内容类型，如果选择all则四种类型都抓取，最新的先显示',
        'feedImage': 'Optional代表不要求抓出来的内容必须有配图，Necessary则要求内容必须有配图',
        'feedItems': '自动抓取内容的条数上限，如果这个list中有手动拖入的内容，则不显示自动抓取的内容',
        'feedTag': '自动抓取内容依据的标签，如果抓取条件复杂，也可以请技术帮助你输入mysql的查询语句',
        'language': '中文、英文或者中英文对照，只适用于story'
    };
    var toolkits = {
        'section': {
            'block': ['title', 'name', 'side', 'sideAlign'],
            'include': ['from', 'side', 'sideAlign'],
            'header': [],
            'banner': ['position'],
            'footer': []
        },
        'list': {
            'list': ['name', 'title', 'url', 'language', 'description', 'style', 'float', 'showTag', 'showTimeStamp', 'preferLead', 'sponsorAdId', 'sponsorLogoUrl', 'sponsorLink', 'sponsorNote', 'feedItems', 'feedTag', 'feedType', 'feedImage'],
            'SideMPU': ['name'],
            'SideWithItems':['name', 'title', 'url', 'sideOption', 'feedItems', 'feedTag', 'feedType'],
            'SideRanking': ['name', 'title', 'url', 'feedItems', 'feedTag', 'feedType']
        }
    };
    var devices = [
        {'name': 'PC or Mac', 'width': '', 'height': ''},
        {'name': 'iPhone 5', 'width': 320, 'height': 580},
        {'name': 'iPhone 6', 'width': 375, 'height': 627},
        {'name': 'iPhone 6 Plus', 'width': 414, 'height': 736},
        {'name': 'iPad LandScape', 'width': 1024, 'height': 748},
        {'name': 'iPad Portrait', 'width': 768, 'height': 1024},
        {'name': 'Huawei Mate 8', 'width': 540, 'height': 960},
        {'name': 'Google Nexus 7', 'width': 600, 'height': 960}
    ];
    var thisday = new Date();
    var thenow = thisday.getHours() * 10000 + thisday.getMinutes() * 100 + thisday.getSeconds();
    var todaydate = thisday.getFullYear() + '-' + (thisday.getMonth() + 1) + '-' + thisday.getDate();
    var pagemakerAPIRoot = '/falcon.php/pagemaker/';
    var storyAPIRoot = '/falcon.php/homepage/getstoryapi/';
    var gApiUrls = {
        //'home': 'api/page/home.json',
        'home': pagemakerAPIRoot + 'get/'+ getURLParameter('page') +'/' + todaydate + '?' + thenow,
        'homePOST': pagemakerAPIRoot + 'post/'+ getURLParameter('page') +'/' + todaydate,
        'blank': 'api/page/blank.json',
        'stories': storyAPIRoot + todaydate + '?' + thenow
    };
    var gApiUrlsLocal = {
        'home': 'api/page/home.json',
        'homePOST': 'api',
        'blank': 'api/page/blank.json',
        'stories': 'api/page/stories.json'
    };

    //drag and drop
    var dragSrcEl = null;
    var dragIndex;
    var dragOverIndex;
    var customPageJSON;

    // get parameter value from url

    /* jshint ignore:start */
    function getURLParameter(name) {
        return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;
    }
    /* jshint ignore:end */


    //将Unix时间戳转换为中文日期和星期
    function unixtochinese(thetime, datetype) {
        var todaystamp, dayArray, dayChar, thehour, theminute, ampm, currentDate, currentDateStamp, itemDateStamp;
        if (thetime === 'hide') {
            return '';
        }
        currentDate = new Date();
        currentDateStamp = currentDate.getFullYear() * 10000 + (currentDate.getMonth() + 1) * 100 + currentDate.getDate();
        thisday = new Date(thetime * 1000);
        itemDateStamp = thisday.getFullYear() * 10000 + (thisday.getMonth() + 1) * 100 + thisday.getDate();
        todaystamp = thisday.getFullYear() + '年' + (thisday.getMonth() + 1) + '月' + thisday.getDate() + '日 星期';
        dayArray = '日一二三四五六';
        dayChar = dayArray[thisday.getDay()];
        todaystamp += dayChar;
        thehour = thisday.getHours();
        thehour = ('0' + thehour).slice(-2);
        theminute = thisday.getMinutes();
        theminute = ('0' + theminute).slice(-2);
        ampm = (thehour < 12) ? 'AM' : 'PM';
        if (datetype === 1) {
            todaystamp = ' ' + thehour + ':' + theminute + ' ' + ampm;
        } else if (datetype === 2) {
            //console.log (currentDateStamp);
            //console.log (todaystamp);
            if (currentDateStamp === itemDateStamp) {
                todaystamp = thehour + ':' + theminute;
            } else {
                todaystamp = (thisday.getMonth() + 1) + '/' + thisday.getDate() + ' ' + thehour + ':' + theminute;
            }
        } else if (datetype === 3) {
            if (/^[0-9]{4}\-[0-9]{1,2}\-[0-9]{1,2}$/gi.test(thetime)) {
                //console.log (thetime);
                todaystamp = thetime.replace(/^[0-9]{4}\-([0-9]{1,2}\-[0-9]{1,2})$/g, '$1');
                todaystamp = todaystamp.replace(/^0/g, '').replace(/\-0/g, '/').replace('-', '/');
            } else {
                todaystamp = (thisday.getMonth() + 1) + '/' + thisday.getDate();
            }
        }
        return todaystamp;
    }

    function renderAPI(id, headline, timeStamp, timeStampType, longlead, shortlead, image, type, tag, customLink, relativestory, showRelativeStoryItems) {
        var editLink = '';
        var previewLink = '';
        var dataHTML = '';
        var oTimeStamp = timeStamp || Math.round(new Date().getTime()/1000);
        var relativestoryHTML = '';
        var hasImageClass = '';
        var imageBG = '';
        if (typeof showRelativeStoryItems !== 'undefined') {
            showRelativeStoryItems = '<div class="item-info-item"><div class="item-info-title">Show Related Items: </div><input type="number" title="How Many Related Content Would You Like to Show in This Page? " name="showRelativeStoryItems" class="o-input-text" value="' + showRelativeStoryItems + '"></div>';
        } else {
            showRelativeStoryItems = '';
        }
        if (type === 'story') {
            editLink = 'https://backyard.ftchinese.com/falcon.php/story/edit/' + id;
            previewLink = 'http://www7.ftchinese.com/story/' + id;
        } else if (type === 'interactive') {
            editLink = 'https://backyard.ftchinese.com/falcon.php/ia/edit/' + id;
            previewLink = 'http://www7.ftchinese.com/interactive/' + id;
        } else if (type === 'photo') {
            editLink = 'https://backyard.ftchinese.com/falcon.php/pics/edit_photonews/' + id;
            previewLink = 'http://www7.ftchinese.com/photonews/' + id;
        } else if (type === 'video') {
            editLink = 'https://backyard.ftchinese.com/create_videostory.php?id=' + id;
            previewLink = 'http://www7.ftchinese.com/video/' + id;
        }
        if (timeStamp !== '') {
            timeStamp = unixtochinese(timeStamp, timeStampType);
        } else {
            timeStamp = '<div class="new-item"></div>';
        }
{'fraction_non_alphanumeric': 0.1919904431423858, 'fraction_numerical': 0.01433528642129814, 'mean_word_length': 2.7104263402279445, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 8, 'lorem ipsum': 0, 'www.': 8, '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': '1747782', 'n_tokens_mistral': 6686, 'n_tokens_neox': 6553, 'n_words': 1119}