Changeset 25440
 Timestamp:
 19.04.2012 16:09:40 (8 years ago)
 Files:

 1 modified
Legend:
 Unmodified
 Added
 Removed

main/trunk/greenstone3/web/interfaces/oran/js/javascriptglobalfunctions.js
r25364 r25440 233 233 function ifposDec(a, b) 234 234 { 235 console.log("GOT " + a + " and " + b);236 235 var carry = 0; 237 236 var num = 0; 238 237 var i = 0; 239 238 240 if(b.length > a.length){ console.log("RETURNING 0 (1)"); return 0;}239 if(b.length > a.length){return a;} 241 240 if(b.length == a.length) 242 241 { … … 244 243 while(i >= 0) 245 244 { 246 if(a[i] > b[i]){ console.log("BREAKING");break;}247 if(a[i] < b[i]){ console.log("RETURNING 0 (2)"); return 0;}245 if(a[i] > b[i]){break;} 246 if(a[i] < b[i]){return a;} 248 247 i; 249 248 } … … 251 250 252 251 i = 0; 252 var len = 0; 253 var outString = ""; 253 254 while((i < a.length)  (i < b.length)) 254 255 { … … 268 269 269 270 a[i] = num; 271 outString += num + "," 270 272 i++ 271 } 272 console.log("NUM is " + num); 273 274 return 1; 273 274 if(num != 0){len = i} 275 } 276 277 if(len < a.length) 278 { 279 a = a.slice(0, len); 280 } 281 282 return a; 275 283 } 276 284 … … 289 297 for(i = a.length  1; i >= 0; i) 290 298 { 291 console.log("i is " + i + " a[i] is " + a[i] + " a[i]/16 is " + Math.floor(a[i]/16) + " a[i]%16 is " + Math.floor(a[i]%16));292 console.log("Adding " + convert[Math.floor(a[i]/16)] + " and " + convert[Math.floor(a[i]%16)]);293 299 result.push(convert[Math.floor(a[i]/16)]); 294 300 result.push(convert[Math.floor(a[i]%16)]); … … 318 324 for(var i = 0; i < 8; i++) 319 325 { 320 primePow.push(pow );326 primePow.push(pow.slice()); //The javascript way to do an array copy (yuck!) 321 327 inc(pow, pow); 322 328 } … … 324 330 for(var i = 0; i < str.length; i++) 325 331 { 326 var c = str.char At(i);332 var c = str.charCodeAt(i); 327 333 328 334 if(remainder.length == 99) … … 333 339 for(var j = remainder.length; j > 0; j) 334 340 { 335 remainder[ i] = remainder[i1];341 remainder[j] = remainder[j1]; 336 342 } 337 343 remainder[0] = c; … … 339 345 for(var j = 7; j >= 0; j) 340 346 { 341 ifposDec(remainder, primePow[j]);347 remainder = ifposDec(remainder, primePow[j]); 342 348 } 343 349 } 344 345 var returnString = remainder.length + " AWAY TO CONVERT > ";346 for(var i = 0; i < remainder.length; i++)347 {348 returnString += remainder[i] + " ";349 }350 console.log(returnString);351 350 352 351 return convertNum(remainder);