7.7 C
София
вторник, март 19, 2024

САМО в Новините Днес: Ето го кода за машините на вота (ЕКСКЛУЗИВНО)

ПРОЧЕТИ СЪЩО

Не бъди безразличен ! Сподели статията с твоите приятели

Кодът за машините на вота от последните избори на 2 октомври, който би трябвало да е достъпен само в Централната избирателна комисия (ЦИК), изпрати ексклузивно до редакцията източник на Новините Днес.

Това е доказателство, че ако някой е искал да повлияе на резултатите от вота, е имал нужната информация да го направи.

Повод да получим кода, който може да бъде проверен от специалистите в ЦИК, е вчерашният скандал, който заформиха бившите партньори от кабинета „Кирил Петков” – „Продължаваме промяната” и БСП.

От ПП отрекоха обвинението на червените, че Петков държи кодовете за машините на вота. То прозвуча от парламентарната трибуна, направи го зам.-председателят на ПГ на „БСП за България” Георги Свиленски.

Проверка по рама

На въпрос на водещия на „Панорама” по БНТ Бойко Василев дали Кирил Петков наистина е казал на БСП, че държи кодовете и ще им ги даде, ако оттеглят поправките за връщането на хартиената бюлетина, Андрей Гюров от „Промяната” се измъкна: „Аз не мога да кажа какво е казал”.

„Този код е наличен в ЦИК и всяка партия може да отиде и да се запознае, а притесненията на Свиленски също са несъстоятелни”, рече Гюров, докато през това време седми час продължаваха извънредно дългите дебати по промените в Изборния кодекс на второ четене.

Но същевременно изведе аргументи за това, че няма как от ПП и ДБ да са манипулирали резултатите, защото тогава нямаше да са на второ място едните, а другите – да са шеста по големина група.

„Възможно най-ясно и категорично – няма начин този код и резултатите да бъдат манипулирани. Той се контролира от ЦИК. Ако ние имахме достъп и го манипулирахме, дали щяхме да бъдем втора политическа сила?”, попита риторично Гюров. И добави, че дали ДБ, които имаха министър на електронното управление в лицето на Божидар Божанов, щяха да са едва шеста парламента група.

Сега Новините Днес предоставя кода на цяла България, за да е ясно, че инструмент за манипулиране на гласуването има, въпросът е дали е използван и ако да, от кого?

Ето какво пише предоставилият кода до Новините Днес:

Магазин за Акумулатори

Пращам изходния код на „Софтуер броене Информационно обслужване” за изборите за народни представители на 2 октомври:

