PageSourceSearch

https://rums.ac.ir/assets/js/esprit.poll.js

js rums.ac.ir collected 2026-10-02 06:10:21 UTC 14,248 bytes, 430 lines download raw bytes

1//Build Number : 1009904232103
2const currentLang = document.documentElement.lang.toUpperCase();
3const PollTranslate = {
4  "FA": { "btn": "ثبت نظر" },
5  "EN": { "btn": "Submit Vote" },
6  "AR": { "btn": "إرسال التصويت" },
7  "FR": { "btn": "Soumettre le vote" },
8  "Zh": { "btn": "提交投票" },
9  "RU": { "btn": "Отправить голос" },
10  "Ur": { "btn": "ووٹ جمع کروائیں" },
11  "El": { "btn": "Υποβολή ψήφου" },
12  "Es": { "btn": "Enviar voto" },
13  "Tr": { "btn": "Oyu Gönder" },
14  "Hy": { "btn": "Քվեարկել" },
15  "Bn": { "btn": "ভোট জমা দিন" },
16  "Az": { "btn": "Səsi göndər" },
17  "Tu": { "btn": "Ses beriň" },
18  "It": { "btn": "Invia voto" },
19  "De": { "btn": "Abstimmung senden" },
20  "Th": { "btn": "ส่งคะแนนโหวต" },
21  "Sr": { "btn": "Pošalji glas" },
22  "Uz": { "btn": "Ovoz berish" },
23  "Sq": { "btn": "Dërgo votën" },
24  "Hi": { "btn": "मत भेजें" },
25  "Tg": { "btn": "Фиристодани овоз" },
26  "bg": { "btn": "Изпрати глас" },
27  "NO": { "btn": "Send stemme" },
28  "DK": { "btn": "Indsend stemme" },
29  "PT": { "btn": "Enviar voto" },
30  "NL": { "btn": "Stem versturen" },
31  "HR": { "btn": "Pošalji glas" },
32  "KY": { "btn": "Добуш берүү" },
33  "KK": { "btn": "Дауыс беру" },
34  "SV": { "btn": "Skicka röst" },
35  "JA": { "btn": "投票を送信" },
36  "SR": { "btn": "Pošalji glas" },
37  "GE": { "btn": "ხმის გაგზავნა" },
38  "ID": { "btn": "Kirim suara" },
39  "MY": { "btn": "Hantar undi" },
40  "LK": { "btn": "ඡන්දය යවන්න" },
41  "TZ": { "btn": "Tuma kura" },
42  "ET": { "btn": "ድምጹን አስገባ" }
43};
44
45function initMultiPoll(pollDataArray) {
46  $(document).ready(function () {
47
48
49    decodedData = [];
50    const template =
51      '  <div class=" poll-item item" data-id="{id}" data-index="{index}"> \
52        <div class="es-row title-row">\
53            <h3 class="es-col-12 title">{title}</h3>\
54        </div>\
55        <div class="es-row">\
56            <div class="es-col-12 answers">{answers}</div>\
57        </div>\
58        <div class="es-row">\
59            <div class="es-col-12">\
60                <button class="es-btn es-btn-primary submitQuestion es-btn-block es-col-6 es-mx-auto">{submit}</button>\
61            </div>\
62        </div>\
63    </div>';
64    let out = '';
65    pollDataArray.forEach(function (pollData, index) {
66      const pollDataDecode = {
67        "title": Base64.decode(pollData.title.toString().replace("B64:", "")),
68        "answers": JSON.parse(Base64.decode(pollData.answers.toString().replace("B64:", ""))),
69        "id": pollData.id
70      };
71      if (pollData.result) pollDataDecode["result"] = pollData.result;
72      decodedData.push(pollDataDecode);
73
74
75
76      let temp = template
77        .replace(/\{title\}/gi, pollDataDecode.title)
78        .replace(/\{id\}/gi, pollDataDecode.id)
79        .replace(/\{index\}/gi, index)
80        ;
81      let answers = "";
82      pollDataDecode.answers.map(function (answerItem, index2) {
83        answers +=
84          '<div class="radio"> <label> <input name="vote_' + index + '" value="' +
85          answerItem.value + '" type="radio" /> ' +
86          answerItem.answer + '</label> </div>';
87      });
88
89      temp = temp.replace(/\{answers\}/gi, answers);
90
91      temp = temp.replace(/\{submit\}/gi, "ثبت پاسخ");
92      out += temp;
93    })
94    console.log($("#pollContent"), out)
95    $("#pollContent").html(out);
96    $("#pollContent").addClass("owl-carousel  owl-theme");
97    $("#pollContent .poll-item").each(function () {
98
99      var pollDataDecode = decodedData[$(this).data("index")];
100      console.log(pollDataDecode)
101      if (pollDataDecode.result) {
102        pollDataDecode["result"] = pollDataDecode.result;
103        showPollResult(pollDataDecode, $(this));
104        return;
105      }
106    })
107
108    var pollOwlCarousel = $("#pollContent").owlCarousel({
109      loop: false,
110      margin: 10,
111      dots: true,
112      nav: false,
113      /* touchDrag:false,
114       mouseDrag:false,
115       touchDrag:false,
116       pullDrag:false, */
117      rtl: true,
118      responsive: {
119        0: {
120          items: 1
121        },
122        600: {
123          items: 1
124        },
125        1000: {
126          items: 1
127        }
128      }
129    })
130    $(".submitQuestion").on("click", function () {
131      let _this = this, $elem = $(this).closest('.poll-item');
132      if (typeof $elem.find("input[type='radio']:checked").val() == "undefined") {
133        alert("یک مورد را انتخاب کنید ");
134        return
135      }
136      $.ajax({
137        url: "/inc/ajax.ashx",
138        type: "POST",
139        data: {
140          "id": $elem.data("id"),
141          "action": "submit_vote",
142          "value": $elem.find("input[type='radio']:checked").val()
143        },
144        dataType: "json",
145        beforeSend: function () {
146          $elem.find("input,button").attr("disabled", true);
147          $(_this).html('صبر کنید...');
148        },
149        success: function (res) {
150
151          if (res.status == "success") {
152            console.log(decodedData, $elem.data("index"))
153            var pollDataDecode = decodedData[$elem.data("index")];
154            $.extend(pollDataDecode, { "result": res.result });
155
156            showPollResult(pollDataDecode, $elem);
157            setTimeout(function () {
158              pollOwlCarousel.trigger('next.owl.carousel');
159            }, 1000);
160
161          }
162
163
164        },
165        error: function () {
166          $("#submitpoll").attr("disabled", false);
167          $(".poll-loader").remove();
168        }
169      })
170    })
171  })
172}
173function initPoll(pollData) {
174  $(document).ready(function () {
175
176
177    const pollDataDecode = {
178      "title": Base64.decode(pollData.title.toString().replace("B64:", "")),
179      "answers": JSON.parse(Base64.decode(pollData.answers.toString().replace("B64:", ""))),
180      "id": pollData.id
181    },
182      template =
183        '    <div class="es-row title-row">\
184        <h3 class="es-col-12 title">{title}</h3>\
185    </div>\
186    <div class="es-row">\
187        <div class="es-col-12 answers">{answers}</div>\
188    </div>\
189    <div class="es-row">\
190        <div class="es-col-12">\
191            <button class="es-btn es-btn-primary" name="submitpoll" type="submit">{submit}</button>\
192        </div>\
193    </div> ', pollElement = "#pollContent-" + pollDataDecode.id;
194    if (pollData.result) {
195      pollDataDecode["result"] = pollData.result;
196
197      showPollResult(pollDataDecode, $(pollElement));
198      return;
199    }
200    var out = template.replace(/\{title\}/gi, pollDataDecode.title);
201    var answers = "";
202    pollDataDecode.answers.map(function (answerItem) {
203      answers +=
204        '<div class="radio"> <label> <input name="vote" value="' +
205        answerItem.value + '" type="radio" /> ' +
206        answerItem.answer + '</label> </div>';
207    });
208
209    out = out.replace(/\{answers\}/gi, answers);
210    out = out.replace(/\{submit\}/gi, PollTranslate[currentLang]?.btn || "ثبت نظر");
211    $(pollElement).html(out);
212
213    $(pollElement + " [name='submitpoll']").on("click", function () {
214      var _this = this;
215      if (typeof $("input[name='vote']:checked").val() == "undefined") {
216        alert("یک مورد را انتخاب کنید ");
217        return
218      }
219      $.ajax({
220        url: "/inc/ajax.ashx",
221        type: "POST",
222        data: {
223          "id": pollDataDecode.id,
224          "action": "submit_vote",
225          "value": $("input[name='vote']:checked").val()
226        },
227        dataType: "json",
228        beforeSend: function () {
229          $(_this).attr("disabled", true);
230          $(pollElement).append('<div class="poll-loader">لطفا صبر کنید...</div>');
231        },
232        success: function (res) {
233          $(_this).attr("disabled", false);
234          $(".poll-loader").remove();
235          if (res.status == "success") {
236            $.extend(pollDataDecode, { "result": res.result });
237            console.log(pollDataDecode)
238            showPollResult(pollDataDecode, $(pollElement));
239          }
240
241
242        },
243        error: function () {
244          $(_this).attr("disabled", false);
245          $(".poll-loader").remove();
246        }
247      })
248    })
249  })
250}
251
252function showPollResult(pollData, $elemResult) {
253  const template =
254    '      <div class="es-row">\
255          <h3 class="es-col-12 title">{title}</h3>\
256      </div>\
257      <div class="es-row">\
258          <div class="es-col-12 answers">{results}</div>\
259      </div>' ;
260
261  var out = template.replace(/\{title\}/gi, pollData.title);
262  var results = "", totalPoint = 0;
263
264  pollData.answers.map(function (answerItem, index) {
265    var resultItem = $.getPWK(pollData.result, "value", answerItem.value, "*");
266
267    if (!resultItem) {
268      answerItem["count"] = 0;
269      answerItem["value"] = CHDB64(answerItem.value);
270      answerItem["answer"] = CHDB64(answerItem.answer);
271    }
272    else {
273      answerItem["count"] = Number(CHDB64(resultItem.count));
274      totalPoint += Number(CHDB64(resultItem.count));
275    }
276
277  });
278
279  pollData.answers.map(function (answerItem, index) {
280    var percent = Math.round(answerItem.count * 100 / totalPoint);
281    results +=
282      '<div class="result es-row"> ' +
283      '<div class="es-col-12">  ' +
284      '<div class="es-poll-progress">' +
285      '<div class="es-poll-progress-bar" role="es-progressbar" aria-valuenow="' + percent + '"' +
286      ' aria-valuemin="0" aria-valuemax="100" data-width="' + percent + '"> ' +
287      '</div>' +
288      '</div>  ' +
289      '<div class="es-percent es-d-flex es-justify-content-between"><div class="answers-title">' + answerItem.answer + '</div><div class="answers-value"> ' + percent + '% </div></div>' +
290      '</div>' +
291      '</div>';
292
293  });
294  out = out.replace(/\{results\}/gi, results);
295
296  $elemResult.html(out);
297  $elemResult.find(".es-poll-progress-bar").each(function () {
298    $(this).css({
299      "width": $(this).attr("data-width") + "%"
300    })
301  })
302}
303if (typeof jQuery.getPWK != "function") jQuery.getPWK = function (j, key, value, param) {
304  //array  - key for find - value for find- get value for param
305  //j = the array we want find  
306  //param === * (all item as object)
307  //param === # index of item in array
308  var res;
309  j.map(function (el, index) {
310    if (param === "*") {
311      if (el[key] == value) res = el;
312    } else if (param === "#") {
313      if (el[key] == value) res = index;
314    } else {
315      if (el[key] == value) res = el[param]
316    }
317  });
318  return res;
319}
320var CHDB64 = function (str) {
321  str = (typeof str == "undefined" ? "" : str.toString());
322  var out = (str.indexOf("B64:") == 0 ? Base64.decode(str.replace("B64:", "")) : str);
323  out = (out.indexOf("Base64") == 0 ? Base64.decode(out.replace("Base64", "")) : out);
324  return out;
325}
326var Base64 = {
327  // private property
328  _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
329  // public method for encoding
330  encode: function (input) {
331    var output = "";
332    var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
333    var i = 0;
334    input = Base64._utf8_encode(input);
335    while (i < input.length) {
336      chr1 = input.charCodeAt(i++);
337      chr2 = input.charCodeAt(i++);
338      chr3 = input.charCodeAt(i++);
339      enc1 = chr1 >> 2;
340      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
341      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
342      enc4 = chr3 & 63;
343      if (isNaN(chr2)) {
344        enc3 = enc4 = 64;
345      } else if (isNaN(chr3)) {
346        enc4 = 64;
347      }
348      output = output +
349        this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
350        this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
351    }
352    return output;
353  },
354  // public method for decoding
355  decode: function (input) {
356    var output = "";
357    var chr1, chr2, chr3;
358    var enc1, enc2, enc3, enc4;
359    var i = 0;
360    input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
361    while (i < input.length) {
362      enc1 = this._keyStr.indexOf(input.charAt(i++));
363      enc2 = this._keyStr.indexOf(input.charAt(i++));
364      enc3 = this._keyStr.indexOf(input.charAt(i++));
365      enc4 = this._keyStr.indexOf(input.charAt(i++));
366      chr1 = (enc1 << 2) | (enc2 >> 4);
367      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
368      chr3 = ((enc3 & 3) << 6) | enc4;
369      output = output + String.fromCharCode(chr1);
370      if (enc3 != 64) {
371        output = output + String.fromCharCode(chr2);
372      }
373      if (enc4 != 64) {
374        output = output + String.fromCharCode(chr3);
375      }
376    }
377    output = Base64._utf8_decode(output);
378    return output;
379  },
380
381  // private method for UTF-8 encoding
382  _utf8_encode: function (string) {
383    string = string.replace(/\r\n/g, "\n");
384    var utftext = "";
385
386    for (var n = 0; n < string.length; n++) {
387      var c = string.charCodeAt(n);
388
389      if (c < 128) {
390        utftext += String.fromCharCode(c);
391      } else if ((c > 127) && (c < 2048)) {
392        utftext += String.fromCharCode((c >> 6) | 192);
393        utftext += String.fromCharCode((c & 63) | 128);
394      } else {
395        utftext += String.fromCharCode((c >> 12) | 224);
396        utftext += String.fromCharCode(((c >> 6) & 63) | 128);
397        utftext += String.fromCharCode((c & 63) | 128);
398      }
399    }
400
401    return utftext;
402  },
403
404  // private method for UTF-8 decoding
405  _utf8_decode: function (utftext) {
406    var string = "";
407    var i = 0;
408    var c = c1 = c2 = 0;
409
410    while (i < utftext.length) {
411      c = utftext.charCodeAt(i);
412
413      if (c < 128) {
414        string += String.fromCharCode(c);
415        i++;
416      } else if ((c > 191) && (c < 224)) {
417        c2 = utftext.charCodeAt(i + 1);
418        string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
419        i += 2;
420      } else {
421        c2 = utftext.charCodeAt(i + 1);
422        c3 = utftext.charCodeAt(i + 2);
423        string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
424        i += 3;
425      }
426    }
427
428    return string;
429  }
430}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.