| 10 | | (function(c){var b="opensocial_simple";if(window.mixi){opensocial.Person.Field.BLOOD_TYPE=window.mixi.PersonField.BLOOD_TYPE}var a={ajaxSettings:{url:undefined,success:function(){},data:undefined,METHOD:undefined,CONTENT_TYPE:undefined,AUTHORIZATION:undefined,GET_SUMMARIES:undefined,HEADERS:undefined,NUM_ENTRIES:undefined,POST_DATA:undefined,REFRESH_INTERVAL:undefined},person_field_set:{all_field_set:(function(){var d=[],e=opensocial.Person.Field;c.each(e,function(f){d.push(f)});return d})(),mixi_field_set:["ID","NAME","NICKNAME","PROFILE_URL","THUMBNAIL_URL","ADDRESSES","AGE","DATE_OF_BIRTH","GENDER","HAS_APP","BLOOD_TYPE"]}};a.get=function(d,f,h,e){if(c.isFunction(f)){h=f;f=null}var g={METHOD:"GET",url:d,success:h,CONTENT_TYPE:e};if(f){g.data=f}return a.ajax(g)};c.each(gadgets.io.ContentType,function(e,d){a["get"+e]=function(f,g,h){return a.get(f,g,h,e)}});a.post=function(d,f,h,e){if(c.isFunction(f)){h=f;f=null}var g={METHOD:"POST",url:d,success:h,CONTENT_TYPE:e};if(f){g.data=f}return a.ajax(g)};a.ajaxSetup=function(d){c.extend(a.ajaxSettings,d);return this};a.ajax=function(d){d=c.extend(true,d,c.extend(true,{},a.ajaxSettings,d));var f={};var e=gadgets.io.RequestParameters;(d.data&&(d.METHOD=="POST"))?f[e.POST_DATA]=c.param(d.data||{}):c.param(d.data||{})&&(d.url+="?"+c.param(d.data||{}));c.each([{obj:"AuthorizationType",req:"AUTHORIZATION"},{obj:"ContentType",req:"CONTENT_TYPE"},{obj:"MethodType",req:"METHOD"}],function(){var h=gadgets.io[this["obj"]][d[this["req"]]];if(h!==undefined){f[e[this["req"]]]=h}});var g=gadgets.io.RequestParameters;c.each(["GET_SUMMARIES","HEADERS","NUM_ENTRIES","REFRESH_INTERVAL"],function(){if(d[this]!==undefined){f[g[this]]=d[this]}});gadgets.io.makeRequest(d.url,function(h){d.success(h.data)},f);return this};a.getPerson=function(h,j){var g=opensocial;var i=g.IdSpec.PersonId;var f=g.newDataRequest();if(c.isFunction(h)){j=h;h=["PROFILE_URL"]}if(a.person_field_set[h]){h=a.person_field_set[h]}if(!c.isArray(h)){throw new Error("field is not array")}var e=c.map(h,function(k){return g.Person.Field[k]});c.each(["OWNER","VIEWER"],function(){var k=this+"";var l={};l[g.DataRequest.PeopleRequestFields.PROFILE_DETAILS]=e;f.add(f.newFetchPersonRequest(i[k],l),k)});var d={};f.send(function(k){if(k.hadError()){return}d.OWNER=k.get("OWNER").getData();d.VIEWER=k.get("VIEWER").getData();c.each(["OWNER","VIEWER"],function(){var l=this+"";var m={};c.each(h,function(){m[this]=d[l].getField(g.Person.Field[this]);if(this!="ADDRESSES"||!m[this]){return}m[this]=m[this][g.Address.Field.UNSTRUCTURED_ADDRESS]||m[this]["unstructured_address"]});d[l].fieldValue=m});if(c.isFunction(j)){j(d)}});return d};a.getPersons=a.getPeople=function(e,f,j){if(c.isFunction(f)){j=f;f={field:["PROFILE_URL"]}}if(!f.field){f.field=["PROFILE_URL"]}if(a.person_field_set[f.field]){f.field=a.person_field_set[f.field]}var h=opensocial;var g=h.newDataRequest();var d=(function(){var k={};k[h.IdSpec.Field.USER_ID]=e-0;return opensocial.newIdSpec(k)})();var i={};i[h.DataRequest.PeopleRequestFields.PROFILE_DETAILS]=c.map(f.field,function(k){return h.Person.Field[k]});g.add(g.newFetchPeopleRequest(d,i),"PEOPLE");g.send(function(l){if(!c.isFunction(j)){return}if(!l.hadError()){return j(l.get("PEOPLE").getData())}var k={errorMessage:c.isFunction(l.getErrorMessage)?l.getErrorMessage():"",errorCode:c.isFunction(l.getErrorCode)?l.getErrorCode():403,getId:function(){return e-0},getDisplayName:function(){return},getField:function(m){return({id:e-0})[m]}};k.asArray=function(){return[k]};k.each=function(m){m(k)};j(k)});return this};a.getPersonsAsync=a.getPeopleAsync=function(e,h,k){if(!e||!e.length){return k([])}if(c.isFunction(h)){k=h;h={timeout:10*1000,complate:undefined}}if(h.timeout===undefined){h.timeout=10*1000}var i=opensocial;if(!c.isArray(e)){e=[e]}var g={};c.each(e,function(){g[this]=1});users=[];c.each(g,function(l){users.push(l)});if(c.isFunction(h.complate)){var j=k;var d=users.length;var f=function(){h.complate();h.complate=function(){}};var j=k;k=function(){j.apply(this,arguments);if(!d--){f()}};setTimeout(f,h.timeout)}c.each(users,function(){a.getPeople(this,h,k)});return this};a.getPersonsSync=a.getPeopleSync=function(h,k,j){if(!h||!h.length){return j([])}if(c.isFunction(k)){j=k;k={field:["PROFILE_URL"]}}if(!k.field){k.field=["PROFILE_URL"]}if(a.person_field_set[k.field]){k.field=a.person_field_set[k.field]}var f=opensocial;if(!c.isArray(h)){h=[h]}var g={};users=[];c.each(h,function(){g[this]=1});c.each(g,function(m){users.push(m)});var l=[];var e={};e[f.DataRequest.PeopleRequestFields.PROFILE_DETAILS]=c.map(k.field,function(m){return f.Person.Field[m]});var i=f.newDataRequest();c.each(users,function(m,o){var n=(function(){var q={};q[f.IdSpec.Field.USER_ID]=o-0;return opensocial.newIdSpec(q)})();i.add(i.newFetchPeopleRequest(n,e),"PEOPLE-"+m)});i.send(function(n){if(!c.isFunction(j)){return}var m=[];c.each(users,function(o,q){var p=n.get("PEOPLE-"+o);m.push(p.hadError()?d(q,p):p.getData().asArray()[0])});j(m)});function d(o,n){var m={errorMessage:c.isFunction(n.getErrorMessage)?n.getErrorMessage():"",errorCode:c.isFunction(n.getErrorCode)?n.getErrorCode():403,getId:function(){return o-0},getDisplayName:function(){return},getField:function(p){return({id:o-0})[p]}};m.asArray=function(){return[m]};m.each=function(p){p(m)};return m}return this};a.requestShareApp=function(e){var d=opensocial;if(!c.isFunction(e)){e=function(){}}d.requestShareApp("VIEWER_FRIENDS",null,e);return this};a.getFriends=function(h){var k=c.isFunction(h)?h:h.callback;var j=opensocial;var g=j.newIdSpec({userId:h.userId||"VIEWER",groupId:"FRIENDS"});var d=j.DataRequest.PeopleRequestFields;var f={};if(h.max!==undefined){f[d.MAX]=h.max}h.first=h.first||0;if(h.first!==undefined){f[d.FIRST]=h.first}if(h.filter!==undefined){f[d.FILTER]=j.DataRequest.FilterType[h.filter.toUpperCase()]}h.field=h.field||["PROFILE_URL"];if(a.person_field_set[h.field]){h.field=a.person_field_set[h.field]}h.field=c.isArray(h.field)?h.field:[h.field];f[j.DataRequest.PeopleRequestFields.PROFILE_DETAILS]=c.map(h.field,function(l){return j.Person.Field[l]});var i=j.newDataRequest();i.add(i.newFetchPeopleRequest(g,f),"FRIENDS");var e={};i.send(function(l){if(l.hadError()){return(c.isFunction(h.hadError)?h.hadError(l):undefined)}e=l.get("FRIENDS").getData();var m=h.first+h.max;if(m<e.getTotalSize()){e.nextFriends=function(o){h.callback=o;h.first=m;a.getFriends(h)}}var n=h.first-h.max;if(n>=0){e.prevFriends=function(o){h.callback=o;h.first=n;a.getFriends(h)}}e.getFriends=function(p,o){h.callback=p;h.first=h.max*(o-0);a.getFriends(h)};e.getPageSize=function(){return Math.ceil(e.getTotalSize()/h.max)};e.getCurrentPage=function(){return Math.ceil(e.getOffset()/h.max)};if(c.isFunction(k)){k(e)}});return e};a.getOwnerFriends=function(f,d,e){return a.getFriends({callback:f,userId:"OWNER",max:d,first:e})};a.getViewerFriends=function(f,d,e){return a.getFriends({callback:f,userId:"VIEWER",max:d,first:e})};new function(){var d=opensocial.IdSpec.PersonId;a.getOwnerData=function(e){return a.getData(e,d.OWNER)};a.postOwnerData=function(e,f){throw new Error("security error")};a.getViewerData=function(e){return a.getData(e,d.VIEWER)};a.postViewerData=function(e,f){return a.postData(e,f,d.VIEWER)}};new function(){var d=function(i,h){var g=opensocial.newDataRequest();var e={};c.each(i,function(k,l){e[opensocial.IdSpec.Field[k]]=l});var f=opensocial.newIdSpec(e);var j={};j[opensocial.DataRequest.DataRequestFields.ESCAPE_TYPE]=opensocial.EscapeType.NONE;g.add(g.newFetchPersonAppDataRequest(f,b,j),b);g.add(g.newFetchPersonRequest(i.USER_ID),"viewer");g.send(function(k){if(k.hadError()){return(k.getErrorMessage()?undefined:h.call(this))}var l=k.get("viewer").getData();if(!l){return}h.apply(this,[k,l])});return g};a.getData=function(f,e){if(!c.isFunction(f)){throw new Error("callback is not function")}d({USER_ID:e},function(i,k){if(!c.isFunction(f)){return}if(!i||!k){return f({})}var h=i.get(b).getData();var g=h[k.getId()]||h[k.getId().replace(/\D/g,"")];try{if("string"===typeof g[b]){g[b]=gadgets.json.parse(decodeURIComponent(g[b]))}g=g[b][b]}catch(j){g={}}return f(g)});return this};a.getFriendsData=function(e,f){if(c.isFunction(e)){f=e;e="OWNER"}if(!c.isFunction(f)){throw new Error("callback is not function")}if(!e){e="OWNER"}d({USER_ID:opensocial.IdSpec.PersonId[e],GROUP_ID:"FRIENDS",NETWORK_DISTANCE:1},function(j,l){if(!arguments.length){return f({})}var i=j.get(b).getData();(i[l.getId()]||i[l.getId().replace(/\D/g,"")]||{}).is_viewer=true;var g={friends:[],VIEWER:l};for(var m in i){try{var h=gadgets.json.parse(unescape(i[m][b]))[b];h.OWNER_ID=m;g.friends.push(h)}catch(k){}}return f(g)});return this}};new function(){var f=opensocial;var e=function(g){return function(h){if(h.hadError()){return}if(c.isFunction(g)){g.apply(this,arguments)}}};var d=function(j,h){var g={};var i=f[h].Field;c.each(j,function(k,l){g[i[k]||k]=l});return g};a.postData=function(g,k,j){var h=f.newDataRequest();var i={};i[b]=g;h.add(h.newUpdatePersonAppDataRequest(j,b,encodeURIComponent(gadgets.json.stringify(i))));h.send(e(k));return this};a.postActivity=function(l,h,m){var g=f.CreateActivityPriority;var k={TITLE:l};if("string"!==typeof l){k=l}if(c.isFunction(h)){m=h;h={priority:"LOW"}}if("string"===typeof h){h={priority:h}}if(!h){h={priority:"LOW"}}if(c.isArray(h)){h={target:h,priority:"LOW"}}h.priority=g[h]||h.priority;if(!h.priority){h.priority="LOW"}var j=d(k,"Activity");if(!c.isArray(h.target)){h.target=h.target?[h.target]:[]}(function(){if(c.isArray(h.target)&&!h.target.length){return}if(!c.isArray(h.target)&&!h.target){return}j[mixi.ActivityField.RECIPIENTS]=(c.isArray(h.target)?h.target:[h.target])})();(function(){if(!h.media_item){return}var n=h.media_item;if(!c.isArray(n)){n=[n]}var o=[];c.each(n,function(){var q=this+"";var p=q.match(/gif$/i)?"image/gif":q.match(/jpe?g$/i)?"image/jpeg":q.match(/png$/i)?"image/png":"";if(!p){return}o.push(f.newMediaItem(p,q))});if(!o.length){return}j[f.Activity.Field.MEDIA_ITEMS]=o})();(function(){if(!h.app_params){return}var n={};n.appParams=h.app_params;if("object"===typeof h.app_params){n.appParams=gadgets.json.stringify(n.appParams)}var o=gadgets.io.encodeValues(n);j[f.Activity.Field.URL]="http://mixi.jp/run_appli.pl?id="+(gadgets.util.getUrlParameters()["app_id"])+"&"+o})();var i=f.newActivity(j);if(!c.isFunction(m)){m=function(){}}f.requestCreateActivity(i,h.priority,m);return this};a.postMessage=function(j,m,g,n){var h=f.Message.Type;var l={TITLE:m};if("string"!==typeof j){l=j;if(c.isFunction(m)){n=m}g=l.BODY;delete l.BODY;j=l.TARGET;delete l.TARGET}var k=d(l,"Message");var i=f.newMessage(g,k);if(!c.isFunction(n)){n=function(){}}f.requestSendMessage(j,i,n);return this}};a.getLocale=function(e){var d={};var i=c(e||".jQuery_opensocial_simple_locale").get(0).innerHTML.replace(/\/\*|\*\//g,"");if(!i){throw new Error("missing local value")}var h=(new gadgets.Prefs()).getLang();if(!(new RegExp('<Locale lang="'+h+'">')).test(i)){h=""}var f=i.match(new RegExp('<Locale lang="'+h+'">([\\s\\S]+?)</Locale>'));if(!f){f=i.match(new RegExp("<Locale>([\\s\\S]+?)</Locale>"))}if(!f){return{}}var g=f[1].match(/<msg\s+name="\w+">[\s\S]+?<\/msg>/gi);if(!g){return{}}c.each(g,function(){var j=this.match(/<msg\s+name="(\w+)">([\s\S]+?)<\/msg>/i);d[j[1]]=j[2]});return d};a.navigateTo=function(e,g,d){if(!gadgets.views.getSupportedViews){throw new Error('require <Require feature="views" />')}var f=gadgets.views.getSupportedViews();if(!f[e]){throw new Error("unsupportedViewName "+e)}gadgets.views.requestNavigateTo(f[e],g,d);return this};a.getParams=function(){if(!gadgets.views.getParams){throw new Error('require <Require feature="views" />')}return gadgets.views.getParams()};a.adjustHeight=function(){if(!gadgets.window){throw new Error('require <Require feature="dynamic-heigh" />')}return gadgets.window.adjustHeight.apply(gadgets.window,arguments)};c[b]=a;c[b.replace(/_([a-z])/g,function(){return arguments[1].toUpperCase()})]=a})(jQuery); |
| | 18 | (function(e){if(window.mixi)opensocial.Person.Field.BLOOD_TYPE=window.mixi.PersonField.BLOOD_TYPE;var i={ajaxSettings:{url:undefined,success:function(){},data:undefined,METHOD:undefined,CONTENT_TYPE:undefined,AUTHORIZATION:undefined,GET_SUMMARIES:undefined,HEADERS:undefined,NUM_ENTRIES:undefined,POST_DATA:undefined,REFRESH_INTERVAL:undefined,BASIC_AUTHORIZATION:undefined},person_field_set:{all_field_set:function(){var a=[];e.each(opensocial.Person.Field,function(b){a.push(b)});return a}(),mixi_field_set:["ID", "NAME","NICKNAME","PROFILE_URL","THUMBNAIL_URL","ADDRESSES","AGE","DATE_OF_BIRTH","GENDER","HAS_APP","BLOOD_TYPE"]}};i.get=function(a,b,d,g){if(e.isFunction(b)){d=b;b=null}a={METHOD:"GET",url:a,success:d,CONTENT_TYPE:g};if(b)a.data=b;return i.ajax(a)};e.each(gadgets.io.ContentType,function(a){i["get"+a]=function(b,d,g){return i.get(b,d,g,a)}});i.post=function(a,b,d,g){if(e.isFunction(b)){d=b;b=null}a={METHOD:"POST",url:a,success:d,CONTENT_TYPE:g};if(b)a.data=b;return i.ajax(a)};i.ajaxSetup=function(a){e.extend(i.ajaxSettings, a);return this};i.ajax=function(a){a=e.extend(true,a,e.extend(true,{},i.ajaxSettings,a));var b={},d=gadgets.io.RequestParameters;a.data&&a.METHOD=="POST"?b[d.POST_DATA]=e.param(a.data||{}):e.param(a.data||{})&&(a.url+="?"+e.param(a.data||{}));e.each([{obj:"AuthorizationType",req:"AUTHORIZATION"},{obj:"ContentType",req:"CONTENT_TYPE"},{obj:"MethodType",req:"METHOD"}],function(){var c=gadgets.io[this.obj][a[this.req]];if(c!==undefined)b[d[this.req]]=c});var g=gadgets.io.RequestParameters;e.each(["GET_SUMMARIES", "HEADERS","NUM_ENTRIES","REFRESH_INTERVAL"],function(){if(a[this]!==undefined)b[g[this]]=a[this]});if(a.BASIC_AUTHORIZATION)b[g.HEADERS]=e.extend(b[g.HEADERS]||{},{Authorization:"Basic "+Base64.encode(a.BASIC_AUTHORIZATION)});gadgets.io.makeRequest(a.url,function(c){a.success(c.data)},b);return this};i.getPerson=function(a,b){var d=opensocial,g=d.IdSpec.PersonId,c=d.newDataRequest();if(e.isFunction(a)){b=a;a=["PROFILE_URL"]}if(i.person_field_set[a])a=i.person_field_set[a];if(!e.isArray(a))throw Error("field is not array"); var k=e.map(a,function(h){return d.Person.Field[h]});e.each(["OWNER","VIEWER"],function(){var h=this+"",l={};l[d.DataRequest.PeopleRequestFields.PROFILE_DETAILS]=k;c.add(c.newFetchPersonRequest(g[h],l),h)});var j={};c.send(function(h){if(!h.hadError()){j.OWNER=h.get("OWNER").getData();j.VIEWER=h.get("VIEWER").getData();e.each(["OWNER","VIEWER"],function(){var l=this+"",m={};e.each(a,function(){m[this]=j[l].getField(d.Person.Field[this]);this!="ADDRESSES"||!m[this]||(m[this]=m[this][d.Address.Field.UNSTRUCTURED_ADDRESS]|| m[this].unstructured_address)});j[l].fieldValue=m});e.isFunction(b)&&b(j)}});return j};i.getPersons=i.getPeople=function(a,b,d){if(e.isFunction(b)){d=b;b={field:["PROFILE_URL"]}}if(!b.field)b.field=["PROFILE_URL"];if(i.person_field_set[b.field])b.field=i.person_field_set[b.field];var g=opensocial,c=g.newDataRequest(),k=function(){var h={};h[g.IdSpec.Field.USER_ID]=a-0;return opensocial.newIdSpec(h)}(),j={};j[g.DataRequest.PeopleRequestFields.PROFILE_DETAILS]=e.map(b.field,function(h){return g.Person.Field[h]}); c.add(c.newFetchPeopleRequest(k,j),"PEOPLE");c.send(function(h){if(e.isFunction(d)){if(!h.hadError())return d(h.get("PEOPLE").getData());var l={errorMessage:e.isFunction(h.getErrorMessage)?h.getErrorMessage():"",errorCode:e.isFunction(h.getErrorCode)?h.getErrorCode():403,getId:function(){return a-0},getDisplayName:function(){},getField:function(m){return{id:a-0}[m]}};l.asArray=function(){return[l]};l.each=function(m){m(l)};d(l)}});return this};i.getPersonsAsync=i.getPeopleAsync=function(a,b,d){if(!a|| !a.length)return d([]);if(e.isFunction(b)){d=b;b={timeout:1E4,complate:undefined}}if(b.timeout===undefined)b.timeout=1E4;e.isArray(a)||(a=[a]);var g={};e.each(a,function(){g[this]=1});users=[];e.each(g,function(h){users.push(h)});if(e.isFunction(b.complate)){var c=d,k=users.length,j=function(){b.complate();b.complate=function(){}};c=d;d=function(){c.apply(this,arguments);k--||j()};setTimeout(j,b.timeout)}e.each(users,function(){i.getPeople(this,b,d)});return this};i.getPersonsSync=i.getPeopleSync= function(a,b,d){function g(l,m){var n={errorMessage:e.isFunction(m.getErrorMessage)?m.getErrorMessage():"",errorCode:e.isFunction(m.getErrorCode)?m.getErrorCode():403,getId:function(){return l-0},getDisplayName:function(){},getField:function(p){return{id:l-0}[p]}};n.asArray=function(){return[n]};n.each=function(p){p(n)};return n}if(!a||!a.length)return d([]);if(e.isFunction(b)){d=b;b={field:["PROFILE_URL"]}}if(!b.field)b.field=["PROFILE_URL"];if(i.person_field_set[b.field])b.field=i.person_field_set[b.field]; var c=opensocial;e.isArray(a)||(a=[a]);var k={};users=[];e.each(a,function(){k[this]=1});e.each(k,function(l){users.push(l)});var j={};j[c.DataRequest.PeopleRequestFields.PROFILE_DETAILS]=e.map(b.field,function(l){return c.Person.Field[l]});var h=c.newDataRequest();e.each(users,function(l,m){var n=function(){var p={};p[c.IdSpec.Field.USER_ID]=m-0;return opensocial.newIdSpec(p)}();h.add(h.newFetchPeopleRequest(n,j),"PEOPLE-"+l)});h.send(function(l){if(e.isFunction(d)){var m=[];e.each(users,function(n, p){var q=l.get("PEOPLE-"+n);m.push(q.hadError()?g(p,q):q.getData().asArray()[0])});d(m)}});return this};i.requestShareApp=function(a){var b=opensocial;e.isFunction(a)||(a=function(){});b.requestShareApp("VIEWER_FRIENDS",null,a);return this};i.getFriends=function(a){var b=e.isFunction(a)?a:a.callback,d=opensocial,g=d.newIdSpec({userId:a.userId||"VIEWER",groupId:"FRIENDS"}),c=d.DataRequest.PeopleRequestFields,k={};if(a.max!==undefined)k[c.MAX]=a.max;a.first=a.first||0;if(a.first!==undefined)k[c.FIRST]= a.first;if(a.filter!==undefined)k[c.FILTER]=d.DataRequest.FilterType[a.filter.toUpperCase()];a.field=a.field||["PROFILE_URL"];if(i.person_field_set[a.field])a.field=i.person_field_set[a.field];a.field=e.isArray(a.field)?a.field:[a.field];k[d.DataRequest.PeopleRequestFields.PROFILE_DETAILS]=e.map(a.field,function(h){return d.Person.Field[h]});c=d.newDataRequest();c.add(c.newFetchPeopleRequest(g,k),"FRIENDS");var j={};c.send(function(h){if(h.hadError())return e.isFunction(a.hadError)?a.hadError(h): undefined;j=h.get("FRIENDS").getData();var l=a.first+a.max;if(l<j.getTotalSize())j.nextFriends=function(n){a.callback=n;a.first=l;i.getFriends(a)};var m=a.first-a.max;if(m>=0)j.prevFriends=function(n){a.callback=n;a.first=m;i.getFriends(a)};j.getFriends=function(n,p){a.callback=n;a.first=a.max*(p-0);i.getFriends(a)};j.getPageSize=function(){return Math.ceil(j.getTotalSize()/a.max)};j.getCurrentPage=function(){return Math.ceil(j.getOffset()/a.max)};e.isFunction(b)&&b(j)});return j};i.getOwnerFriends= function(a,b,d){return i.getFriends({callback:a,userId:"OWNER",max:b,first:d})};i.getViewerFriends=function(a,b,d){return i.getFriends({callback:a,userId:"VIEWER",max:b,first:d})};new (function(){var a=opensocial.IdSpec.PersonId;i.getOwnerData=function(b){return i.getData(b,a.OWNER)};i.postOwnerData=function(){throw Error("security error");};i.getViewerData=function(b){return i.getData(b,a.VIEWER)};i.postViewerData=function(b,d){return i.postData(b,d,a.VIEWER)}});new (function(){var a=function(b, d){var g=opensocial.newDataRequest(),c={};e.each(b,function(h,l){c[opensocial.IdSpec.Field[h]]=l});var k=opensocial.newIdSpec(c),j={};j[opensocial.DataRequest.DataRequestFields.ESCAPE_TYPE]=opensocial.EscapeType.NONE;g.add(g.newFetchPersonAppDataRequest(k,"opensocial_simple",j),"opensocial_simple");g.add(g.newFetchPersonRequest(b.USER_ID),"viewer");g.send(function(h){if(h.hadError())return h.getErrorMessage()?undefined:d.call(this);var l=h.get("viewer").getData();l&&d.apply(this,[h,l])});return g}; i.getData=function(b,d){if(!e.isFunction(b))throw Error("callback is not function");a({USER_ID:d},function(g,c){if(e.isFunction(b)){if(!g||!c)return b({});var k=g.get("opensocial_simple").getData();k=k[c.getId()]||k[c.getId().replace(/\D/g,"")];try{if("string"===typeof k.opensocial_simple)k.opensocial_simple=gadgets.json.parse(decodeURIComponent(k.opensocial_simple));k=k.opensocial_simple.opensocial_simple}catch(j){k={}}return b(k)}});return this};i.getFriendsData=function(b,d){if(e.isFunction(b)){d= b;b="OWNER"}if(!e.isFunction(d))throw Error("callback is not function");b||(b="OWNER");a({USER_ID:opensocial.IdSpec.PersonId[b],GROUP_ID:"FRIENDS",NETWORK_DISTANCE:1},function(g,c){if(!arguments.length)return d({});var k=g.get("opensocial_simple").getData();(k[c.getId()]||k[c.getId().replace(/\D/g,"")]||{}).is_viewer=true;var j={friends:[],VIEWER:c};for(var h in k)try{var l=gadgets.json.parse(unescape(k[h].opensocial_simple)).opensocial_simple;l.OWNER_ID=h;j.friends.push(l)}catch(m){}return d(j)}); return this}});new (function(){var a=opensocial,b=function(g){return function(c){c.hadError()||e.isFunction(g)&&g.apply(this,arguments)}},d=function(g,c){var k={},j=a[c].Field;e.each(g,function(h,l){k[j[h]||h]=l});return k};i.postData=function(g,c,k){var j=a.newDataRequest(),h={};h.opensocial_simple=g;j.add(j.newUpdatePersonAppDataRequest(k,"opensocial_simple",encodeURIComponent(gadgets.json.stringify(h))));j.send(b(c));return this};i.postActivity=function(g,c,k){var j=a.CreateActivityPriority,h= {TITLE:g};if("string"!==typeof g)h=g;if(e.isFunction(c)){k=c;c={priority:"LOW"}}if("string"===typeof c)c={priority:c};c||(c={priority:"LOW"});if(e.isArray(c))c={target:c,priority:"LOW"};c.priority=j[c]||c.priority;if(!c.priority)c.priority="LOW";var l=d(h,"Activity");if(!e.isArray(c.target))c.target=c.target?[c.target]:[];if(!(e.isArray(c.target)&&!c.target.length))if(e.isArray(c.target)||c.target)l[mixi.ActivityField.RECIPIENTS]=e.isArray(c.target)?c.target:[c.target];(function(){if(c.media_item){var m= c.media_item;e.isArray(m)||(m=[m]);var n=[];e.each(m,function(){var p=this+"",q=p.match(/gif$/i)?"image/gif":p.match(/jpe?g$/i)?"image/jpeg":p.match(/png$/i)?"image/png":"";q&&n.push(a.newMediaItem(q,p))});if(n.length)l[a.Activity.Field.MEDIA_ITEMS]=n}})();(function(){if(c.app_params){var m={};m.appParams=c.app_params;if("object"===typeof c.app_params)m.appParams=gadgets.json.stringify(m.appParams);m=gadgets.io.encodeValues(m);l[a.Activity.Field.URL]="http://mixi.jp/run_appli.pl?id="+gadgets.util.getUrlParameters().app_id+ "&"+m}})();g=a.newActivity(l);e.isFunction(k)||(k=function(){});a.requestCreateActivity(g,c.priority,k);return this};i.postMessage=function(g,c,k,j){var h={TITLE:c};if("string"!==typeof g){h=g;if(e.isFunction(c))j=c;k=h.BODY;delete h.BODY;g=h.TARGET;delete h.TARGET}c=d(h,"Message");k=a.newMessage(k,c);e.isFunction(j)||(j=function(){});a.requestSendMessage(g,k,j);return this}});i.getLocale=function(a){var b={};a=e(a||".jQuery_opensocial_simple_locale").get(0).innerHTML.replace(/\/\*|\*\//g,"");if(!a)throw Error("missing local value"); var d=(new gadgets.Prefs).getLang();RegExp('<Locale lang="'+d+'">').test(a)||(d="");(d=a.match(RegExp('<Locale lang="'+d+'">([\\s\\S]+?)</Locale>')))||(d=a.match(/<Locale>([\s\S]+?)<\/Locale>/));if(!d)return{};a=d[1].match(/<msg\s+name="\w+">[\s\S]+?<\/msg>/gi);if(!a)return{};e.each(a,function(){var g=this.match(/<msg\s+name="(\w+)">([\s\S]+?)<\/msg>/i);b[g[1]]=g[2]});return b};i.navigateTo=function(a,b,d){if(!gadgets.views.getSupportedViews)throw Error('require <Require feature="views" />');var g= gadgets.views.getSupportedViews();if(!g[a])throw Error("unsupportedViewName "+a);gadgets.views.requestNavigateTo(g[a],b,d);return this};i.getParams=function(){if(!gadgets.views.getParams)throw Error('require <Require feature="views" />');return gadgets.views.getParams()};i.adjustHeight=function(){if(!gadgets.window)throw Error('require <Require feature="dynamic-heigh" />');return gadgets.window.adjustHeight.apply(gadgets.window,arguments)};e.opensocial_simple=i;e["opensocial_simple".replace(/_([a-z])/g, function(a,b){return b.toUpperCase()})]=i;(function(){var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var b=function(f){for(var o={},r=0,t=f.length;r<t;r++)o[f.charAt(r)]=r;return o}(a),d=function(f){f=f.charCodeAt(0)<<16|f.charCodeAt(1)<<8|f.charCodeAt(2);return a.charAt(f>>>18)+a.charAt(f>>>12&63)+a.charAt(f>>>6&63)+a.charAt(f&63)},g=function(f){if(f.match(/[^\x00-\xFF]/))throw"unsupported character found";for(var o=0;f.length%3;){f+="\u0000";o++}f=f.replace(/[\x00-\xFF]{3}/g, d);if(!o)return f;for(f=f.substr(0,f.length-o);o--;)f+="=";return f},c=window.btoa||g,k=function(f){f=b[f.charAt(0)]<<18|b[f.charAt(1)]<<12|b[f.charAt(2)]<<6|b[f.charAt(3)];return String.fromCharCode(f>>16)+String.fromCharCode(f>>8&255)+String.fromCharCode(f&255)},j=function(f){f=f.replace(/[^A-Za-z0-9\+\/]/g,"");for(var o=0;f.length%4;){f+="A";o++}f=f.replace(/[A-Za-z0-9\+\/]{4}/g,k);f.length-=[0,0,2,1][o];return f},h=window.atob||j,l=/[^\x00-\xFF]/g,m=function(f){f=f.charCodeAt(0);return f<2048? String.fromCharCode(192|f>>>6)+String.fromCharCode(128|f&63):String.fromCharCode(224|f>>>12&15)+String.fromCharCode(128|f>>>6&63)+String.fromCharCode(128|f&63)},n=function(f){return f.replace(l,m)},p=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,q=function(f){var o=f.charCodeAt(0),r=f.charCodeAt(1);if(o<224)return String.fromCharCode((o&31)<<6|r&63);else{f=f.charCodeAt(2);return String.fromCharCode((o&15)<<12|(r&63)<<6|f&63)}},s=function(f){return f.replace(p,q)};this.Base64|| (Base64={fromBase64:j,toBase64:g,atob:h,btoa:c,utob:n,btou:s,encode:function(f){return c(n(f))},encodeURI:function(f){return c(n(f)).replace(/[+\/]/g,function(o){return o=="+"?"-":"_"}).replace(/=+$/,"")},decode:function(f){return s(h(f.replace(/[-_]/g,function(o){return o=="-"?"+":"/"})))}})})()})(jQuery); |