1- ابتدا کد اسکریپت فعال سازی (اسکریپت 1) کپی کنید و اون رو بعد از تگ </style> و قبل از تگ <head> قرار بدید.
<script>
//<![CDATA[
var json_parse = (function () {
var at,
ch,
escapee = {
'"': '"',
'\\': '\\',
'/': '/',
b: '\b',
f: '\f',
n: '\n',
r: '\r',
t: '\t'
},
text,
error = function (m) {
throw {
name: 'SyntaxError',
message: m,
at: at,
text: text
};
},
next = function (c) {
if (c && c !== ch) {
error("Expected '" + c + "' instead of '" + ch + "'");
}
ch = text.charAt(at);
at += 1;
return ch;
},
number = function () {
var number,
string = '';
if (ch === '-') {
string = '-';
next('-');
}
while (ch >= '0' && ch <= '9') {
string += ch;
next();
}
if (ch === '.') {
string += '.';
while (next() && ch >= '0' && ch <= '9') {
string += ch;
}
}
if (ch === 'e' || ch === 'E') {
string += ch;
next();
if (ch === '-' || ch === '+') {
string += ch;
next();
}
while (ch >= '0' && ch <= '9') {
string += ch;
next();
}
}
number = +string;
if (isNaN(number)) {
error("Bad number");
} else {
return number;
}
},
string = function () {
var hex,
i,
string = '',
uffff;
if (ch === '"') {
while (next()) {
if (ch === '"') {
next();
return string;
} else if (ch === '\\') {
next();
if (ch === 'u') {
uffff = 0;
for (i = 0; i < 4; i += 1) {
hex = parseInt(next(), 16);
if (!isFinite(hex)) {
break;
}
uffff = uffff * 16 + hex;
}
string += String.fromCharCode(uffff);
} else if (typeof escapee[ch] === 'string') {
string += escapee[ch];
} else {
break;
}
} else {
string += ch;
}
}
}
error("Bad string");
},
white = function () {
while (ch && ch <= ' ') {
next();
}
},
word = function () {
switch (ch) {
case 't':
next('t');
next('r');
next('u');
next('e');
return true;
case 'f':
next('f');
next('a');
next('l');
next('s');
next('e');
return false;
case 'n':
next('n');
next('u');
next('l');
next('l');
return null;
}
error("Unexpected '" + ch + "'");
},
value,
array = function () {
var array = [];
if (ch === '[') {
next('[');
white();
if (ch === ']') {
next(']');
return array;
}
while (ch) {
array.push(value());
white();
if (ch === ']') {
next(']');
return array;
}
next(',');
white();
}
}
error("Bad array");
},
object = function () {
var key,
object = {};
if (ch === '{') {
next('{');
white();
if (ch === '}') {
next('}');
return object;
}
while (ch) {
key = string();
white();
next(':');
if (Object.hasOwnProperty.call(object, key)) {
error('Duplicate key "' + key + '"');
}
object[key] = value();
white();
if (ch === '}') {
next('}');
return object;
}
next(',');
white();
}
}
error("Bad object");
};
value = function () {
white();
switch (ch) {
case '{':
return object();
case '[':
return array();
case '"':
return string();
case '-':
return number();
default:
return ch >= '0' && ch <= '9' ? number() : word();
}
};
return function (source, reviver) {
var result;
text = source;
at = 0;
ch = ' ';
result = value();
white();
if (ch) {
error("Syntax error");
}
return typeof reviver === 'function' ? (function walk(holder, key) {
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}({'': result}, '')) : result;
};
}());
function SetCookie(c_name, c_value, e_days)
{
var exdate = new Date();
exdate.setDate(exdate.getDate() + e_days);
var value = "";
if (c_value instanceof Array) {
for(var i = 0; i < c_value.length; i++) {
if (i != 0)
value += "&";
value += c_value[i][0] + "=" + escape(c_value[i][1]);
}
}
else {
value = escape(c_value);
}
var parts = location.hostname.split('.');
var subdomain = parts.shift();
var upperleveldomain = parts.join('.');
var domain = location.hostname.split('.').slice(-2).join('.').toLocaleLowerCase();
if (domain == "blogsky.com") domain = ".blogsky.com";
value += (e_days == null) ? "" : ";expires=" + exdate.toUTCString() + ";path=/;domain=" + domain;
document.cookie = c_name + "=" + value;
}
function GetCookie(c_name)
{
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if (c_start == -1)
{
c_start = c_value.indexOf(c_name + "=");
}
if (c_start == -1)
{
c_value = null;
}
else
{
c_start = c_value.indexOf("=", c_start) + 1;
var c_end = c_value.indexOf(";", c_start);
if (c_end == -1)
{
c_end = c_value.length;
}
var c_value = c_value.substring(c_start, c_end);
var equalIndex = c_value.indexOf("=");
var ampIndex = c_value.indexOf("&");
if (ampIndex < equalIndex) {
c_end = ampIndex;
c_value = c_value.substring(0, c_end);
}
if (c_value.indexOf("=") != -1) {
var c_values = c_value.split("&");
c_value = new Array();
for(var i = 0; i < c_values.length; i++) {
c_value.push(new Array(c_values[i].split("=")[0], unescape(c_values[i].split("=")[1])));
}
}
else {
c_value = unescape(c_value);
}
}
return c_value;
}
function DeleteCookie(c_name) {
SetCookie(c_name, "", -10);
}
function PollVote(submitButton, pollId) {
var pollVoteMessage = document.getElementById("poll-vote-message-" + pollId);
submitButton.setAttribute("disabled", "disabled");
var votes = "";
var index = 0;
var elements = document.getElementsByTagName("*");
for (var i = 0; i < elements.length; i++) {
var elementPollId = elements[i].getAttribute("data-poll-id");
if (elementPollId != undefined && elementPollId == pollId) {
if (elements[i].checked) {
votes += "&votes[" + index + "]=" + elements[i].value;
index++;
}
}
}
if (votes == "") {
submitButton.removeAttribute("disabled");
pollVoteMessage.innerHTML = "گزینهای برای رای دادن انتخاب نشده است";
pollVoteMessage.style.display = "block";
setTimeout(function() { pollVoteMessage.style.display = "none"; }, 5000);
return;
}
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
var response = json_parse(xmlhttp.responseText);
if (response.Success) {
document.getElementById("poll-vote-" + pollId).innerHTML = response.PollResult;
}
else {
submitButton.removeAttribute("disabled");
pollVoteMessage.innerHTML = response.Message;
pollVoteMessage.style.display = "block";
setTimeout(function() { pollVoteMessage.style.display = "none"; }, 5000);
}
}
else if (xmlhttp.status == 500) {
submitButton.removeAttribute("disabled");
pollVoteMessage.innerHTML = "خطا در انجام عملیات";
pollVoteMessage.style.display = "block";
setTimeout(function() { pollVoteMessage.style.display = "none"; }, 5000);
}
}
}
xmlhttp.open("POST", "@pollActionUrl", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("pollid=" + pollId + votes);
}
function PollResult(resultButton, pollId)
{
var pollVoteMessage = document.getElementById("poll-vote-message-" + pollId);
var pollResultStatus = resultButton.getAttribute("data-status");
if (pollResultStatus == "locked") return;
resultButton.setAttribute("data-status", "locked");
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}
else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
resultButton.setAttribute("data-status", "available");
var response = json_parse(xmlhttp.responseText);
if (response.Success) {
var pollVote = document.getElementById("poll-vote-" + pollId);
pollVote.style.display = "none";
var pollResult = document.createElement("div");
pollResult.id = "poll-result-" + pollId;
pollResult.innerHTML = response.PollResult;
pollVote.parentNode.insertBefore(pollResult, pollVote);
var backButton = document.createElement("a");
backButton.onclick = function(){ PollBack(this, pollId); };
backButton.style.cursor = "pointer";
backButton.innerHTML = "بازگشت به نظرسنجی";
document.getElementById("poll-result-" + pollId).appendChild(backButton);
}
else {
pollVoteMessage.innerHTML = response.Message;
pollVoteMessage.style.display = "block";
setTimeout(function() { pollVoteMessage.style.display = "none"; resultButton.setAttribute("data-status", "available"); }, 5000);
}
}
else if (xmlhttp.status == 500) {
pollVoteMessage.innerHTML = "خطا در انجام عملیات";
pollVoteMessage.style.display = "block";
setTimeout(function() { pollVoteMessage.style.display = "none"; resultButton.setAttribute("data-status", "available"); }, 5000);
}
}
}
xmlhttp.open("POST", "@pollResultActionUrl", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("pollid=" + pollId);
}
function PollBack(backElement, pollId) {
var pollResult = document.getElementById("poll-result-" + pollId);
pollResult.parentNode.removeChild(pollResult);
document.getElementById("poll-vote-" + pollId).style.display = "block";
}
//]]>
</script>