/Frameworks/AppKit/browser.platform/CPCookie.j

http://github.com/polymar/polish · Unknown · 54 lines · 54 code · 0 blank · 0 comment · 0 complexity · ba4b04138c28e8e6515168c76b3f46ee MD5 · raw file

  1. I;21;Foundation/CPObject.jI;21;Foundation/CPString.jc;1385;
  2. var _1=objj_allocateClassPair(CPObject,"CPCookie"),_2=_1.isa;
  3. class_addIvars(_1,[new objj_ivar("_cookieName"),new objj_ivar("_cookieValue"),new objj_ivar("_expires")]);
  4. objj_registerClassPair(_1);
  5. objj_addClassForBundle(_1,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  6. class_addMethods(_1,[new objj_method(sel_getUid("initWithName:"),function(_3,_4,_5){
  7. with(_3){
  8. _3=objj_msgSendSuper({receiver:_3,super_class:objj_getClass("CPObject")},"init");
  9. _cookieName=_5;
  10. _cookieValue=objj_msgSend(_3,"_readCookieValue");
  11. return _3;
  12. }
  13. }),new objj_method(sel_getUid("value"),function(_6,_7){
  14. with(_6){
  15. return _cookieValue;
  16. }
  17. }),new objj_method(sel_getUid("name"),function(_8,_9){
  18. with(_8){
  19. return _cookieName;
  20. }
  21. }),new objj_method(sel_getUid("expires"),function(_a,_b){
  22. with(_a){
  23. return _expires;
  24. }
  25. }),new objj_method(sel_getUid("setValue:expires:domain:"),function(_c,_d,_e,_f,_10){
  26. with(_c){
  27. if(_f){
  28. var _11="; expires="+_f.toGMTString();
  29. }else{
  30. var _11="";
  31. }
  32. if(_10){
  33. _10="; domain="+_10;
  34. }else{
  35. _10="";
  36. }
  37. document.cookie=_cookieName+"="+_e+_11+"; path=/"+_10;
  38. }
  39. }),new objj_method(sel_getUid("_readCookieValue"),function(_12,_13){
  40. with(_12){
  41. var _14=_cookieName+"=";
  42. var ca=document.cookie.split(";");
  43. for(var i=0;i<ca.length;i++){
  44. var c=ca[i];
  45. while(c.charAt(0)==" "){
  46. c=c.substring(1,c.length);
  47. }
  48. if(c.indexOf(_14)==0){
  49. return c.substring(_14.length,c.length);
  50. }
  51. }
  52. return "";
  53. }
  54. })]);