Changeset 1321
- Timestamp:
- 12/07/07 10:23:45 (9 months ago)
- Files:
-
- mochikit/trunk/MochiKit/Iter.js (modified) (3 diffs)
- mochikit/trunk/packed/MochiKit/MochiKit.js (modified) (162 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
mochikit/trunk/MochiKit/Iter.js
r1319 r1321 284 284 while (argiter.length > 1) { 285 285 try { 286 return argiter[0].next(); 286 var result = argiter[0].next(); 287 return result; 287 288 } catch (e) { 288 289 if (e != self.StopIteration) { … … 290 291 } 291 292 argiter.shift(); 293 var result = argiter[0].next(); 294 return result; 292 295 } 293 296 } … … 415 418 iterable = self.iter(iterable); 416 419 var rval = []; 420 var a_val; 417 421 try { 418 422 while (true) { 419 rval.push(iterable.next()); 423 a_val = iterable.next(); 424 rval.push(a_val); 420 425 } 421 426 } catch (e) { mochikit/trunk/packed/MochiKit/MochiKit.js
r1319 r1321 1229 1229 while(_18e.length>1){ 1230 1230 try{ 1231 return _18e[0].next(); 1231 var _18f=_18e[0].next(); 1232 return _18f; 1232 1233 } 1233 1234 catch(e){ … … 1236 1237 } 1237 1238 _18e.shift(); 1239 var _18f=_18e[0].next(); 1240 return _18f; 1238 1241 } 1239 1242 } … … 1276 1279 return rval; 1277 1280 }}; 1278 },_tee:function(_19 9,sync,_19b){1279 sync.pos[_19 9]=-1;1281 },_tee:function(_19a,sync,_19c){ 1282 sync.pos[_19a]=-1; 1280 1283 var m=MochiKit.Base; 1281 var _19 d=m.listMin;1284 var _19e=m.listMin; 1282 1285 return {repr:function(){ 1283 return "tee("+_19 9+", ...)";1286 return "tee("+_19a+", ...)"; 1284 1287 },toString:m.forwardCall("repr"),next:function(){ 1285 1288 var rval; 1286 var i=sync.pos[_19 9];1289 var i=sync.pos[_19a]; 1287 1290 if(i==sync.max){ 1288 rval=_19 b.next();1291 rval=_19c.next(); 1289 1292 sync.deque.push(rval); 1290 1293 sync.max+=1; 1291 sync.pos[_19 9]+=1;1294 sync.pos[_19a]+=1; 1292 1295 }else{ 1293 1296 rval=sync.deque[i-sync.min]; 1294 sync.pos[_19 9]+=1;1295 if(i==sync.min&&_19 d(sync.pos)!=sync.min){1297 sync.pos[_19a]+=1; 1298 if(i==sync.min&&_19e(sync.pos)!=sync.min){ 1296 1299 sync.min+=1; 1297 1300 sync.deque.shift(); … … 1300 1303 return rval; 1301 1304 }}; 1302 },tee:function(_1a 0,n){1305 },tee:function(_1a1,n){ 1303 1306 var rval=[]; 1304 1307 var sync={"pos":[],"deque":[],"max":-1,"min":-1}; … … 1307 1310 } 1308 1311 var self=MochiKit.Iter; 1309 _1a 0=self.iter(_1a0);1312 _1a1=self.iter(_1a1); 1310 1313 var _tee=self._tee; 1311 1314 for(var i=0;i<n;i++){ 1312 rval.push(_tee(i,sync,_1a 0));1315 rval.push(_tee(i,sync,_1a1)); 1313 1316 } 1314 1317 return rval; 1315 },list:function(_1a 7){1318 },list:function(_1a8){ 1316 1319 var rval; 1317 if(_1a 7instanceof Array){1318 return _1a 7.slice();1319 } 1320 if(typeof (_1a 7)=="function"&&!(_1a7 instanceof Function)&&typeof (_1a7.length)=="number"){1320 if(_1a8 instanceof Array){ 1321 return _1a8.slice(); 1322 } 1323 if(typeof (_1a8)=="function"&&!(_1a8 instanceof Function)&&typeof (_1a8.length)=="number"){ 1321 1324 rval=[]; 1322 for(var i=0;i<_1a 7.length;i++){1323 rval.push(_1a 7[i]);1325 for(var i=0;i<_1a8.length;i++){ 1326 rval.push(_1a8[i]); 1324 1327 } 1325 1328 return rval; 1326 1329 } 1327 1330 var self=MochiKit.Iter; 1328 _1a 7=self.iter(_1a7);1331 _1a8=self.iter(_1a8); 1329 1332 var rval=[]; 1333 var _1ac; 1330 1334 try{ 1331 1335 while(true){ 1332 rval.push(_1a7.next()); 1336 _1ac=_1a8.next(); 1337 rval.push(_1ac); 1333 1338 } 1334 1339 } … … 1340 1345 } 1341 1346 return undefined; 1342 },reduce:function(fn,_1a c,_1ad){1347 },reduce:function(fn,_1ae,_1af){ 1343 1348 var i=0; 1344 var x=_1a d;1349 var x=_1af; 1345 1350 var self=MochiKit.Iter; 1346 _1a c=self.iter(_1ac);1351 _1ae=self.iter(_1ae); 1347 1352 if(arguments.length<3){ 1348 1353 try{ 1349 x=_1a c.next();1354 x=_1ae.next(); 1350 1355 } 1351 1356 catch(e){ … … 1359 1364 try{ 1360 1365 while(true){ 1361 x=fn(x,_1a c.next());1366 x=fn(x,_1ae.next()); 1362 1367 } 1363 1368 } … … 1369 1374 return x; 1370 1375 },range:function(){ 1371 var _1b 1=0;1376 var _1b3=0; 1372 1377 var stop=0; 1373 1378 var step=1; … … 1376 1381 }else{ 1377 1382 if(arguments.length==2){ 1378 _1b 1=arguments[0];1383 _1b3=arguments[0]; 1379 1384 stop=arguments[1]; 1380 1385 }else{ 1381 1386 if(arguments.length==3){ 1382 _1b 1=arguments[0];1387 _1b3=arguments[0]; 1383 1388 stop=arguments[1]; 1384 1389 step=arguments[2]; … … 1392 1397 } 1393 1398 return {next:function(){ 1394 if((step>0&&_1b 1>=stop)||(step<0&&_1b1<=stop)){1399 if((step>0&&_1b3>=stop)||(step<0&&_1b3<=stop)){ 1395 1400 throw MochiKit.Iter.StopIteration; 1396 1401 } 1397 var rval=_1b 1;1398 _1b 1+=step;1402 var rval=_1b3; 1403 _1b3+=step; 1399 1404 return rval; 1400 1405 },repr:function(){ 1401 return "range("+[_1b 1,stop,step].join(", ")+")";1406 return "range("+[_1b3,stop,step].join(", ")+")"; 1402 1407 },toString:MochiKit.Base.forwardCall("repr")}; 1403 },sum:function(_1b 5,_1b6){1404 if(typeof (_1b 6)=="undefined"||_1b6===null){1405 _1b 6=0;1406 } 1407 var x=_1b 6;1408 },sum:function(_1b7,_1b8){ 1409 if(typeof (_1b8)=="undefined"||_1b8===null){ 1410 _1b8=0; 1411 } 1412 var x=_1b8; 1408 1413 var self=MochiKit.Iter; 1409 _1b 5=self.iter(_1b5);1414 _1b7=self.iter(_1b7); 1410 1415 try{ 1411 1416 while(true){ 1412 x+=_1b 5.next();1417 x+=_1b7.next(); 1413 1418 } 1414 1419 } … … 1419 1424 } 1420 1425 return x; 1421 },exhaust:function(_1b 9){1426 },exhaust:function(_1bb){ 1422 1427 var self=MochiKit.Iter; 1423 _1b 9=self.iter(_1b9);1428 _1bb=self.iter(_1bb); 1424 1429 try{ 1425 1430 while(true){ 1426 _1b 9.next();1431 _1bb.next(); 1427 1432 } 1428 1433 } … … 1432 1437 } 1433 1438 } 1434 },forEach:function(_1b b,func,self){1439 },forEach:function(_1bd,func,self){ 1435 1440 var m=MochiKit.Base; 1436 1441 if(arguments.length>2){ 1437 1442 func=m.bind(func,self); 1438 1443 } 1439 if(m.isArrayLike(_1b b)){1444 if(m.isArrayLike(_1bd)){ 1440 1445 try{ 1441 for(var i=0;i<_1b b.length;i++){1442 func(_1b b[i]);1446 for(var i=0;i<_1bd.length;i++){ 1447 func(_1bd[i]); 1443 1448 } 1444 1449 } … … 1450 1455 }else{ 1451 1456 self=MochiKit.Iter; 1452 self.exhaust(self.imap(func,_1b b));1453 } 1454 },every:function(_1c 0,func){1457 self.exhaust(self.imap(func,_1bd)); 1458 } 1459 },every:function(_1c2,func){ 1455 1460 var self=MochiKit.Iter; 1456 1461 try{ 1457 self.ifilterfalse(func,_1c 0).next();1462 self.ifilterfalse(func,_1c2).next(); 1458 1463 return false; 1459 1464 } … … 1464 1469 return true; 1465 1470 } 1466 },sorted:function(_1c 3,cmp){1467 var rval=MochiKit.Iter.list(_1c 3);1471 },sorted:function(_1c5,cmp){ 1472 var rval=MochiKit.Iter.list(_1c5); 1468 1473 if(arguments.length==1){ 1469 1474 cmp=MochiKit.Base.compare; … … 1471 1476 rval.sort(cmp); 1472 1477 return rval; 1473 },reversed:function(_1c 6){1474 var rval=MochiKit.Iter.list(_1c 6);1478 },reversed:function(_1c8){ 1479 var rval=MochiKit.Iter.list(_1c8); 1475 1480 rval.reverse(); 1476 1481 return rval; 1477 },some:function(_1c 8,func){1482 },some:function(_1ca,func){ 1478 1483 var self=MochiKit.Iter; 1479 1484 try{ 1480 self.ifilter(func,_1c 8).next();1485 self.ifilter(func,_1ca).next(); 1481 1486 return true; 1482 1487 } … … 1487 1492 return false; 1488 1493 } 1489 },iextend:function(lst,_1c c){1490 if(MochiKit.Base.isArrayLike(_1c c)){1491 for(var i=0;i<_1c c.length;i++){1492 lst.push(_1c c[i]);1494 },iextend:function(lst,_1ce){ 1495 if(MochiKit.Base.isArrayLike(_1ce)){ 1496 for(var i=0;i<_1ce.length;i++){ 1497 lst.push(_1ce[i]); 1493 1498 } 1494 1499 }else{ 1495 1500 var self=MochiKit.Iter; 1496 _1c c=self.iter(_1cc);1501 _1ce=self.iter(_1ce); 1497 1502 try{ 1498 1503 while(true){ 1499 lst.push(_1c c.next());1504 lst.push(_1ce.next()); 1500 1505 } 1501 1506 } … … 1507 1512 } 1508 1513 return lst; 1509 },groupby:function(_1 cf,_1d0){1514 },groupby:function(_1d1,_1d2){ 1510 1515 var m=MochiKit.Base; 1511 1516 var self=MochiKit.Iter; 1512 1517 if(arguments.length<2){ 1513 _1d 0=m.operator.identity;1514 } 1515 _1 cf=self.iter(_1cf);1518 _1d2=m.operator.identity; 1519 } 1520 _1d1=self.iter(_1d1); 1516 1521 var pk=undefined; 1517 1522 var k=undefined; 1518 1523 var v; 1519 1524 function fetch(){ 1520 v=_1 cf.next();1521 k=_1d 0(v);1525 v=_1d1.next(); 1526 k=_1d2(v); 1522 1527 } 1523 1528 function eat(){ … … 1526 1531 return ret; 1527 1532 } 1528 var _1d 7=true;1529 var _1d 8=m.compare;1533 var _1d9=true; 1534 var _1da=m.compare; 1530 1535 return {repr:function(){ 1531 1536 return "groupby(...)"; 1532 1537 },next:function(){ 1533 while(_1d 8(k,pk)===0){1538 while(_1da(k,pk)===0){ 1534 1539 fetch(); 1535 if(_1d 7){1536 _1d 7=false;1540 if(_1d9){ 1541 _1d9=false; 1537 1542 break; 1538 1543 } … … 1543 1548 fetch(); 1544 1549 } 1545 if(_1d 8(k,pk)!==0){1550 if(_1da(k,pk)!==0){ 1546 1551 throw self.StopIteration; 1547 1552 } … … 1549 1554 }}]; 1550 1555 }}; 1551 },groupby_as_array:function(_1d 9,_1da){1556 },groupby_as_array:function(_1db,_1dc){ 1552 1557 var m=MochiKit.Base; 1553 1558 var self=MochiKit.Iter; 1554 1559 if(arguments.length<2){ 1555 _1d a=m.operator.identity;1556 } 1557 _1d 9=self.iter(_1d9);1558 var _1d d=[];1559 var _1 de=true;1560 var _1 df;1561 var _1e 0=m.compare;1560 _1dc=m.operator.identity; 1561 } 1562 _1db=self.iter(_1db); 1563 var _1df=[]; 1564 var _1e0=true; 1565 var _1e1; 1566 var _1e2=m.compare; 1562 1567 while(true){ 1563 1568 try{ 1564 var _1e 1=_1d9.next();1565 var key=_1d a(_1e1);1569 var _1e3=_1db.next(); 1570 var key=_1dc(_1e3); 1566 1571 } 1567 1572 catch(e){ … … 1571 1576 throw e; 1572 1577 } 1573 if(_1 de||_1e0(key,_1df)!==0){1574 var _1e 3=[];1575 _1d d.push([key,_1e3]);1576 } 1577 _1e 3.push(_1e1);1578 _1 de=false;1579 _1 df=key;1580 } 1581 return _1d d;1582 },arrayLikeIter:function(_1e 4){1578 if(_1e0||_1e2(key,_1e1)!==0){ 1579 var _1e5=[]; 1580 _1df.push([key,_1e5]); 1581 } 1582 _1e5.push(_1e3); 1583 _1e0=false; 1584 _1e1=key; 1585 } 1586 return _1df; 1587 },arrayLikeIter:function(_1e6){ 1583 1588 var i=0; 1584 1589 return {repr:function(){ 1585 1590 return "arrayLikeIter(...)"; 1586 1591 },toString:MochiKit.Base.forwardCall("repr"),next:function(){ 1587 if(i>=_1e 4.length){1592 if(i>=_1e6.length){ 1588 1593 throw MochiKit.Iter.StopIteration; 1589 1594 } 1590 return _1e 4[i++];1595 return _1e6[i++]; 1591 1596 }}; 1592 },hasIterateNext:function(_1e 6){1593 return (_1e 6&&typeof (_1e6.iterateNext)=="function");1594 },iterateNextIter:function(_1e 7){1597 },hasIterateNext:function(_1e8){ 1598 return (_1e8&&typeof (_1e8.iterateNext)=="function"); 1599 },iterateNextIter:function(_1e9){ 1595 1600 return {repr:function(){ 1596 1601 return "iterateNextIter(...)"; 1597 1602 },toString:MochiKit.Base.forwardCall("repr"),next:function(){ 1598 var rval=_1e 7.iterateNext();1603 var rval=_1e9.iterateNext(); 1599 1604 if(rval===null||rval===undefined){ 1600 1605 throw MochiKit.Iter.StopIteration; … … 1634 1639 MochiKit.Logging.EXPORT=["LogLevel","LogMessage","Logger","alertListener","logger","log","logError","logDebug","logFatal","logWarning"]; 1635 1640 MochiKit.Logging.EXPORT_OK=["logLevelAtLeast","isLogMessage","compareLogMessage"]; 1636 MochiKit.Logging.LogMessage=function(num,_1e b,info){1641 MochiKit.Logging.LogMessage=function(num,_1ed,info){ 1637 1642 this.num=num; 1638 this.level=_1e b;1643 this.level=_1ed; 1639 1644 this.info=info; 1640 1645 this.timestamp=new Date(); … … 1644 1649 return "LogMessage("+m.map(m.repr,[this.num,this.level,this.info]).join(", ")+")"; 1645 1650 },toString:MochiKit.Base.forwardCall("repr")}; 1646 MochiKit.Base.update(MochiKit.Logging,{logLevelAtLeast:function(_1 ee){1651 MochiKit.Base.update(MochiKit.Logging,{logLevelAtLeast:function(_1f0){ 1647 1652 var self=MochiKit.Logging; 1648 if(typeof (_1 ee)=="string"){1649 _1 ee=self.LogLevel[_1ee];1653 if(typeof (_1f0)=="string"){ 1654 _1f0=self.LogLevel[_1f0]; 1650 1655 } 1651 1656 return function(msg){ 1652 var _1f 1=msg.level;1653 if(typeof (_1f 1)=="string"){1654 _1f 1=self.LogLevel[_1f1];1655 } 1656 return _1f 1>=_1ee;1657 var _1f3=msg.level; 1658 if(typeof (_1f3)=="string"){ 1659 _1f3=self.LogLevel[_1f3]; 1660 } 1661 return _1f3>=_1f0; 1657 1662 }; 1658 1663 },isLogMessage:function(){ 1659 var _1f 2=MochiKit.Logging.LogMessage;1664 var _1f4=MochiKit.Logging.LogMessage; 1660 1665 for(var i=0;i<arguments.length;i++){ 1661 if(!(arguments[i] instanceof _1f 2)){1666 if(!(arguments[i] instanceof _1f4)){ 1662 1667 return false; 1663 1668 } … … 1669 1674 alert("num: "+msg.num+"\nlevel: "+msg.level+"\ninfo: "+msg.info.join(" ")); 1670 1675 }}); 1671 MochiKit.Logging.Logger=function(_1f 7){1676 MochiKit.Logging.Logger=function(_1f9){ 1672 1677 this.counter=0; 1673 if(typeof (_1f 7)=="undefined"||_1f7===null){1674 _1f 7=-1;1675 } 1676 this.maxSize=_1f 7;1678 if(typeof (_1f9)=="undefined"||_1f9===null){ 1679 _1f9=-1; 1680 } 1681 this.maxSize=_1f9; 1677 1682 this._messages=[]; 1678 1683 this.listeners={}; … … 1709 1714 pair[1](msg); 1710 1715 } 1711 },addListener:function(_1f c,_1fd,_1fe){1712 if(typeof (_1f d)=="string"){1713 _1f d=MochiKit.Logging.logLevelAtLeast(_1fd);1714 } 1715 var _ 1ff=[_1fd,_1fe];1716 _ 1ff.ident=_1fc;1717 this.listeners[_1f c]=_1ff;1718 },removeListener:function(_20 0){1719 delete this.listeners[_20 0];1720 },baseLog:function(_20 1,_202){1721 var msg=new MochiKit.Logging.LogMessage(this.counter,_20 1,MochiKit.Base.extend(null,arguments,1));1716 },addListener:function(_1fe,_1ff,_200){ 1717 if(typeof (_1ff)=="string"){ 1718 _1ff=MochiKit.Logging.logLevelAtLeast(_1ff); 1719 } 1720 var _201=[_1ff,_200]; 1721 _201.ident=_1fe; 1722 this.listeners[_1fe]=_201; 1723 },removeListener:function(_202){ 1724 delete this.listeners[_202]; 1725 },baseLog:function(_203,_204){ 1726 var msg=new MochiKit.Logging.LogMessage(this.counter,_203,MochiKit.Base.extend(null,arguments,1)); 1722 1727 this._messages.push(msg); 1723 1728 this.dispatchListeners(msg); … … 1729 1734 this._messages.shift(); 1730 1735 } 1731 },getMessages:function(_20 4){1732 var _20 5=0;1733 if(!(typeof (_20 4)=="undefined"||_204===null)){1734 _20 5=Math.max(0,this._messages.length-_204);1735 } 1736 return this._messages.slice(_20 5);1737 },getMessageText:function(_20 6){1738 if(typeof (_20 6)=="undefined"||_206===null){1739 _20 6=30;1740 } 1741 var _20 7=this.getMessages(_206);1742 if(_20 7.length){1736 },getMessages:function(_206){ 1737 var _207=0; 1738 if(!(typeof (_206)=="undefined"||_206===null)){ 1739 _207=Math.max(0,this._messages.length-_206); 1740 } 1741 return this._messages.slice(_207); 1742 },getMessageText:function(_208){ 1743 if(typeof (_208)=="undefined"||_208===null){ 1744 _208=30; 1745 } 1746 var _209=this.getMessages(_208); 1747 if(_209.length){ 1743 1748 var lst=map(function(m){ 1744 1749 return "\n ["+m.num+"] "+m.level+": "+m.info.join(" "); 1745 },_20 7);1746 lst.unshift("LAST "+_20 7.length+" MESSAGES:");1750 },_209); 1751 lst.unshift("LAST "+_209.length+" MESSAGES:"); 1747 1752 return lst.join(""); 1748 1753 } 1749 1754 return ""; 1750 },debuggingBookmarklet:function(_20 a){1755 },debuggingBookmarklet:function(_20c){ 1751 1756 if(typeof (MochiKit.LoggingPane)=="undefined"){ 1752 1757 alert(this.getMessageText()); 1753 1758 }else{ 1754 MochiKit.LoggingPane.createLoggingPane(_20 a||false);1759 MochiKit.LoggingPane.createLoggingPane(_20c||false); 1755 1760 } 1756 1761 }}; … … 1759 1764 var m=MochiKit.Base; 1760 1765 m.registerComparator("LogMessage",this.isLogMessage,this.compareLogMessage); 1761 var _20 c=m.partial;1762 var _20 d=this.Logger;1763 var _2 0e=_20d.prototype.baseLog;1764 m.update(this.Logger.prototype,{debug:_20 c(_20e,"DEBUG"),log:_20c(_20e,"INFO"),error:_20c(_20e,"ERROR"),fatal:_20c(_20e,"FATAL"),warning:_20c(_20e,"WARNING")});1766 var _20e=m.partial; 1767 var _20f=this.Logger; 1768 var _210=_20f.prototype.baseLog; 1769 m.update(this.Logger.prototype,{debug:_20e(_210,"DEBUG"),log:_20e(_210,"INFO"),error:_20e(_210,"ERROR"),fatal:_20e(_210,"FATAL"),warning:_20e(_210,"WARNING")}); 1765 1770 var self=this; 1766 var _21 0=function(name){1771 var _212=function(name){ 1767 1772 return function(){ 1768 1773 self.logger[name].apply(self.logger,arguments); 1769 1774 }; 1770 1775 }; 1771 this.log=_21 0("log");1772 this.logError=_21 0("error");1773 this.logDebug=_21 0("debug");1774 this.logFatal=_21 0("fatal");1775 this.logWarning=_21 0("warning");1776 this.logger=new _20 d();1776 this.log=_212("log"); 1777 this.logError=_212("error"); 1778 this.logDebug=_212("debug"); 1779 this.logFatal=_212("fatal"); 1780 this.logWarning=_212("warning"); 1781 this.logger=new _20f(); 1777 1782 this.logger.useNativeConsole=true; 1778 1783 this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)}; … … 1819 1824 return null; 1820 1825 } 1821 var year,_21 8,day,hour,min,sec,msec;1826 var year,_21a,day,hour,min,sec,msec; 1822 1827 year=parseInt(res[1],10); 1823 1828 if(typeof (res[2])=="undefined"||res[2]===""){ 1824 1829 return new Date(year); 1825 1830 } 1826 _21 8=parseInt(res[2],10)-1;1831 _21a=parseInt(res[2],10)-1; 1827 1832 day=parseInt(res[3],10); 1828 1833 if(typeof (res[4])=="undefined"||res[4]===""){ 1829 return new Date(year,_21 8,day);1834 return new Date(year,_21a,day); 1830 1835 } 1831 1836 hour=parseInt(res[4],10); … … 1838 1843 } 1839 1844 if((typeof (res[8])=="undefined"||res[8]==="")&&(typeof (res[9])=="undefined"||res[9]==="")){ 1840 return new Date(year,_21 8,day,hour,min,sec,msec);1845 return new Date(year,_21a,day,hour,min,sec,msec); 1841 1846 } 1842 1847 var ofs; … … 1852 1857 ofs=0; 1853 1858 } 1854 return new Date(Date.UTC(year,_21 8,day,hour,min,sec,msec)-ofs);1855 }; 1856 MochiKit.DateTime.toISOTime=function(date,_22 0){1859 return new Date(Date.UTC(year,_21a,day,hour,min,sec,msec)-ofs); 1860 }; 1861 MochiKit.DateTime.toISOTime=function(date,_222){ 1857 1862 if(typeof (date)=="undefined"||date===null){ 1858 1863 return null; … … 1861 1866 var mm=date.getMinutes(); 1862 1867 var ss=date.getSeconds(); 1863 var lst=[((_22 0&&(hh<10))?"0"+hh:hh),((mm<10)?"0"+mm:mm),((ss<10)?"0"+ss:ss)];1868 var lst=[((_222&&(hh<10))?"0"+hh:hh),((mm<10)?"0"+mm:mm),((ss<10)?"0"+ss:ss)]; 1864 1869 return lst.join(":"); 1865 1870 }; 1866 MochiKit.DateTime.toISOTimestamp=function(date,_22 6){1871 MochiKit.DateTime.toISOTimestamp=function(date,_228){ 1867 1872 if(typeof (date)=="undefined"||date===null){ 1868 1873 return null; 1869 1874 } 1870 var sep=_22 6?"T":" ";1871 var foot=_22 6?"Z":"";1872 if(_22 6){1875 var sep=_228?"T":" "; 1876 var foot=_228?"Z":""; 1877 if(_228){ 1873 1878 date=new Date(date.getTime()+(date.getTimezoneOffset()*60000)); 1874 1879 } 1875 return MochiKit.DateTime.toISODate(date)+sep+MochiKit.DateTime.toISOTime(date,_22 6)+foot;1880 return MochiKit.DateTime.toISODate(date)+sep+MochiKit.DateTime.toISOTime(date,_228)+foot; 1876 1881 }; 1877 1882 MochiKit.DateTime.toISODate=function(date){ … … 1879 1884 return null; 1880 1885 } 1881 var _22 a=MochiKit.DateTime._padTwo;1882 return [date.getFullYear(),_22 a(date.getMonth()+1),_22a(date.getDate())].join("-");1886 var _22c=MochiKit.DateTime._padTwo; 1887 return [date.getFullYear(),_22c(date.getMonth()+1),_22c(date.getDate())].join("-"); 1883 1888 }; 1884 1889 MochiKit.DateTime.americanDate=function(d){ … … 1897 1902 return null; 1898 1903 } 1899 var _2 2f=MochiKit.DateTime._padTwo;1900 return [_2 2f(d.getMonth()+1),_22f(d.getDate()),d.getFullYear()].join("/");1904 var _231=MochiKit.DateTime._padTwo; 1905 return [_231(d.getMonth()+1),_231(d.getDate()),d.getFullYear()].join("/"); 1901 1906 }; 1902 1907 MochiKit.DateTime.toAmericanDate=function(d){ … … 1926 1931 MochiKit.Base._exportSymbols(this,MochiKit.DateTime); 1927 1932 }else{ 1928 (function(_23 4,_235){1933 (function(_236,_237){ 1929 1934 if((typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")||(MochiKit.__export__===false)){ 1930 var all=_23 5.EXPORT_TAGS[":all"];1935 var all=_237.EXPORT_TAGS[":all"]; 1931 1936 for(var i=0;i<all.length;i++){ 1932 _23 4[all[i]]=_235[all[i]];1937 _236[all[i]]=_237[all[i]]; 1933 1938 } 1934 1939 } … … 1944 1949 return this.__repr__(); 1945 1950 }; 1946 MochiKit.Format._numberFormatter=function(_23 8,_239,_23a,_23b,_23c,_23d,_23e,_23f,_240){1951 MochiKit.Format._numberFormatter=function(_23a,_23b,_23c,_23d,_23e,_23f,_240,_241,_242){ 1947 1952 return function(num){ 1948 1953 num=parseFloat(num); 1949 1954 if(typeof (num)=="undefined"||num===null||isNaN(num)){ 1950 return _23 8;1951 } 1952 var _24 2=_239;1953 var _24 3=_23a;1955 return _23a; 1956 } 1957 var _244=_23b; 1958 var _245=_23c; 1954 1959 if(num<0){ 1955 1960 num=-num; 1956 1961 }else{ 1957 _24 2=_242.replace(/-/,"");1962 _244=_244.replace(/-/,""); 1958 1963 } 1959 1964 var me=arguments.callee; 1960 var fmt=MochiKit.Format.formatLocale(_23 b);1961 if(_23 c){1965 var fmt=MochiKit.Format.formatLocale(_23d); 1966 if(_23e){ 1962 1967 num=num*100; 1963 _24 3=fmt.percent+_243;1964 } 1965 num=MochiKit.Format.roundToFixed(num,_23 d);1966 var _24 6=num.split(/\./);1967 var _24 7=_246[0];1968 var frac=(_24 6.length==1)?"":_246[1];1968 _245=fmt.percent+_245; 1969 } 1970 num=MochiKit.Format.roundToFixed(num,_23f); 1971 var _248=num.split(/\./); 1972 var _249=_248[0]; 1973 var frac=(_248.length==1)?"":_248[1]; 1969 1974 var res=""; 1970 while(_24 7.length<_23e){1971 _24 7="0"+_247;1972 } 1973 if(_2 3f){1974 while(_24 7.length>_23f){1975 var i=_24 7.length-_23f;1976 res=fmt.separator+_24 7.substring(i,_247.length)+res;1977 _24 7=_247.substring(0,i);1978 } 1979 } 1980 res=_24 7+res;1981 if(_23 d>0){1982 while(frac.length<_24 0){1975 while(_249.length<_240){ 1976 _249="0"+_249; 1977 } 1978 if(_241){ 1979 while(_249.length>_241){ 1980 var i=_249.length-_241; 1981 res=fmt.separator+_249.substring(i,_249.length)+res; 1982 _249=_249.substring(0,i); 1983 } 1984 } 1985 res=_249+res; 1986 if(_23f>0){ 1987 while(frac.length<_242){ 1983 1988 frac=frac+"0"; 1984 1989 } 1985 1990 res=res+fmt.decimal+frac; 1986 1991 } 1987 return _24 2+res+_243;1988 }; 1989 }; 1990 MochiKit.Format.numberFormatter=function(_24 b,_24c,_24d){1991 if(typeof (_24 c)=="undefined"){1992 _24 c="";1993 } 1994 var _2 4e=_24b.match(/((?:[0#]+,)?[0#]+)(?:\.([0#]+))?(%)?/);1995 if(!_2 4e){1992 return _244+res+_245; 1993 }; 1994 }; 1995 MochiKit.Format.numberFormatter=function(_24d,_24e,_24f){ 1996 if(typeof (_24e)=="undefined"){ 1997 _24e=""; 1998 } 1999 var _250=_24d.match(/((?:[0#]+,)?[0#]+)(?:\.([0#]+))?(%)?/); 2000 if(!_250){ 1996 2001 throw TypeError("Invalid pattern"); 1997 2002 } 1998 var _2 4f=_24b.substr(0,_24e.index);1999 var _25 0=_24b.substr(_24e.index+_24e[0].length);2000 if(_2 4f.search(/-/)==-1){2001 _2 4f=_24f+"-";2002 } 2003 var _25 1=_24e[1];2004 var frac=(typeof (_2 4e[2])=="string"&&_24e[2]!="")?_24e[2]:"";2005 var _25 3=(typeof (_24e[3])=="string"&&_24e[3]!="");2006 var tmp=_25 1.split(/,/);2007 var _25 5;2008 if(typeof (_24 d)=="undefined"){2009 _24 d="default";2003 var _251=_24d.substr(0,_250.index); 2004 var _252=_24d.substr(_250.index+_250[0].length); 2005 if(_251.search(/-/)==-1){ 2006 _251=_251+"-"; 2007 } 2008 var _253=_250[1]; 2009 var frac=(typeof (_250[2])=="string"&&_250[2]!="")?_250[2]:""; 2010 var _255=(typeof (_250[3])=="string"&&_250[3]!=""); 2011 var tmp=_253.split(/,/); 2012 var _257; 2013 if(typeof (_24f)=="undefined"){ 2014 _24f="default"; 2010 2015 } 2011 2016 if(tmp.length==1){ 2012 _25 5=null;2013 }else{ 2014 _25 5=tmp[1].length;2015 } 2016 var _25 6=_251.length-_251.replace(/0/g,"").length;2017 var _25 7=frac.length-frac.replace(/0/g,"").length;2018 var _25 8=frac.length;2019 var rval=MochiKit.Format._numberFormatter(_24 c,_24f,_250,_24d,_253,_258,_256,_255,_257);2017 _257=null; 2018 }else{ 2019 _257=tmp[1].length; 2020 } 2021 var _258=_253.length-_253.replace(/0/g,"").length; 2022 var _259=frac.length-frac.replace(/0/g,"").length; 2023 var _25a=frac.length; 2024 var rval=MochiKit.Format._numberFormatter(_24e,_251,_252,_24f,_255,_25a,_258,_257,_259); 2020 2025 var m=MochiKit.Base; 2021 2026 if(m){ … … 2028 2033 return rval; 2029 2034 }; 2030 MochiKit.Format.formatLocale=function(_25 d){2031 if(typeof (_25 d)=="undefined"||_25d===null){2032 _25 d="default";2033 } 2034 if(typeof (_25 d)=="string"){2035 var rval=MochiKit.Format.LOCALE[_25 d];2035 MochiKit.Format.formatLocale=function(_25f){ 2036 if(typeof (_25f)=="undefined"||_25f===null){ 2037 _25f="default"; 2038 } 2039 if(typeof (_25f)=="string"){ 2040 var rval=MochiKit.Format.LOCALE[_25f]; 2036 2041 if(typeof (rval)=="string"){ 2037 2042 rval=arguments.callee(rval); 2038 MochiKit.Format.LOCALE[_25 d]=rval;2043 MochiKit.Format.LOCALE[_25f]=rval; 2039 2044 } 2040 2045 return rval; 2041 2046 }else{ 2042 return _25 d;2043 } 2044 }; 2045 MochiKit.Format.twoDigitAverage=function(_2 5f,_260){2046 if(_26 0){2047 var res=_2 5f/_260;2047 return _25f; 2048 } 2049 }; 2050 MochiKit.Format.twoDigitAverage=function(_261,_262){ 2051 if(_262){ 2052 var res=_261/_262; 2048 2053 if(!isNaN(res)){ 2049 return MochiKit.Format.twoDigitFloat(_2 5f/_260);2054 return MochiKit.Format.twoDigitFloat(_261/_262); 2050 2055 } 2051 2056 } 2052 2057 return "0"; 2053 2058 }; 2054 MochiKit.Format.twoDigitFloat=function(_26 2){2055 var sign=(_26 2<0?"-":"");2056 var s=Math.floor(Math.abs(_26 2)*100).toString();2059 MochiKit.Format.twoDigitFloat=function(_264){ 2060 var sign=(_264<0?"-":""); 2061 var s=Math.floor(Math.abs(_264)*100).toString(); 2057 2062 if(s=="0"){ 2058 2063 return s; … … 2079 2084 } 2080 2085 }; 2081 MochiKit.Format.lstrip=function(str,_26 8){2086 MochiKit.Format.lstrip=function(str,_26a){ 2082 2087 str=str+""; 2083 2088 if(typeof (str)!="string"){ 2084 2089 return null; 2085 2090 } 2086 if(!_26 8){2091 if(!_26a){ 2087 2092 return str.replace(/^\s+/,""); 2088 2093 }else{ 2089 return str.replace(new RegExp("^["+_26 8+"]+"),"");2090 } 2091 }; 2092 MochiKit.Format.rstrip=function(str,_26 a){2094 return str.replace(new RegExp("^["+_26a+"]+"),""); 2095 } 2096 }; 2097 MochiKit.Format.rstrip=function(str,_26c){ 2093 2098 str=str+""; 2094 2099 if(typeof (str)!="string"){ 2095 2100 return null; 2096 2101 } 2097 if(!_26 a){2102 if(!_26c){ 2098 2103 return str.replace(/\s+$/,""); 2099 2104 }else{ 2100 return str.replace(new RegExp("["+_26 a+"]+$"),"");2101 } 2102 }; 2103 MochiKit.Format.strip=function(str,_26 c){2105 return str.replace(new RegExp("["+_26c+"]+$"),""); 2106 } 2107 }; 2108 MochiKit.Format.strip=function(str,_26e){ 2104 2109 var self=MochiKit.Format; 2105 return self.rstrip(self.lstrip(str,_26 c),_26c);2106 }; 2107 MochiKit.Format.truncToFixed=function(_2 6e,_26f){2108 _2 6e=Math.floor(_26e*Math.pow(10,_26f));2109 var res=(_2 6e*Math.pow(10,-_26f)).toFixed(_26f);2110 return self.rstrip(self.lstrip(str,_26e),_26e); 2111 }; 2112 MochiKit.Format.truncToFixed=function(_270,_271){ 2113 _270=Math.floor(_270*Math.pow(10,_271)); 2114 var res=(_270*Math.pow(10,-_271)).toFixed(_271); 2110 2115 if(res.charAt(0)=="."){ 2111 2116 res="0"+res; … … 2113 2118 return res; 2114 2119 }; 2115 MochiKit.Format.roundToFixed=function(_27 1,_272){2116 return MochiKit.Format.truncToFixed(_27 1+0.5*Math.pow(10,-_272),_272);2117 }; 2118 MochiKit.Format.percentFormat=function(_27 3){2119 return MochiKit.Format.twoDigitFloat(100*_27 3)+"%";2120 MochiKit.Format.roundToFixed=function(_273,_274){ 2121 return MochiKit.Format.truncToFixed(_273+0.5*Math.pow(10,-_274),_274); 2122 }; 2123 MochiKit.Format.percentFormat=function(_275){ 2124 return MochiKit.Format.twoDigitFloat(100*_275)+"%"; 2120 2125 }; 2121 2126 MochiKit.Format.EXPORT=["truncToFixed","roundToFixed","numberFormatter","formatLocale","twoDigitAverage","twoDigitFloat","percentFormat","lstrip","rstrip","strip"]; … … 2150 2155 MochiKit.Base._exportSymbols(this,MochiKit.Format); 2151 2156 }else{ 2152 (function(_27 8,_279){2157 (function(_27a,_27b){ 2153 2158 if((typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")||(MochiKit.__export__===false)){ 2154 var all=_27 9.EXPORT_TAGS[":all"];2159 var all=_27b.EXPORT_TAGS[":all"]; 2155 2160 for(var i=0;i<all.length;i++){ 2156 _27 8[all[i]]=_279[all[i]];2161 _27a[all[i]]=_27b[all[i]]; 2157 2162 } 2158 2163 } … … 2168 2173 return this.__repr__(); 2169 2174 }; 2170 MochiKit.Async.Deferred=function(_27 c){2175 MochiKit.Async.Deferred=function(_27e){ 2171 2176 this.chain=[]; 2172 2177 this.id=this._nextId(); … … 2174 2179 this.paused=0; 2175 2180 this.results=[null,null]; 2176 this.canceller=_27 c;2181 this.canceller=_27e; 2177 2182 this.silentlyCancelled=false; 2178 2183 this.chained=false; 2179 2184 }; 2180 2185 MochiKit.Async.Deferred.prototype={repr:function(){ 2181 var _27 d;2186 var _27f; 2182 2187 if(this.fired==-1){ 2183 _27 d="unfired";2188 _27f="unfired"; 2184 2189 }else{ 2185 2190 if(this.fired===0){ 2186 _27 d="success";2187 }else{ 2188 _27 d="error";2189 } 2190 } 2191 return "Deferred("+this.id+", "+_27 d+")";2191 _27f="success"; 2192 }else{ 2193 _27f="error"; 2194 } 2195 } 2196 return "Deferred("+this.id+", "+_27f+")"; 2192 2197 },toString:MochiKit.Base.forwardCall("repr"),_nextId:MochiKit.Base.counter(),cancel:function(){ 2193 2198 var self=MochiKit.Async; … … 2259 2264 return this; 2260 2265 },_fire:function(){ 2261 var _28 8=this.chain;2262 var _28 9=this.fired;2263 var res=this.results[_28 9];2266 var _28a=this.chain; 2267 var _28b=this.fired; 2268 var res=this.results[_28b]; 2264 2269 var self=this; 2265 2270 var cb=null; 2266 while(_28 8.length>0&&this.paused===0){2267 var pair=_28 8.shift();2268 var f=pair[_28 9];2271 while(_28a.length>0&&this.paused===0){ 2272 var pair=_28a.shift(); 2273 var f=pair[_28b]; 2269 2274 if(f===null){ 2270 2275 continue; … … 2272 2277 try{ 2273 2278 res=f(res); 2274 _28 9=((res instanceof Error)?1:0);2279 _28b=((res instanceof Error)?1:0); 2275 2280 if(res instanceof MochiKit.Async.Deferred){ 2276 2281 cb=function(res){ … … 2285 2290 } 2286 2291 catch(err){ 2287 _28 9=1;2292 _28b=1; 2288 2293 if(!(err instanceof Error)){ 2289 2294 err=new MochiKit.Async.GenericError(err); … … 2292 2297 } 2293 2298 } 2294 this.fired=_28 9;2295 this.results[_28 9]=res;2299 this.fired=_28b; 2300 this.results[_28b]=res; 2296 2301 if(cb&&this.paused){ 2297 2302 res.addBoth(cb); … … 2301 2306 MochiKit.Base.update(MochiKit.Async,{evalJSONRequest:function(req){ 2302 2307 return MochiKit.Base.evalJSON(req.responseText); 2303 },succeed:function(_29 1){2308 },succeed:function(_293){ 2304 2309 var d=new MochiKit.Async.Deferred(); 2305 2310 d.callback.apply(d,arguments); 2306 2311 return d; 2307 },fail:function(_29 3){2312 },fail:function(_295){ 2308 2313 var d=new MochiKit.Async.Deferred(); 2309 2314 d.errback.apply(d,arguments); … … 2312 2317 var self=arguments.callee; 2313 2318 if(!self.XMLHttpRequest){ 2314 var _29 6=[function(){2319 var _298=[function(){ 2315 2320 return new XMLHttpRequest(); 2316 2321 },function(){ … … 2323 2328 throw new MochiKit.Async.BrowserComplianceError("Browser does not support XMLHttpRequest"); 2324 2329 }]; 2325 for(var i=0;i<_29 6.length;i++){2326 var func=_29 6[i];2330 for(var i=0;i<_298.length;i++){ 2331 var func=_298[i]; 2327 2332 try{ 2328 2333 self.XMLHttpRequest=func; … … 2347 2352 } 2348 2353 } 2349 var _29 b=null;2354 var _29d=null; 2350 2355 try{ 2351 _29 b=this.status;2352 if(!_29 b&&m.isNotEmpty(this.responseText)){2353 _29 b=304;2356 _29d=this.status; 2357 if(!_29d&&m.isNotEmpty(this.responseText)){ 2358 _29d=304; 2354 2359 } 2355 2360 } 2356 2361 catch(e){ 2357 2362 } 2358 if(_29 b==200||_29b==201||_29b==204||_29b==304||_29b==1223){2363 if(_29d==200||_29d==201||_29d==204||_29d==304||_29d==1223){ 2359 2364 d.callback(this); 2360 2365 }else{ … … 2379 2384 } 2380 2385 req.abort(); 2381 },sendXMLHttpRequest:function(req,_2 9f){2382 if(typeof (_2 9f)=="undefined"||_29f===null){2383 _2 9f="";2386 },sendXMLHttpRequest:function(req,_2a1){ 2387 if(typeof (_2a1)=="undefined"||_2a1===null){ 2388 _2a1=""; 2384 2389 } 2385 2390 var m=MochiKit.Base; … … 2388 2393 try{ 2389 2394 req.onreadystatechange=m.bind(self._xhr_onreadystatechange,req,d); 2390 req.send(_2 9f);2395 req.send(_2a1); 2391 2396 } 2392 2397 catch(e){ … … 2423 2428 req.setRequestHeader("X-Requested-With","XMLHttpRequest"); 2424 2429 if(opts.headers){ 2425 var _2a c=opts.headers;2426 if(!m.isArrayLike(_2a c)){2427 _2a c=m.items(_2ac);2428 } 2429 for(var i=0;i<_2a c.length;i++){2430 var _2 ae=_2ac[i];2431 var name=_2 ae[0];2432 var _2b 0=_2ae[1];2433 req.setRequestHeader(name,_2b 0);2430 var _2ae=opts.headers; 2431 if(!m.isArrayLike(_2ae)){ 2432 _2ae=m.items(_2ae); 2433 } 2434 for(var i=0;i<_2ae.length;i++){ 2435 var _2b0=_2ae[i]; 2436 var name=_2b0[0]; 2437 var _2b2=_2b0[1]; 2438 req.setRequestHeader(name,_2b2); 2434 2439 } 2435 2440 } … … 2454 2459 d=d.addCallback(self.evalJSONRequest); 2455 2460 return d; 2456 },wait:function(_2b 9,_2ba){2461 },wait:function(_2bb,_2bc){ 2457 2462 var d=new MochiKit.Async.Deferred(); 2458 2463 var m=MochiKit.Base; 2459 if(typeof (_2b a)!="undefined"){2464 if(typeof (_2bc)!="undefined"){ 2460 2465 d.addCallback(function(){ 2461 return _2b a;2466 return _2bc; 2462 2467 }); 2463 2468 } 2464 var _2b d=setTimeout(m.bind("callback",d),Math.floor(_2b9*1000));2469 var _2bf=setTimeout(m.bind("callback",d),Math.floor(_2bb*1000)); 2465 2470 d.canceller=function(){ 2466 2471 try{ 2467 clearTimeout(_2b d);2472 clearTimeout(_2bf); 2468 2473 } 2469 2474 catch(e){ … … 2471 2476 }; 2472 2477 return d; 2473 },callLater:function(_2 be,func){2478 },callLater:function(_2c0,func){ 2474 2479 var m=MochiKit.Base; 2475 var _2c 1=m.partial.apply(m,m.extend(null,arguments,1));2476 return MochiKit.Async.wait(_2 be).addCallback(function(res){2477 return _2c 1();2480 var _2c3=m.partial.apply(m,m.extend(null,arguments,1)); 2481 return MochiKit.Async.wait(_2c0).addCallback(function(res){ 2482 return _2c3(); 2478 2483 }); 2479 2484 }}); … … 2502 2507 } 2503 2508 },_nextId:MochiKit.Base.counter(),repr:function(){ 2504 var _2c 4;2509 var _2c6; 2505 2510 if(this.locked){ 2506 _2c 4="locked, "+this.waiting.length+" waiting";2507 }else{ 2508 _2c 4="unlocked";2509 } 2510 return "DeferredLock("+this.id+", "+_2c 4+")";2511 _2c6="locked, "+this.waiting.length+" waiting"; 2512 }else{ 2513 _2c6="unlocked"; 2514 } 2515 return "Defer
