Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.getScript("https://cdn.jsdelivr.net/npm/[email protected]/lib/jquery.tabletojson.min.js", function () {
- function download(data, filename, type) {
- var file = new Blob([data], {
- type: type
- });
- if (window.navigator.msSaveOrOpenBlob) // IE10+
- window.navigator.msSaveOrOpenBlob(file, filename);
- else { // Others
- var a = document.createElement("a"),
- url = URL.createObjectURL(file);
- a.href = url;
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- setTimeout(function () {
- document.body.removeChild(a);
- window.URL.revokeObjectURL(url);
- }, 0);
- }
- }
- function sortMarkets(array) {
- return array.sort(function (a, b) {
- var la = a["language"];
- var lb = b["language"];
- var ca = a["country"];
- var cb = b["country"];
- if (la < lb) return -1;
- if (la > lb) return 1;
- if (ca < cb) return -1;
- if (ca > cb) return 1;
- return 0;
- });
- }
- $('th div').each(function () {
- var el = $(this).find("p:first");
- var text = el.text();
- if (!text.endsWith(" - ")) {
- el.text(text + " - ");
- }
- });
- var table = $('#MercedesMeintegrationstatus-CMScontentsetup').nextAll('div').find('table').tableToJSON({
- extractor: function (cellIndex, $cell) {
- var cls = $cell.attr('class');
- if (cls.includes("highlight") && cls.includes("green")) {
- return "YES";
- } else if (cls.includes("highlight")) {
- return "NO";
- }
- return $cell.text();
- }
- });
- var spas = {};
- $.each(table, function (i, row) {
- for (key in row) {
- var region = row["RD-Region"];
- var country = row["Country"];
- var language = row["Language"];
- if (key != "Nr" && key != "Domain" && key != "RD-Region" && key != "Country" && key != "Language") {
- if (!(key in spas)) {
- spas[key] = {
- region: region,
- markets: []
- };
- }
- if (row[key] === "YES") {
- if (language.indexOf(",") > -1) {
- var langs = language.split(",");
- for (var indice = 0; indice < langs.length; indice++) {
- spas[key].markets.push({
- "language": langs[indice].trim(),
- "country": country,
- "market": "DACH"
- });
- }
- } else {
- spas[key].markets.push({
- "language": language,
- "country": country,
- "market": "DACH"
- });
- }
- }
- }
- }
- });
- var manifests = {};
- for (var spa in spas) {
- var current = spas[spa];
- var markets = sortMarkets(current.markets);
- manifests[spa] = markets;
- }
- download(JSON.stringify(manifests, null, 2), 'manifests.txt', 'text/plain');
- });
Advertisement
Add Comment
Please, Sign In to add comment