PageSourceSearch

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

js fums.ac.ir collected 2026-10-02 14:43:22 UTC 12,489 bytes, 388 lines download raw bytes

1//Build Number : 1009904232103
2
3function initMultiPoll(pollDataArray) {
4  $(document).ready(function () {
5
6
7    decodedData = [];
8    const template =
9      '  <div class=" poll-item item" data-id="{id}" data-index="{index}"> \
10        <div class="es-row title-row">\
11            <h3 class="es-col-12 title">{title}</h3>\
12        </div>\
13        <div class="es-row">\
14            <div class="es-col-12 answers">{answers}</div>\
15        </div>\
16        <div class="es-row">\
17            <div class="es-col-12">\
18                <button class="es-btn es-btn-primary submitQuestion es-btn-block es-col-6 es-mx-auto">{submit}</button>\
19            </div>\
20        </div>\
21    </div>';
22    let out = '';
23    pollDataArray.forEach(function (pollData, index) {
24      const pollDataDecode = {
25        "title": Base64.decode(pollData.title.toString().replace("B64:", "")),
26        "answers": JSON.parse(Base64.decode(pollData.answers.toString().replace("B64:", ""))),
27        "id": pollData.id
28      };
29      if (pollData.result) pollDataDecode["result"] = pollData.result;
30      decodedData.push(pollDataDecode);
31
32
33
34      let temp = template
35        .replace(/\{title\}/gi, pollDataDecode.title)
36        .replace(/\{id\}/gi, pollDataDecode.id)
37        .replace(/\{index\}/gi, index)
38        ;
39      let answers = "";
40      pollDataDecode.answers.map(function (answerItem, index2) {
41        answers +=
42          '<div class="radio"> <label> <input name="vote_' + index + '" value="' +
43          answerItem.value + '" type="radio" /> ' +
44          answerItem.answer + '</label> </div>';
45      });
46
47      temp = temp.replace(/\{answers\}/gi, answers);
48
49      temp = temp.replace(/\{submit\}/gi, "ثبت پاسخ");
50      out += temp;
51    })
52    console.log($("#pollContent"), out)
53    $("#pollContent").html(out);
54    $("#pollContent").addClass("owl-carousel  owl-theme");
55    $("#pollContent .poll-item").each(function () {
56
57      var pollDataDecode = decodedData[$(this).data("index")];
58      console.log(pollDataDecode)
59      if (pollDataDecode.result) {
60        pollDataDecode["result"] = pollDataDecode.result;
61        showPollResult(pollDataDecode, $(this));
62        return;
63      }
64    })
65
66    var pollOwlCarousel = $("#pollContent").owlCarousel({
67      loop: false,
68      margin: 10,
69      dots: true,
70      nav: false,
71      /* touchDrag:false,
72       mouseDrag:false,
73       touchDrag:false,
74       pullDrag:false, */
75      rtl: true,
76      responsive: {
77        0: {
78          items: 1
79        },
80        600: {
81          items: 1
82        },
83        1000: {
84          items: 1
85        }
86      }
87    })
88    $(".submitQuestion").on("click", function () {
89      let _this = this, $elem = $(this).closest('.poll-item');
90      if (typeof $elem.find("input[type='radio']:checked").val() == "undefined") {
91        alert("یک مورد را انتخاب کنید ");
92        return
93      }
94      $.ajax({
95        url: "/inc/ajax.ashx",
96        type: "POST",
97        data: {
98          "id": $elem.data("id"),
99          "action": "submit_vote",
100          "value": $elem.find("input[type='radio']:checked").val()
101        },
102        dataType: "json",
103        beforeSend: function () {
104          $elem.find("input,button").attr("disabled", true);
105          $(_this).html('صبر کنید...');
106        },
107        success: function (res) {
108
109          if (res.status == "success") {
110            console.log(decodedData, $elem.data("index"))
111            var pollDataDecode = decodedData[$elem.data("index")];
112            $.extend(pollDataDecode, { "result": res.result });
113
114            showPollResult(pollDataDecode, $elem);
115            setTimeout(function () {
116              pollOwlCarousel.trigger('next.owl.carousel');
117            }, 1000);
118
119          }
120
121
122        },
123        error: function () {
124          $("#submitpoll").attr("disabled", false);
125          $(".poll-loader").remove();
126        }
127      })
128    })
129  })
130}
131function initPoll(pollData) {
132  $(document).ready(function () {
133
134
135    const pollDataDecode = {
136      "title": Base64.decode(pollData.title.toString().replace("B64:", "")),
137      "answers": JSON.parse(Base64.decode(pollData.answers.toString().replace("B64:", ""))),
138      "id": pollData.id
139    },
140      template =
141        '    <div class="es-row title-row">\
142        <h3 class="es-col-12 title">{title}</h3>\
143    </div>\
144    <div class="es-row">\
145        <div class="es-col-12 answers">{answers}</div>\
146    </div>\
147    <div class="es-row">\
148        <div class="es-col-12">\
149            <button class="es-btn es-btn-primary" name="submitpoll" type="submit">{submit}</button>\
150        </div>\
151    </div> ', pollElement = "#pollContent-" + pollDataDecode.id;
152    if (pollData.result) {
153      pollDataDecode["result"] = pollData.result;
154
155      showPollResult(pollDataDecode, $(pollElement));
156      return;
157    }
158    var out = template.replace(/\{title\}/gi, pollDataDecode.title);
159    var answers = "";
160    pollDataDecode.answers.map(function (answerItem) {
161      answers +=
162        '<div class="radio"> <label> <input name="vote" value="' +
163        answerItem.value + '" type="radio" /> ' +
164        answerItem.answer + '</label> </div>';
165    });
166
167    out = out.replace(/\{answers\}/gi, answers);
168    out = out.replace(/\{submit\}/gi, "ثبت نظر");
169    $(pollElement).html(out);
170
171    $(pollElement + " [name='submitpoll']").on("click", function () {
172      var _this = this;
173      if (typeof $("input[name='vote']:checked").val() == "undefined") {
174        alert("یک مورد را انتخاب کنید ");
175        return
176      }
177      $.ajax({
178        url: "/inc/ajax.ashx",
179        type: "POST",
180        data: {
181          "id": pollDataDecode.id,
182          "action": "submit_vote",
183          "value": $("input[name='vote']:checked").val()
184        },
185        dataType: "json",
186        beforeSend: function () {
187          $(_this).attr("disabled", true);
188          $(pollElement).append('<div class="poll-loader">لطفا صبر کنید...</div>');
189        },
190        success: function (res) {
191          $(_this).attr("disabled", false);
192          $(".poll-loader").remove();
193          if (res.status == "success") {
194            $.extend(pollDataDecode, { "result": res.result });
195            console.log(pollDataDecode)
196            showPollResult(pollDataDecode, $(pollElement));
197          }
198
199
200        },
201        error: function () {
202          $(_this).attr("disabled", false);
203          $(".poll-loader").remove();
204        }
205      })
206    })
207  })
208}
209
210function showPollResult(pollData, $elemResult) {
211  const template =
212    '      <div class="es-row">\
213          <h3 class="es-col-12 title">{title}</h3>\
214      </div>\
215      <div class="es-row">\
216          <div class="es-col-12 answers">{results}</div>\
217      </div>' ;
218
219  var out = template.replace(/\{title\}/gi, pollData.title);
220  var results = "", totalPoint = 0;
221
222  pollData.answers.map(function (answerItem, index) {
223    var resultItem = $.getPWK(pollData.result, "value", answerItem.value, "*");
224
225    if (!resultItem) {
226      answerItem["count"] = 0;
227      answerItem["value"] = CHDB64(answerItem.value);
228      answerItem["answer"] = CHDB64(answerItem.answer);
229    }
230    else {
231      answerItem["count"] = Number(CHDB64(resultItem.count));
232      totalPoint += Number(CHDB64(resultItem.count));
233    }
234
235  });
236
237  pollData.answers.map(function (answerItem, index) {
238    var percent = Math.round(answerItem.count * 100 / totalPoint);
239    results +=
240      '<div class="result es-row"> ' +
241      '<div class="es-col-12">  ' +
242      '<div class="es-poll-progress">' +
243      '<div class="es-poll-progress-bar" role="es-progressbar" aria-valuenow="' + percent + '"' +
244      ' aria-valuemin="0" aria-valuemax="100" data-width="' + percent + '"> ' +
245      '</div>' +
246      '</div>  ' +
247      '<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>' +
248      '</div>' +
249      '</div>';
250
251  });
252  out = out.replace(/\{results\}/gi, results);
253
254  $elemResult.html(out);
255  $elemResult.find(".es-poll-progress-bar").each(function () {
256    $(this).css({
257      "width": $(this).attr("data-width") + "%"
258    })
259  })
260}
261if (typeof jQuery.getPWK != "function") jQuery.getPWK = function (j, key, value, param) {
262  //array  - key for find - value for find- get value for param
263  //j = the array we want find  
264  //param === * (all item as object)
265  //param === # index of item in array
266  var res;
267  j.map(function (el, index) {
268    if (param === "*") {
269      if (el[key] == value) res = el;
270    } else if (param === "#") {
271      if (el[key] == value) res = index;
272    } else {
273      if (el[key] == value) res = el[param]
274    }
275  });
276  return res;
277}
278var CHDB64 = function (str) {
279  str = (typeof str == "undefined" ? "" : str.toString());
280  var out = (str.indexOf("B64:") == 0 ? Base64.decode(str.replace("B64:", "")) : str);
281  out = (out.indexOf("Base64") == 0 ? Base64.decode(out.replace("Base64", "")) : out);
282  return out;
283}
284var Base64 = {
285  // private property
286  _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
287  // public method for encoding
288  encode: function (input) {
289    var output = "";
290    var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
291    var i = 0;
292    input = Base64._utf8_encode(input);
293    while (i < input.length) {
294      chr1 = input.charCodeAt(i++);
295      chr2 = input.charCodeAt(i++);
296      chr3 = input.charCodeAt(i++);
297      enc1 = chr1 >> 2;
298      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
299      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
300      enc4 = chr3 & 63;
301      if (isNaN(chr2)) {
302        enc3 = enc4 = 64;
303      } else if (isNaN(chr3)) {
304        enc4 = 64;
305      }
306      output = output +
307        this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
308        this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
309    }
310    return output;
311  },
312  // public method for decoding
313  decode: function (input) {
314    var output = "";
315    var chr1, chr2, chr3;
316    var enc1, enc2, enc3, enc4;
317    var i = 0;
318    input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
319    while (i < input.length) {
320      enc1 = this._keyStr.indexOf(input.charAt(i++));
321      enc2 = this._keyStr.indexOf(input.charAt(i++));
322      enc3 = this._keyStr.indexOf(input.charAt(i++));
323      enc4 = this._keyStr.indexOf(input.charAt(i++));
324      chr1 = (enc1 << 2) | (enc2 >> 4);
325      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
326      chr3 = ((enc3 & 3) << 6) | enc4;
327      output = output + String.fromCharCode(chr1);
328      if (enc3 != 64) {
329        output = output + String.fromCharCode(chr2);
330      }
331      if (enc4 != 64) {
332        output = output + String.fromCharCode(chr3);
333      }
334    }
335    output = Base64._utf8_decode(output);
336    return output;
337  },
338
339  // private method for UTF-8 encoding
340  _utf8_encode: function (string) {
341    string = string.replace(/\r\n/g, "\n");
342    var utftext = "";
343
344    for (var n = 0; n < string.length; n++) {
345      var c = string.charCodeAt(n);
346
347      if (c < 128) {
348        utftext += String.fromCharCode(c);
349      } else if ((c > 127) && (c < 2048)) {
350        utftext += String.fromCharCode((c >> 6) | 192);
351        utftext += String.fromCharCode((c & 63) | 128);
352      } else {
353        utftext += String.fromCharCode((c >> 12) | 224);
354        utftext += String.fromCharCode(((c >> 6) & 63) | 128);
355        utftext += String.fromCharCode((c & 63) | 128);
356      }
357    }
358
359    return utftext;
360  },
361
362  // private method for UTF-8 decoding
363  _utf8_decode: function (utftext) {
364    var string = "";
365    var i = 0;
366    var c = c1 = c2 = 0;
367
368    while (i < utftext.length) {
369      c = utftext.charCodeAt(i);
370
371      if (c < 128) {
372        string += String.fromCharCode(c);
373        i++;
374      } else if ((c > 191) && (c < 224)) {
375        c2 = utftext.charCodeAt(i + 1);
376        string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
377        i += 2;
378      } else {
379        c2 = utftext.charCodeAt(i + 1);
380        c3 = utftext.charCodeAt(i + 2);
381        string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
382        i += 3;
383      }
384    }
385
386    return string;
387  }
388}

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.