<head>

      <style media=“screen“ type=“text/css“>
        select,
        textarea,
        input[type=“text“],
        input[type=“password“],
        input[type=“datetime“],
        input[type=“datetime-local“],
        input[type=“date“],
        input[type=“month“],
        input[type=“time“],
        input[type=“week“],
        input[type=“number“],
        input[type=“email“],
        input[type=“url“],
        input[type=“search“],
        input[type=“tel“],
        input[type=“color“],
        .uneditable-input {
            display: inline-block;
            height: 20px;
            padding: 1px 1px;
            margin-bottom: 2px;
            font-size: 10pt;
            line-height: 10px;
            color: #555555;
            vertical-align: middle;
            -webkit-border-radius: 2px;
            -moz-border-radius: 2px;
            border-radius: 2px;
            min-width: 60px
        }

        .table td {
            padding: 2px;
            line-height: 10px;
            text-align: left;
            vertical-align: top;
            border-top: 1px solid #dddddd;
        }

        .bolded {
            font-weight: bold;
        }

        .colorIndex3 {
            color: red
        }

        .colorIndex5 {
            color: blue
        }

        .firstRow {
            background: #D0D0D0;
            font-weight: bold;
            border: 1px solid black;
        }

        .firstCol {
            background: #D0D0D0;
            border: 1px solid black;
        }

        #finalTable .secondRow {
            background: #F0F0F0;
            font-weight: bold;
            border: 1px solid black;
        }

        #finalTable .lastCol {
            border: 1px solid black;
        }

        #table3p td {
            text-align: center;
            vertical-align: middle;
            min-width: 40px
        }

        #table3i td {
            text-align: center;
            vertical-align: middle;
            min-width: 40px
        }

        #table3 td {
            text-align: center;
            vertical-align: middle;
            min-width: 40px
        }

        #fracTable td {
            text-align: center;
            vertical-align: middle;
            min-width: 40px
        }

        #finalTable td {
            text-align: center;
            vertical-align: middle;
            min-width: 40px
        }

        #fracTable .lastCol {
            border: 1px solid black;
            min-width: 40px
        }

        #fracTable .secondRow {
            border: 1px solid black;
            font-weight: bold;
            background: #F0F0F0;
            min-width: 40px
        }

        #fracTable .underLastCol {
            border: 1px solid black;
        }

        #table3p .lastCol {
            border: 1px solid black;
        }

        #table3p .underLastCol {
            border: 1px solid black;
        }

        #table3i .lastCol {
            border: 1px solid black;
        }

        #table3i .underLastCol {
            border: 1px solid black;
        }

        #table3 .secondRow {
            border: 1px solid black;
            font-weight: bold;
            background: #F0F0F0;
        }

        #table3 .lastCol {
            border: 1px solid black;
        }

        #table3 .underLastCol {
            border: 1px solid black;
        }
    </style>
    <script>
        // Fix some compatibility issues
        if (typeof console === „undefined“) console = {};
        if (typeof console.log === „undefined“) console.log = function(n) {};
        if (typeof Array.prototype.push === „undefined“) {
            Array.prototype.push = function(n) {
                var i;
                if (n instanceof Array) {
                    for (i = 0; i < n.length; i++) this[this.length] = n[i];
                    return this;
                }
                this[this.length] = n;
                return this;
            };
        }
        if (typeof Array.prototype.forEach === „undefined“) {
            Array.prototype.forEach = function(n) {
                var i;
                for (i = 0; i < this.length; i++) n(this[i]);
            };
        }
        if (typeof Array.prototype.map === „undefined“) {
            Array.prototype.map = function(n) {
                var i;
                var a = [];
                for (i = 0; i < this.length; i++) a[a.length] = n(this[i]);
                return a;
            };
        }
        if (typeof Object.prototype.keys === „undefined“) {
            Object.prototype.keys = function(n) {
                var i;
                var a = [];
                for (i in n) {
                    a[a.length] = i;
                }
                return a;
            };
        }
        if (typeof document.getElementsByClassName === „undefined“) {
            document.getElementsByClassName = function(n) {
                var a = [];
                var cl = n.split(/ +/);
                var e = document.getElementsByTagName(‘*’);
                var i;
                var j;
                for (i = 0; i < e.length; i++) {
                    for (j = 0; j < cl.length; j++) {
                        if (RegExp(‘ ‘ + cl[j] + ‘ ‘).test(‘ ‘ + e[i].className + ‘ ‘)) {
                            a[a.length] = e[i];
                            break;
                        }
                    }
                }
                return a;
            };
        }

        // –-

        function BgElections2013codeV4() {
            // Translation from Visual Basic to JavaScript
            var InputData;
            var x;
            var y;
            var MIR;
            var Parties;
            var Total;
            var lowPerc = parseFloat(document.getElementById(„lowPerc“).value);

            MIR = parseInt(document.getElementById(„dim_mir“).value);
            Parties = parseInt(document.getElementById(„dim_party“).value);

            var p = readSpecs();
            console.log(p);
            filterLowPerc(p, lowPerc);
            Parties = p.party.length; // Remove all the parties with less than 4%
            console.log(p); // Lets dump what we have here

            // Now we have in P only the values of the parties to compute
            var i;
            var j;
            var mandates = [];
            var totMandates = []; // we shall see when we use the totMandates at all, as it looks like the globalMandates is more important
            // Distrubute the mandates
            for (i = 0; i < Parties; i++) {
                mandates[i] = [];
                for (j = 0; j < MIR; j++) {
                    mandates[i][j] = p.mir[j].mandates * p.party[i].partyVotes[j] / p.mir[j].reTotalSum; // Error, not global totalsum
                }
                totMandates[i] = sumArray(mandates[i]);
            }

            // Distribution of the seats between the parties on a national level, 1st step
            var globalMandates = [];
            for (i = 0; i < Parties; i++) globalMandates[i] = p.totalMandates * p.party[i].partySum / p.reTotalSum;

            // integer parts and fractions are separated in two new tables
            var intMandates = [];
            var intTotMandates = [];
            var fracMandates = [];
            var fracTotMandates = [];
            for (i = 0; i < Parties; i++) {
                intMandates[i] = [];
                fracMandates[i] = [];
                for (j = 0; j < MIR; j++) {
                    intMandates[i][j] = parseInt(mandates[i][j]);
                    fracMandates[i][j] = mandates[i][j] – intMandates[i][j];
                }
                intTotMandates[i] = parseInt(globalMandates[i]); // globalMandates instead of totMandates
                fracTotMandates[i] = globalMandates[i] – intTotMandates[i]; // globalMandates instead of totMandates
            }

            // Lets compute the non distributed seats
            // Here we compute the non-distributed seats by constituency (MIR)
            var undistSeats = [];
            for (j = 0; j < MIR; j++) {
                undistSeats[j] = p.mir[j].mandates – sumCol(intMandates, j);
            }
            var totUndMandates = p.totalMandates – sumArray(intTotMandates); //totalMandates is missing

            // Make some cells bold (used in the calculation later, those are the first X (undistributed) mandates in the column)
            var bolded = [];
            for (i = 0; i < Parties; i++) {
                bolded[i] = [];
                for (j = 0; j < MIR; j++) {
                    bolded[i][j] = 0;
                    var r = rankCol(fracMandates[i][j], fracMandates, j);
                    if (r <= undistSeats[j]) bolded[i][j] = 1;
                }
            }

            var totBolded = [];
            for (i = 0; i < Parties; i++) {
                totBolded[i] = 0;
                if (rank(fracTotMandates[i], fracTotMandates) <= totUndMandates) totBolded[i] = 1;
            }

            var winMandates = [];
            // Calculate number of seats per party STEP 1
            for (i = 0; i < Parties; i++) {
                winMandates[i] = parseInt(globalMandates[i]) + totBolded[i];
            } //globalMandates instead of totMandates

            // Lets calculate the difference between the direct mandates and the mandate redistribution
            // It is possible to have situation where we have removal of a mandate instead of adding one, which is wrong
            var parMandates = [];
            for (i = 0; i < Parties; i++) {
                parMandates[i] = winMandates[i] – sumArray(intMandates[i]);
                if (parMandates[i] < 0) {
                    alert(„Sorry, we have a problem in STEP2nwe can not distribute a negative number of seatsnPlease send a message to [email protected]
„);
                }
            }

            //
            var diffMandates = []; // Here we compute the excedence
            for (i = 0; i < Parties; i++) {
                diffMandates[i] = sumArray(bolded[i]) – parMandates[i];
            }

            // the table with the whole and the distributed mandates together
            var tab4Mandates = [];
            for (i = 0; i < Parties; i++) {
                tab4Mandates[i] = [];
                for (j = 0; j < MIR; j++) {
                    tab4Mandates[i][j] = bolded[i][j] + intMandates[i][j];
                }
            }

            var tab4giveMandates = [];
            var tab4wonMandates = [];
            for (i = 0; i < Parties; i++) {
                tab4giveMandates[i] = sumArray(tab4Mandates[i]);
                tab4wonMandates[i] = winMandates[i];
            }

            // Table 3
            var tab3sumMandates = [];
            for (i = 0; i < Parties; i++) {
                tab3sumMandates[i] = sumArray(intMandates[i]);
            }

            var tab3leftMandates = [];
            for (i = 0; i < Parties; i++) {
                tab3leftMandates[i] = winMandates[i] – tab3sumMandates[i];
            }

            // –– Mandate redistribution
            // From now on we work only on table 5 (fracMandates)

            // In the original code there is a duplication, so I am skipping it, diffMandates[i] contains the excedence already

            // The main calculation for the mandate redistribution
            var Timer;
            var finalTable = [];

            var boldCellPlus = [];
            //                var boldCellMinus = [];
            var Iplus;
            var Jplus;
            var Iminus;
            //                var Jminus;
            //                var K;
            var PlusCounter;
            var cellMinus = [];
            //                var c = [];
            var Min;

            var colorIndex = []; // We are moving the colorIndex outside
            // – Checked up to here
            for (Timer = 0; Timer < 200; Timer++) {
                PlusCounter = 0;
                boldCellPlus = [];
                for (i = 0; i < Parties; i++) {
                    if (diffMandates[i] > 0) PlusCounter++;
                }

                if (PlusCounter === 0) {
                    alert(„След “ + Timer + “ повторения имаме резултат!“);

                    for (i = 0; i < Parties; i++) {
                        finalTable[i] = [];
                        for (j = 0; j < MIR; j++) {
                            finalTable[i][j] = bolded[i][j] + intMandates[i][j];
                        }
                    }
                    // Decoration is not copied
                    // …..
                    break;
                }

                // Article 24
                var bBold = 0;
                for (i = 0; i < Parties; i++) {
                    if (typeof colorIndex[i] === ‘undefined’) colorIndex[i] = [];
                    boldCellPlus[i] = [];
                    for (j = 0; j < MIR; j++) {
                        boldCellPlus[i][j] = 0;
                        if (bolded[i][j] && diffMandates[i] > 0 && colorIndex[i][j] !== 3) {
                            boldCellPlus[i][j] = 1; // Union
                            bBold = 1;
                        }
                    }
                }
                if (!bBold) {
                    alert(„Внимание, настъпи проблем след “ + Timer + “ повторения в стъпка 3! Не може да се намери решение: Моля информирайте ЦИК на [email protected]
„);
                    break;
                }
                var res = crossTableMinMax(fracMandates, boldCellPlus, 0);
                Min = res.val;
                Iplus = res.row;
                Jplus = res.col;

                cellMinus = [];
                var bCell = 0;
                for (k = 0; k < Parties; k++) {
                    cellMinus[k] = [];
                    if (bolded[k][Jplus] === 0 && colorIndex[k][Jplus] !== 3) {
                        cellMinus[k][Jplus] = 1;
                        bCell = 1;
                    }
                }
                if (bCell) {
                    res = crossTableMinMax(fracMandates, cellMinus, 1);
                    Iminus = res.row;
                    // var counter = Jplus; //???
                    bolded[Iplus][Jplus] = 0;
                    bolded[Iminus][Jplus] = 1; // fixed typo
                    colorIndex[Iplus][Jplus] = 3;
                    colorIndex[Iminus][Jplus] = 5;
                    for (i = 0; i < Parties; i++) {
                        diffMandates[i] = sumArray(bolded[i]) – parMandates[i];
                    }
                } else {
                    for (i = 0; i < Parties; i++) colorIndex[i][Jplus] = 3; // red color according to art. 26
                }
            }

            console.log(finalTable);

            // Visualization need to happen here

            var visual = document.getElementById(„outResults“);

            var t = „“;

            // –––– Visualize Table of fractions
            var t3 = [];
            t3[0] = [„“].concat(p.mir.map(function(n) {
                return n.name
;
            })).concat([„Сборно“, „Спечелени“]);
            t3[1] = [„Мандати за:“].concat(p.mir.map(function(n) {
                return n.mandates;
            })).concat([p.totalMandates, p.totalMandates]);
            for (i = 0; i < mandates.length; i++) {
                t3.push([p.party[i].partyName]);
                for (j = 0; j < mandates[i].length; j++) t3[2 + i][1 + j] = mandates[i][j].toFixed(3);
            }
            for (i = 0; i < Parties; i++) {
                t3[2 + i][1 + MIR] = globalMandates[i].toFixed(3);
                t3[2 + i][2 + MIR] = winMandates[i];
            }
            t += „<div class=’Step2′><H2>Втора стъпка, спечелени мандати</H2></div>“ + buildTable(t3, ‘table3’);

            var t3i = [];
            t3i[0] = [„“].concat(p.mir.map(function(n) {
                return n.name
;
            })).concat([„Раздадени“, „Остават за раздаване“]);
            for (i = 0; i < intMandates.length; i++) {
                t3i.push([p.party[i].partyName].concat(intMandates[i]).concat([sumArray(intMandates[i]), winMandates[i] – sumArray(intMandates[i])]));
            }
            t += „<div class=’Step2i’><H2>Първоначални (цели) мандати</H2></div>“ + buildTable(t3i, ‘table3i’);

            var t3p = [];
            t3p[0] = [„“].concat(p.mir.map(function(n) {
                return n.name
;
            })).concat([„Раздадени“, „Спечелени“]);
            for (i = 0; i < intMandates.length; i++) {
                t3p.push([p.party[i].partyName].concat(tab4Mandates[i]).concat([tab4giveMandates[i], tab4wonMandates[i]]));
            }
            t += „<div class=’Step2p’><H2>Раздадени първоначални (цели) и допълнителни (дробни) мандати</H2></div>“ + buildTable(t3p, ‘table3p’);

            // –––– Visualize the Frac table, we need to add the colours here
            var t4 = [
                [„“].concat(p.mir.map(function(n) {
                    return n.name
;
                })).concat([„“, „“]), [„“]
            ];
            t4[1][1 + MIR] = „Остават“;
            t4[1][2 + MIR] = „“;
            for (i = 0; i < Parties; i++) {
                t4[i + 2] = [p.party[i].partyName];
                for (j = 0; j < MIR; j++) {
                    t4[i + 2][j + 1] = {
                        value: fracMandates[i][j].toFixed(3),
                        attr: []
                    };
                    if (bolded[i][j]) t4[i + 2][j + 1].attr.push(„bolded“);
                    try {
                        if (colorIndex[i][j]) t4[i + 2][j + 1].attr.push(„colorIndex“ + colorIndex[i][j]);
                    } catch (e) {};
                }
                t4[i + 2][MIR + 1] = sumArray(bolded[i]);
                t4[i + 2][MIR + 2] = diffMandates[i];
            }
            for (j = 0; j < MIR; j++) t4[1][1 + j] = sumCol(bolded, j);
            t += „<div class=’step3′><H2>Трета стъпка</H2></div>“ + buildTable(t4, ‘fracTable’) ;

            // –––– Visualize Table 5
            var t5 = [];
            t5[0] = [„“].concat(p.mir.map(function(n) {
                return n.name
;
            })).concat(„Сборно“);
            t5[1] = [„Мандати за:“];
            var sum = 0;
            for (i = 0; i < finalTable[0].length; i++) {
                t5[1][1 + i] = sumCol(finalTable, i);
                sum += t5[1][1 + i];
            }
            t5[1][i + 1] = sum;
            for (i = 0; i < finalTable.length; i++) {
                t5.push([p.party[i].partyName].concat(finalTable[i]).concat(sumArray(finalTable[i])));
            }
            t += „<div class=’finalTable’><H2>Окончателно разпределение на мандатите по партии и MИР</H2></div>“ + buildTable(t5, ‘finalTable’);
            // –––– End of Table 5

            visual.innerHTML = t;
        }

        function crossTableMinMax(t1, t2, max) {
            var i;
            var j;
            var val = ‘x’;
            var row;
            var col;

            for (i = 0; i < t2.length; i++) {
                for (j = 0; j < t2[i].length; j++) {
                    if (!t2[i][j]) continue;
                    if (val === ‘x’ || (max ? (val < t1[i][j]) : (val > t1[i][j]))) {
                        val = t1[i][j];
                        row = i;
                        col = j;
                    }
                }
            }

            return {
                val: val,
                row: row,
                col: col
            };
        }

        function rank(num, arr, order) { // Rank in row
            var i;
            var a = arr.slice(0); //copy array
            a.sort().reverse(); // Sort the array
            if (order) a.sort(); // Sort the array progresively
            i = a.indexOf(num);
            if (i >= 0) return i + 1;
            return arr.length + 1;
        }

        function rankCol(num, arr, col, order) { // Rank in col
            var i;
            var a = [];
            for (i = 0; i < arr.length; i++) a.push(arr[i][col]);
            return rank(num, a, order);
        }

        function sumArray(t) {
            var sum = 0;
            t.forEach(function(n) {
                sum += n;
            });
            return sum;
        }

        function sumRow(t, row) {
            return sumArray(t[row]);
        }

        function sumCol(t, col) {
            var sum = 0;
            var i;
            for (i = t.length – 1; i >= 0; i–) sum += t[i][col];
            return sum;
        }

        function buildTable(a, id) {
            var i, j;
            var t = „“;
            for (i = 0; i < a.length; i++) {
                var c = [];
                if (i === 0) c.push(„firstRow“);
                if (i === 1) c.push(„secondRow“);
                if (i === a.length – 1) c.push(„lastRow“);
                if (i === a.length – 2) c.push(„underLastRow“);
                c.push(„row“ + (i + 1));
                t += „<tr class=““ + c.join(“ „) + „“>“;
                for (j = 0; j < a[i].length; j++) {
                    var c2 = [];
                    if (j === 0) c2.push(„firstCol“);
                    if (j === 1) c2.push(„secondCol“);
                    if (j === a[i].length – 1) c2.push(„lastCol“);
                    if (j === a[i].length – 2) c2.push(„underLastCol“);
                    c2.push(„col“ + (j + 1));
                    var tt = „“;
                    if (typeof a[i][j] === ‘object’) {
                        if (a[i][j].attr) c2 = c2.concat(a[i][j].attr);
                        // Generate td with attributes and then add the value
                        tt = „<td class=““ + c.concat(c2).join(“ „) + „“>“ + a[i][j].value + „</td>“;
                    } else {
                        tt = „<td class=““ + c.concat(c2).join(“ „) + „“>“ + a[i][j] + „</td>“;
                    }
                    t += tt;
                };
                t += „</tr>n“;
            }
            return „<table class=“table“ “ + ((id) ? „id=’“ + id + „‘ “ : „“) + „>n“ + t + „</table>n“;
        }

        function filterLowPerc(p, perc) { // Will remove from array of objects p (output from readSpecs) everything under „perc“ percentage and will recalculate
            var i;
            for (i = p.party.length – 1; i >= 0; i–) {
                if (p.party[i].partyPerc < perc) p.party.splice(i, 1);
            }
            // Recalculate the total sum and the perc
            p.reTotalSum = 0;
            for (i = p.party.length – 1; i >= 0; i–) p.reTotalSum += p.party[i].partySum;
            for (i = p.party.length – 1; i >= 0; i–) p.party[i].rePartyPerc = 100 * p.party[i].partySum / p.reTotalSum;
            for (i = p.mir.length – 1; i >= 0; i–) {
                p.mir[i].reTotalSum = 0;
                p.party.forEach(function(n) {
                    p.mir[i].reTotalSum += n.partyVotes[i];
                });
            }
        }

        function readSpecs() { // Read the specs from the table into an array of objects for easy manipulation
            var tr = document.getElementsByClassName(„partyRow“);
            var i, j;
            var p = {
                party: [],
                mir: [],
                totalSum: 0,
                reTotalSum: 0,
                totalMandates: 0
            };
            var dim_mir = document.getElementById(„dim_mir“).value;
            var dim_party = document.getElementById(„dim_party“).value;
            for (i = 0; i < tr.length; i++) {
                var row = tr.item(i);
                var pp = [];
                var po = {
                    partyName: „“,
                    partySum: 0,
                    partyPerc: 0,
                    rePartyPerc: 0,
                    partyVotes: []
                };
                for (j = 0; j < dim_mir; j++) pp.push(parseInt(row.cells[1 + j].firstChild.value));
                po.partyVotes = pp;
                po.partyName = row.cells[0].firstChild.value; // get the name
                po.partySum = sumArray(pp);
                p.totalSum += po.partySum;
                p.party.push(po);
            }
            p.party.forEach(function(n) {
                n.partyPerc = 100 * n.partySum / (p.totalSum ? p.totalSum : 1);
                n.rePartyPerc = n.partyPerc;
            });
            var row = document.getElementsByClassName(„manHeader“).item(0);
            for (j = 0; j < dim_mir; j++) {
                p.mir[j] = {
                    mandates: parseInt(row.cells[1 + j].firstChild.value),
                    name: „“,
                    totalSum: 0,
                    reTotalSum: 0
                };
                p.party.forEach(function(n) {
                    p.mir[j].totalSum += n.partyVotes[j];
                });
                p.mir[j].reTotalSum = p.mir[j].totalSum;
                p.totalMandates += p.mir[j].mandates;
            }
            var row = document.getElementsByClassName(„inHeader“).item(0);
            for (j = 0; j < dim_mir; j++) p.mir[j].name = row.cells[1 + j].firstChild.value;
            p.reTotalSum = p.totalSum;
            return p;
        }

        function calcBgElections2013() {
            BgElections2013codeV4();
        }

        function sumRow(name, output) {
            var o = document.getElementById(output);
            var s = document.getElementsByClassName(name);
            var i, sum = 0;
            for (i = s.length – 1; i >= 0; i–) {
                if (s.item(i).tagName === „INPUT“) sum += parseInt(s.item(i).value);
                else
                    sum += parseInt(s.item(i).innerHTML);
            }
            o.innerHTML = sum;
        };

        function calcProc() {
            var total = document.getElementById(„totalSum“).innerHTML;
            var dim_party = document.getElementById(„dim_party“).value;
            var i;
            for (i = dim_party; i; i–) {
                var s = document.getElementById(„sumParty“ + i).innerHTML;
                var o = document.getElementById(„procParty“ + i);
                o.innerHTML = (100 * parseInt(s) / parseInt(total)).toFixed(3) + „%“;
            }
        }

        function genTable() {
            var visual = document.getElementById(„visual“);
            // Clear the data
            visual.innerHTML = „“;

            var dim_mir = parseInt(document.getElementById(„dim_mir“).value);
            var dim_party = parseInt(document.getElementById(„dim_party“).value);

            if (dim_mir < 1) return alert(„Некоректно количество МИР“);
            if (dim_party < 1) return alert(„Некоректно количество Партии“);

            // Generate the table
            var t = „“;
            var i;
            var j;

            // Table header
            t += „<tr class=’inHeader’><td>&nbsp;</td>“;
            for (i = 1; i <= dim_mir; i++) {
                t = t + „<td><input type=text size=6  class=“manName“ value=“МИР“ + i + „“></td>“;
            }

            t += „<td>Общо:</td><td>Проценти:</td></tr>n“;

            // Мандати за района
            t += „<tr class=’manHeader’><td>Мандати за района:</td>“;
            for (i = dim_mir; i; i–) {
                t = t + „<td><input type=text value=’0′ class=’mandate’ size=3 onChange=’sumRow(“mandate“,“sumMandates“)’></td>“;
            }
            t += „<td id=’sumMandates’>0</td><td>&nbsp;</td></tr>n“;

            // Партии
            for (j = 1; j <= dim_party; j++) {
                t += „<tr class=’partyRow’><td><input type=text size=10 class=’partyName’ value=’Партия “ + j + „‘></td>“;
                for (i = dim_mir; i; i–) {
                    t += „<td><input type=text size=3 value=’0′ class=’partyCol“ + i + “ partyRow“ + j + „‘ onChange=’sumRow(“partyRow“ + j + „“,“sumParty“ + j + „“); sumRow(“partyCol“ + i + „“,“sumPartyCol“ + i + „“); sumRow(“partyRowSums“,“totalSum“); calcProc();’></td>“;
                }
                t += „<td class=’partyRowSums’ id=’sumParty“ + j + „‘>0</td><td id=’procParty“ + j + „‘>0.000%</td></tr>n“;
            }

            // Sum footer
            t += „<tr class=’sumFooter’><td>&nbsp;</td>“;
            for (i = dim_mir; i; i–) {
                t += „<td id=’sumPartyCol“ + i + „‘>0</td>“;
            }
            t += „<td id=’totalSum’>0</td><td>100.000%</td></tr>n“;

            // Lets set the sumout

        }
</script>
</head>

Материалът САМО в Новините Днес: Ето го кода за машините на вота (ЕКСКЛУЗИВНО) е публикуван за пръв път на Новините Днес.

Народ

Новините Днес

Филми онлайн без реклами

ПРОЧЕТИ СЪЩО

ПОСЛЕДНИ НОВИНИ