MediaWiki:Scripting.js: Difference between revisions

From
Jump to navigation Jump to search
(transformed)
(transformed)
 
Line 749: Line 749:
         const query = `${document.location.origin}/Special:Ask/format%3Djson/offset%3D${this.offset}/limit%3D${this.batchSize}/link%3Dall/headers%3Dshow/searchlabel%3DJSON/class%3Dsortable-20wikitable-20smwtable/sort%3D/order%3Dasc/-5B-5BRight::${this.right || ENC_PLUS}-5D-5D/-3FProbable-20year/-3FRight/-3FSection/-3FQuestion-20heading/-3FBreakout/mainlabel%3D/unescape%3Dtrue`;
         const query = `${document.location.origin}/Special:Ask/format%3Djson/offset%3D${this.offset}/limit%3D${this.batchSize}/link%3Dall/headers%3Dshow/searchlabel%3DJSON/class%3Dsortable-20wikitable-20smwtable/sort%3D/order%3Dasc/-5B-5BRight::${this.right || ENC_PLUS}-5D-5D/-3FProbable-20year/-3FRight/-3FSection/-3FQuestion-20heading/-3FBreakout/mainlabel%3D/unescape%3Dtrue`;
         this.offset += this.batchSize;
         this.offset += this.batchSize;
         const response = await fetch(query);
         try {
        const data = await response.json();
            const response = await fetch(query);
        if (!data.results) {
            const data = await response.json();
            console.error(data);
            if (!data.results) {
            throw Error('no results');
                console.error(data);
                throw Error('no results');
            }
            this.renderTimeline(data.results);
            return Object.keys(data.results).length;
        }
        catch (e) {
            console.error(`failed to get timeline data for ${this.right}`, e);
            console.info(query);
            return 0;
         }
         }
        this.renderTimeline(data.results);
        return Object.keys(data.results).length;
     }
     }
     async renderTimeline(results) {
     async renderTimeline(results) {

Latest revision as of 13:52, 5 January 2023

/******/ (function() { // webpackBootstrap
/******/ 	"Using strict hack";
/******/ 	var __webpack_modules__ = ([
/* 0 */,
/* 1 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AddMissingBreakouts = void 0;
const countries_1 = __importDefault(__webpack_require__(2));
const lib_1 = __webpack_require__(3);
const philosophies_1 = __importDefault(__webpack_require__(5));
const taxonomy_1 = __webpack_require__(4);
class AddMissingBreakouts {
    constructor() {
        this.idCount = 0;
    }
    addElement({ loc, right, section, question, questionheading, missing }) {
        this.idCount++;
        const place = document.querySelector(`[data-loc="${loc}"]`);
        ;
        place.insertAdjacentHTML("beforeend", `<select id="breakout-select-${this.idCount}">${missing.map(s => `<option id="breakout-item-${this.idCount}">${s}</option>`)}</select><a class="label-loggedin" id="breakout-add-${this.idCount}"> ${lib_1.NEW}</a>`);
        document.getElementById(`breakout-add-${this.idCount}`).addEventListener('click', () => {
            const breakout = document.getElementById(`breakout-select-${this.idCount}`).value;
            const target = `Freedom_of_Religion/History/Country_sources/${breakout}`;
            document.location = `${document.location.origin}/Special:FormEdit/Right_section/${target}?reload=1&query string=` +
                `&Right_section[right]=${right}` +
                `&Right_section[section]=${section}` +
                `&Right_section[question]=${question}` +
                `&Right_section[questionHeading]=${encodeURIComponent(questionheading)}` +
                `&Right_section[pageLevel]=Breakout` +
                `&Right_section[breakout]=${breakout}`;
        });
    }
    add(breakouts) {
        Array.from(breakouts).forEach((el) => {
            const { loc, has, right, section, question, questionheading } = el.dataset;
            const present = Array.from(document.querySelectorAll(`[data-loc="${loc}"]`)).map(b => b.dataset.breakout);
            const si = has === taxonomy_1.COUNTRIES ? countries_1.default : philosophies_1.default;
            const missing = si.filter(s => !present.includes(s));
            this.addElement({ loc, right, section, question, questionheading, missing });
        });
    }
}
exports.AddMissingBreakouts = AddMissingBreakouts;


/***/ }),
/* 2 */
/***/ (function(__unused_webpack_module, exports) {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports["default"] = [
    "Afghanistan",
    "Albania",
    "Algeria",
    "Andorra",
    "Angola",
    "Antigua and Barbuda",
    "Argentina",
    "Armenia",
    "Australia",
    "Austria",
    "Azerbaijan",
    "The Bahamas",
    "Bahrain",
    "Bangladesh",
    "Barbados",
    "Belarus",
    "Belgium",
    "Belize",
    "Benin",
    "Bhutan",
    "Bolivia",
    "Bosnia and Herzegovina",
    "Botswana",
    "Brazil",
    "Brunei",
    "Bulgaria",
    "Burkina Faso",
    "Burundi",
    "Cambodia",
    "Cameroon",
    "Canada",
    "Cape Verde",
    "Central African Republic",
    "Chad",
    "Chile",
    "China",
    "Colombia",
    "Comoros",
    "Democratic Republic of the Congo",
    "Republic of the Congo",
    "Costa Rica",
    "Croatia",
    "Cuba",
    "Cyprus",
    "Czech Republic",
    "Denmark",
    "Djibouti",
    "Dominica",
    "Dominican Republic",
    "East Timor",
    "Ecuador",
    "Egypt",
    "El Salvador",
    "Equatorial Guinea",
    "Eritrea",
    "Estonia",
    "Eswatini",
    "Ethiopia",
    "Fiji",
    "Finland",
    "France",
    "Gabon",
    "The Gambia",
    "Georgia",
    "Germany",
    "Ghana",
    "Greece",
    "Grenada",
    "Guatemala",
    "Guinea",
    "Guinea-Bissau",
    "Guyana",
    "Haiti",
    "Honduras",
    "Hungary",
    "Iceland",
    "India",
    "Indonesia",
    "Iran",
    "Iraq",
    "Republic of Ireland",
    "Israel",
    "Italy",
    "Ivory Coast",
    "Jamaica",
    "Japan",
    "Jordan",
    "Kazakhstan",
    "Kenya",
    "Kiribati",
    "Kuwait",
    "Kyrgyzstan",
    "Laos",
    "Latvia",
    "Lebanon",
    "Lesotho",
    "Liberia",
    "Libya",
    "Liechtenstein",
    "Lithuania",
    "Luxembourg",
    "Madagascar",
    "Malawi",
    "Malaysia",
    "Maldives",
    "Mali",
    "Malta",
    "Marshall Islands",
    "Mauritania",
    "Mauritius",
    "Mexico",
    "Federated States of Micronesia",
    "Moldova",
    "Monaco",
    "Mongolia",
    "Montenegro",
    "Morocco",
    "Mozambique",
    "Myanmar",
    "Namibia",
    "Nauru",
    "Nepal",
    "Kingdom of the Netherlands",
    "New Zealand",
    "Nicaragua",
    "Niger",
    "Nigeria",
    "North Korea",
    "North Macedonia",
    "Norway",
    "Oman",
    "Pakistan",
    "Palau",
    "Panama",
    "Papua New Guinea",
    "Paraguay",
    "Peru",
    "Philippines",
    "Poland",
    "Portugal",
    "Qatar",
    "Romania",
    "Russia",
    "Rwanda",
    "Saint Kitts and Nevis",
    "Saint Lucia",
    "Saint Vincent and the Grenadines",
    "Samoa",
    "San Marino",
    "São Tomé and Príncipe",
    "Saudi Arabia",
    "Senegal",
    "Serbia",
    "Seychelles",
    "Sierra Leone",
    "Singapore",
    "Slovakia",
    "Slovenia",
    "Solomon Islands",
    "Somalia",
    "South Africa",
    "South Korea",
    "South Sudan",
    "Spain",
    "Sri Lanka",
    "Sudan",
    "Suriname",
    "Sweden",
    "Switzerland",
    "Syria",
    "Tajikistan",
    "Tanzania",
    "Thailand",
    "Togo",
    "Tonga",
    "Trinidad and Tobago",
    "Tunisia",
    "Turkey",
    "Turkmenistan",
    "Tuvalu",
    "Uganda",
    "Ukraine",
    "United Arab Emirates",
    "United Kingdom",
    "United States",
    "Uruguay",
    "Uzbekistan",
    "Vanuatu",
    "Venezuela",
    "Vietnam",
    "Yemen",
    "Zambia",
    "Zimbabwe"
].sort();


/***/ }),
/* 3 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getPageName = exports.getSectionProperties = exports.subcatted = exports.wikiHeading = exports.fixup = exports.findAllSectionHeadings = exports.verifyNoDuplicates = exports.findDuplicates = exports.findFromTaxonomy = exports.toTransform = exports.levelElements = exports.toDelete = exports.PHILOSOPHIES = exports.COUNTRIES = exports.NEW = exports.allTopics = void 0;
const taxonomy_1 = __webpack_require__(4);
exports.allTopics = Object.keys(taxonomy_1.Taxonomy.Right.subcats);
exports.NEW = '&#xFF0B; create';
exports.COUNTRIES = '&#x1F30D;';
exports.PHILOSOPHIES = '&#x1F4AD;';
exports.toDelete = ['Sunwater Institute Rights and Liberties Project', 'Musical Scales Why Change The Minor Scale', '/Getting Started'];
exports.levelElements = ['Page', 'Introduction', 'Section', 'Question', 'Breakout'];
exports.toTransform = ['Freedom of Religion', 'Freedom of Expression', 'Freedom of Association', 'Voting Rights and Suffrage', 'Freedom of the Press', 'Privacy Rights'];
/**
 * Finds the section from the taxonomy subcats, including the path
 *
 * @param name
 * @returns section data and path info
 */
const findFromTaxonomy = (name) => {
    let result;
    function fifi(taxo, taxoPath, segs, level) {
        if (result)
            return;
        for (const key in taxo.subcats) {
            const here = taxo.subcats[key];
            const cat = here[taxonomy_1.CATEGORY] || key;
            if (key === name) {
                const nest = [...taxoPath, key];
                const cats = [...segs, cat];
                result = {
                    nest,
                    pageLevel: level,
                    section: segs[0] || cat,
                    question: (cats.length > 1) ? cats[cats.length - 1] : undefined,
                    questionHeading: (nest.length > 1) ? nest[nest.length - 1] : undefined,
                    segs: cats,
                    has: here[taxonomy_1.HAS],
                    cat
                };
                break;
            }
            if (here.subcats) {
                fifi(here, [...taxoPath, key], [...segs, cat], level + 1);
            }
        }
    }
    ;
    fifi(taxonomy_1.Taxonomy.Right, [], [], 0);
    return result;
};
exports.findFromTaxonomy = findFromTaxonomy;
function findDuplicates(arr) {
    return arr.filter((item, index) => arr.indexOf(item) != index);
}
exports.findDuplicates = findDuplicates;
function verifyNoDuplicates() {
    const sectionsHeadings = findAllSectionHeadings();
    const s = sectionsHeadings.map(s => (0, exports.findFromTaxonomy)(s).cat);
    const dupes = findDuplicates(sectionsHeadings);
    if (dupes.length > 0) {
        throw Error(`Duplicate section names: ${dupes}`);
    }
}
exports.verifyNoDuplicates = verifyNoDuplicates;
function findAllSectionHeadings() {
    const fi = (taxo) => {
        return Object.keys(taxo).reduce((all, section) => {
            all = [...all, section];
            if (taxo[section].subcats) {
                all = [...all, ...fi(taxo[section].subcats)];
            }
            return all;
        }, []);
    };
    return fi(taxonomy_1.Taxonomy.Right.subcats);
}
exports.findAllSectionHeadings = findAllSectionHeadings;
function fixup(p) {
    return p?.replace(/BUILD IN COLLAPSE EXPAND TOGGLE/, '').replace(/What is the oldest written source that mentions this right\?/, "What is the oldest source in any country that mentions this right?").trim();
}
exports.fixup = fixup;
function wikiHeading(level, heading, editText = '') {
    // const h = new Array(level).fill('=').join('');
    // return `${h}${text}${h}`;
    const data = editText ? ` class="controls-loggedin"` : '';
    return `<h${level}${data}>${heading} ${editText}</h${level}>`;
}
exports.wikiHeading = wikiHeading;
function subcatted(headingName, from) {
    return {
        Right: {
            subcats: { [headingName]: from.Right.subcats[headingName] }
        }
    };
}
exports.subcatted = subcatted;
function getSectionProperties(loc, foundSection, info) {
    let properties = {
        right: foundSection.right,
        section: info.section,
        question: info.question,
        questionHeading: info.questionHeading,
        pageLevel: exports.levelElements[foundSection.pageLevel],
    };
    if (foundSection.breakout) {
        properties.breakout = foundSection.breakout;
    }
    return properties;
}
exports.getSectionProperties = getSectionProperties;
function getPageName(section, info) {
    return [section.right, ...(section.breakout ? [...info.segs, section.breakout] : info.segs)].join('/');
}
exports.getPageName = getPageName;


/***/ }),
/* 4 */
/***/ (function(__unused_webpack_module, exports) {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Taxonomy = exports.COUNTRY_SOURCES = exports.COUNTRY_FORCES = exports.COUNTRIES = exports.HAS = exports.CATEGORY = void 0;
exports.CATEGORY = '_cat';
exports.HAS = '_has';
exports.COUNTRIES = 'Countries';
exports.COUNTRY_FORCES = 'Country forces';
exports.COUNTRY_SOURCES = 'Country sources';
const COUNTRY_EXCEPTIONS = 'Country exceptions';
const PHILOSOPHIES = 'Philosophies';
const TRADITION_CONTRIBUTIONS = 'Tradition contributions';
exports.Taxonomy = {
    Breakouts: {
        subcats: {
            [exports.COUNTRIES]: {
                subcats: {
                    [exports.COUNTRY_FORCES]: {},
                    [exports.COUNTRY_SOURCES]: {},
                    [COUNTRY_EXCEPTIONS]: {}
                },
            },
            [PHILOSOPHIES]: {
                subcats: {
                    [TRADITION_CONTRIBUTIONS]: {}
                }
            },
        }
    },
    Right: {
        subcats: {
            // headings
            History: {
                // question
                subcats: {
                    "What is the oldest source in any country that mentions this right?": {
                        [exports.CATEGORY]: 'Source',
                    },
                    "What historical forces or events, if any, contributed to a widespread belief in its importance?": {
                        [exports.CATEGORY]: exports.COUNTRY_FORCES
                    },
                    "What is the oldest written source in this country that mentions this right?": {
                        // question with breakouts
                        [exports.CATEGORY]: exports.COUNTRY_SOURCES,
                        [exports.HAS]: exports.COUNTRIES
                    },
                    "Is the identification of this right associated with a particular era in history, political regime, or political leader?": {
                        [exports.CATEGORY]: 'Era',
                    },
                    "Is there another noteworthy written source from the past that mentions this right?": {
                        [exports.CATEGORY]: "Noteworthy written sources"
                    },
                    "What specific events or ideas contributed to its identification as a fundamental right?": {
                        [exports.CATEGORY]: "Contributions"
                    },
                    "When was it generally accepted as a fundamental, legally-protectable right?": {
                        [exports.CATEGORY]: 'Fundamentally accepted'
                    },
                }
            },
            "Legal Codification": {
                subcats: {
                    "Is this right enshrined in international and regional human rights treaties?": {
                        [exports.CATEGORY]: 'International',
                    },
                    "Is it contained in the US Constitution?": {
                        [exports.CATEGORY]: 'US',
                    },
                    "Has it been interpreted as being implicit in the US Constitution?": {
                        [exports.CATEGORY]: 'US implicit',
                    },
                    "Are there any exceptions in American law to this right?": {
                        [exports.CATEGORY]: 'US exceptions'
                    },
                    "Is this right protected in the Constitutions of most countries today?": {
                        [exports.CATEGORY]: 'Most countries'
                    }
                },
            },
            "Philosophical Origins": {
                subcats: {
                    "What have religious and philosophical traditions contributed to our understanding of this right?": {
                        [exports.CATEGORY]: TRADITION_CONTRIBUTIONS,
                        [exports.HAS]: PHILOSOPHIES
                    },
                    "What do the major legal theories (positive law, natural law, critical legal studies, etc.) say about this right?": {
                        [exports.CATEGORY]: 'Theories',
                    },
                    "Are there any philosophical or moral traditions that dispute the classification of this right as a fundamental right?": {
                        [exports.CATEGORY]: 'Traditions',
                    }
                },
            },
            "Culture and Politics": {
                subcats: {
                    "Is there general and widespread belief that this right is a fundamental right that should generally be protected (and that exceptions should be rare)?": {
                        [exports.CATEGORY]: "Fundamental and protected"
                    },
                    "Does public polling reveal insights about the right as experienced in different countries?": {
                        [exports.CATEGORY]: 'Polling',
                    },
                    "Is this right exercised in different ways depending on the political governance regime in place (democracy, autocracy, hybrid regime)?": {
                        [exports.CATEGORY]: 'Depends on governance'
                    },
                    "Is this right interpreted and exercised in different ways in different countries? Focus on particular countries in which the right is interpreted distinctively": {
                        [exports.CATEGORY]: "Country intepretation"
                    }
                }
            },
            "Conflicts with other Rights": {
                subcats: {
                    "Are there other specific rights that are critical to the exercise of this right?  Can you identify specific examples of this?": {
                        [exports.CATEGORY]: 'Dependants',
                    },
                    "How does federalism change, if at all, the exercise or application of this right? What examples of this can one point to?": {
                        [exports.CATEGORY]: 'Federalism',
                    },
                    "What specific examples of hierarchies, manifestos, constitutions, or prioritized descriptions of rights cite this right’s high status? Low status? No status at all?": {
                        [exports.CATEGORY]: 'Status'
                    },
                    "Is there a perception that this right is above or higher than other fundamental rights, or in general, that it has a particular place in a hierarchy of rights?": {
                        [exports.CATEGORY]: 'Position'
                    },
                    "Are there other specific fundamental rights that tend to conflict with this right? Can you identify specific examples of this?": {
                        [exports.CATEGORY]: 'Other fundamental'
                    },
                }
            },
            "Limitations / Restrictions": {
                [exports.CATEGORY]: 'Limitations - Restrictions',
                subcats: {
                    "Is this right subject to specific limitations in event of emergency (war, brief natural disaster [weather, earthquake], long-run natural disaster [volcano, fire, disease])? Can such limitations be defined in advance with reference to the disaster in question?": {
                        [exports.CATEGORY]: 'Specific limitations',
                    },
                    "Under American jurisprudence, what permissible exceptions exist?": {
                        [exports.CATEGORY]: 'Jurisprudence'
                    },
                    "What are the typical exceptions or limitations placed on this right?": {
                        [exports.CATEGORY]: COUNTRY_EXCEPTIONS
                    },
                    "Under international human rights laws, what permissible exceptions (often called derogations) exist?": {
                        [exports.CATEGORY]: "Derogations"
                    },
                    "Have political theorists or philosophers discussed the permissibility of exceptions to this right?": {
                        [exports.CATEGORY]: "Permissibility"
                    },
                    "Should this right be limited when limiting it would jeopardize democratic norms?": {
                        [exports.CATEGORY]: "Democratic limit"
                    },
                    "Is this right often perceived as threatening to government authorities?": {
                        [exports.CATEGORY]: "Threatening to government"
                    },
                    "Is this right often curtailed by government authorities for reasons other than those which are generally viewed as permissible?": {
                        [exports.CATEGORY]: "Government curtailment"
                    },
                    "Is this right at times curtailed by private actors?": {
                        [exports.CATEGORY]: "Private curtailment"
                    }
                }
            },
            "Utilitarian / Fairness Assessments": {
                [exports.CATEGORY]: "Utilitarian - Fairness",
                subcats: {
                    'Is there a cost attached to protecting and enforcing this right? What kinds of costs are implicated?': {
                        [exports.CATEGORY]: 'Cost',
                        subcats: {
                            'Short-term economic cost in general': {
                                [exports.CATEGORY]: 'Short-term cost'
                            },
                            'Long-term economic cost in general': {
                                [exports.CATEGORY]: 'Long-term cost'
                            },
                            'Cost to those least able to economically absorb the cost': {
                                [exports.CATEGORY]: 'Cost to least able'
                            },
                            'Cost to perceived democratic legitimacy': {
                                [exports.CATEGORY]: 'Cost democracy'
                            },
                            'Cost to consistency or coherence of the law as a whole': {
                                [exports.CATEGORY]: 'Cost consistency'
                            },
                            'Cost to the legitimacy or effectiveness of other rights': {
                                [exports.CATEGORY]: 'Cost legitimacy'
                            },
                            'Cost to considerations of social equality': {
                                [exports.CATEGORY]: 'Cost equity'
                            },
                            'Cost to other non-material goods not so far specified': {
                                [exports.CATEGORY]: 'Other non-material costs'
                            },
                        }
                    },
                    'What are the financial consequences, if any, of making this right a legally protectable right?': {
                        [exports.CATEGORY]: "Financial Consequences"
                    },
                    'Are there any groups that are uniquely disadvantaged by the exercise of this right?': {
                        [exports.CATEGORY]: 'Disadvantaged'
                    },
                    'Are there any groups that uniquely benefit from the exercise of this right?': {
                        [exports.CATEGORY]: 'Beneficiaries'
                    },
                    'Are there instances when this fundamental right can lead to unfairness or inequities?': {
                        [exports.CATEGORY]: 'Unfairness'
                    },
                    'Are there objective ways to measure the utilitarian nature of this right?': {
                        [exports.CATEGORY]: 'Measure'
                    },
                    "If so, where can one draw the line: when does this right stop being useful or economically viable?": {
                        [exports.CATEGORY]: 'Limit',
                        "Cost to other non-material goods not so far specified": {
                            [exports.CATEGORY]: 'Other non-material costs'
                        }
                    }
                }
            },
            "Looking Ahead": {
                subcats: {
                    "Are questions of fairness and utility pertaining to this right likely to change in the years ahead?": {
                        [exports.CATEGORY]: 'Fairness and utility change'
                    },
                    "How can we expect this right to change and evolve in the years ahead?": {
                        [exports.CATEGORY]: 'Expected change'
                    },
                    "What are the most important questions that remain to be answered about this right?": {
                        [exports.CATEGORY]: 'Questions'
                    },
                    "How is the future likely to shape the exercise of this right?": {
                        [exports.CATEGORY]: 'Future'
                    },
                    "Will the exercise or protection of this right be affected by technological changes?": {
                        [exports.CATEGORY]: 'Technological change'
                    },
                    "Under what conditions would this right become irrelevant?": {
                        [exports.CATEGORY]: 'Irrelevence'
                    }
                },
            },
            "Policy Recommendations": {
                subcats: {
                    "If this right were eliminated, what might be the consequences (positive and negative)?": {
                        [exports.CATEGORY]: 'Eliminated',
                    },
                    "Can the practice or exercise of this right be shaped through executive action?": {
                        [exports.CATEGORY]: 'Executive action'
                    },
                    "In the US context, are there particular parties with a stake or interest in amending or reconceptualizing this right?": {
                        [exports.CATEGORY]: 'US party stakes'
                    },
                    "In the US context, can this right be altered legislatively, or would it require a constitutional amendment?": {
                        [exports.CATEGORY]: 'US alterations'
                    },
                    "Is this right best addressed at the national level? The sub-national level? The international level?": {
                        [exports.CATEGORY]: 'Level of address'
                    },
                    "To what extent is this right shaped primarily by judicial decisions?": {
                        [exports.CATEGORY]: 'Shaped by judicial decisions'
                    },
                    "If this right is best addressed through the amendment process, how should it proceed?": {
                        [exports.CATEGORY]: 'Amendment process'
                    },
                    "If this right were unlimited, what might be the consequences (positive and negative)?": {
                        [exports.CATEGORY]: 'Unlimited consequences'
                    },
                }
            }
        }
    }
};


/***/ }),
/* 5 */
/***/ (function(__unused_webpack_module, exports) {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports["default"] = ["Buddhism", "Platonism", "Aristotelian thought", "Ancient Chinese Philosophy", "Stoicism", "Early Indian Philosophy", "Miscellaneous Hellenistic Schools (epicureans, academics, skeptics, etc.)", "Roman Legal and Political Thought", "Early Christianity", "Thomism and medieval Christianity", "Medieval Islamic Thought", "Medieval Judaism", "Early Modern Rationalism", "Absolute Idealism", "Reformation Christianity", "Hobbesian Thought", "Lockean Thought/English Empiricism", "Physiocrats", "Scottish Enlightenment", "Modern Capitalism", "Rousseau's Thought", "Kantianism", "German Idealism", "Benthamite Utilitarianism", "Millian Utilitarianism", "Current Utilitarianism", "Transcendentalism", "Marxism", "Early Sociology", "Pragmatism", "Weberian Thought", "Process Philosophy", "Social Darwinism", "British Idealism (19th cen.)", "Continental Philosophy/Frankfurt School", "Behaviorism", "Feminist Thought", "Postmodernism"].sort();


/***/ }),
/* 6 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RightTimeline = exports.loadScript = void 0;
const lib_1 = __webpack_require__(3);
const ENC_PLUS = encodeURIComponent('+');
async function loadScript(url) {
    const response = await fetch(url);
    if (!response.ok) {
        console.error('not ok', url, console.error(response));
        throw Error(url);
    }
    const script = await response.text();
    eval(script);
}
exports.loadScript = loadScript;
class RightTimeline {
    constructor(right, containerId) {
        this.containerId = containerId;
        this.offset = 0;
        this.batchSize = 200;
        this.id = 0;
        this.pageIds = {};
        this.right = encodeURIComponent(right);
    }
    async go() {
        const container = document.getElementById(this.containerId);
        const loading = document.getElementById('loading');
        loading.innerHTML = '<div><span class="dot-elastic"> </span><span class="loading-text">The timelime is loading. The interface may be slow until it completes.</span></div>';
        await loadScript('https://visjs.github.io/vis-timeline/standalone/umd/vis-timeline-graph2d.min.js');
        const min = new Date('December 1, 500');
        const max = new Date('Dec 31, 2040');
        const start = new Date('December 1, 1850');
        const end = new Date('Dec 31, 1980');
        const options = {
            height: '500px',
            verticalScroll: true,
            max,
            min,
            stack: true,
            start,
            end,
            showTooltips: true,
            tooltip: {
                overflowMethod: 'cap',
                template: (item) => {
                    const { breakout, right, section, years, questionHeading } = this.pageIds[item.id];
                    const showYears = years.map(y => '<strong>' + y + '</strong>').join(', ');
                    return `
<div class="timeline-tooltip">
<h2>${right}</h2>
<h3>${questionHeading ? (questionHeading + ' in ') : ''}${section}</h3>
${breakout ? '<strong>' + breakout + '</strong>' : ''}
<p>Years: ${showYears}</p>
</div>`;
                }
            },
            editable: false,
            margin: {
                item: 10,
                axis: 5 // minimal margin between items and the axis
            },
            orientation: 'top'
        };
        const vis = window.vis;
        this.groups = new vis.DataSet(lib_1.toTransform.map((content, id) => ({ id, content })));
        this.timeline = new vis.Timeline(container, null, options);
        if (!this.right) {
            this.timeline.setGroups(this.groups);
        }
        this.items = new vis.DataSet();
        function selectPage(properties) {
            const loc = this.pageIds[properties.items[0]];
            if (loc?.pageName) {
                document.location = `/${loc.pageName}`;
                return false;
            }
        }
        this.timeline.on('select', selectPage.bind(this));
        let res = this.batchSize;
        while (res === this.batchSize) {
            const nextBatch = () => new Promise((resolve, reject) => setTimeout(async () => {
                const r = await this.getBatch();
                resolve(r);
            }, 500));
            res = await nextBatch();
        }
        loading.innerHTML = '';
    }
    async getBatch() {
        const query = `${document.location.origin}/Special:Ask/format%3Djson/offset%3D${this.offset}/limit%3D${this.batchSize}/link%3Dall/headers%3Dshow/searchlabel%3DJSON/class%3Dsortable-20wikitable-20smwtable/sort%3D/order%3Dasc/-5B-5BRight::${this.right || ENC_PLUS}-5D-5D/-3FProbable-20year/-3FRight/-3FSection/-3FQuestion-20heading/-3FBreakout/mainlabel%3D/unescape%3Dtrue`;
        this.offset += this.batchSize;
        try {
            const response = await fetch(query);
            const data = await response.json();
            if (!data.results) {
                console.error(data);
                throw Error('no results');
            }
            this.renderTimeline(data.results);
            return Object.keys(data.results).length;
        }
        catch (e) {
            console.error(`failed to get timeline data for ${this.right}`, e);
            console.info(query);
            return 0;
        }
    }
    async renderTimeline(results) {
        Object.keys(results).forEach((pageName) => {
            const { Breakout: ibreakout, Right: right, Section: isection, 'Probable year': years, 'Question heading': iquestionHeading } = results[pageName].printouts;
            const breakout = ibreakout[0]?.fulltext;
            const section = isection[0].fulltext;
            const questionHeading = iquestionHeading[0];
            const shortHeading = (0, lib_1.findFromTaxonomy)(questionHeading)?.cat || questionHeading;
            if (!shortHeading) {
                console.error('missing shortHeading', pageName, results[pageName].printouts);
            }
            const group = lib_1.toTransform.indexOf(right[0].fulltext);
            const content = breakout ? `${breakout} in ${shortHeading}` : shortHeading;
            for (const y of years) {
                const a = {
                    id: this.id,
                    group,
                    start: new Date(y.timestamp * 1000),
                    content
                };
                this.items.add(a);
                this.pageIds[this.id] = {
                    pageName,
                    breakout,
                    right: right[0]?.fulltext,
                    section,
                    years: years.map(y => new Date(y.timestamp * 1000).getFullYear()),
                    questionHeading,
                    content: content?.fulltext
                };
                this.id++;
            }
        });
        this.timeline.setItems(this.items);
    }
}
exports.RightTimeline = RightTimeline;


/***/ })
/******/ 	]);
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
!function() {
var exports = __webpack_exports__;

Object.defineProperty(exports, "__esModule", ({ value: true }));
const breakout_1 = __webpack_require__(1);
const RightTimeline_1 = __webpack_require__(6);
const timelineId = '#timeline';
const timeline = document.querySelector(timelineId);
if (!!timeline) {
    const { right } = timeline.dataset;
    doTimeline(right);
}
function doTimeline(right) {
    const rightTimeline = new RightTimeline_1.RightTimeline(right, 'timeline');
    rightTimeline.go();
}
const breakouts = document.getElementsByClassName('for-missing');
if (breakouts) {
    new breakout_1.AddMissingBreakouts().add(breakouts);
}
Array.from(document.querySelectorAll('.back-to-right > a')).forEach(a => {
    const [u, h] = a.getAttribute('href').split('#');
    a.setAttribute('href', `${u}?action=purge#${h}`);
});
if (document.location.search === '?action=purge') {
    setTimeout(() => Array.from(document.getElementsByClassName('mw-htmlform-ooui-wrapper'))[0].style = 'display: block', 2000);
    const b = document.querySelector('#ooui-php-4 > button');
    b.click();
}
Array.from(document.querySelectorAll('.back-to-right > a')).forEach(a => {
    const [u, h] = a.getAttribute('href').split('#');
    const n = `${u}?action=purge#${h}`.replace('?action=purge?action=purge', '?action=purge');
    console.log('n', h, n, '\no', n.indexOf('?action=purge?action=purge'));
    if (h.indexOf('action=purge') < 0) {
        a.setAttribute('href', n);
    }
});

}();
/******/ })()
;