Changeset 36771

Show
Ignore:
Timestamp:
02/16/10 15:39:54 (4 years ago)
Author:
kyo_ago
Message:

ver up

Location:
lang/javascript/jQuery.opensocial_simple
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/jQuery.opensocial_simple/jquery.opensocial_simple.js

    r36770 r36771  
    44 * Dual licensed under the MIT <http://www.opensource.org/licenses/mit-license.php> 
    55 * and GPL <http://www.opensource.org/licenses/gpl-license.php> licenses. 
    6  * Date: 2010-02-03 
     6 * Date: 2010-02-16 
    77 * @author kyo_ago <http://tech.kayac.com/archive/jquery-opensocial-simple.html> 
    8  * @version 1.4.5 
     8 * @version 1.4.6 
    99 */ 
    1010;(function ($) { 
  • lang/javascript/jQuery.opensocial_simple/jquery.opensocial_simple.min.js

    r36603 r36771  
    44 * Dual licensed under the MIT <http://www.opensource.org/licenses/mit-license.php> 
    55 * and GPL <http://www.opensource.org/licenses/gpl-license.php> licenses. 
    6  * Date: 2010-02-03 
     6 * Date: 2010-02-16 
    77 * @author kyo_ago <http://tech.kayac.com/archive/jquery-opensocial-simple.html> 
    8  * @version 1.4.5 
     8 * @version 1.4.6 
    99 */ 
    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 g=gadgets.io[this["obj"]][d[this["req"]]];if(g!==undefined){f[e[this["req"]]]=g}});if(d.REFRESH_INTERVAL!==undefined){f[gadgets.io.RequestParameters.REFRESH_INTERVAL]=d.REFRESH_INTERVAL}c.each(["GET_SUMMARIES","HEADERS","NUM_ENTRIES"],function(){if(d[this]!==undefined){f[this]=s[this]}});gadgets.io.makeRequest(d.url,function(g){d.success(g.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;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 0},getDisplayName:function(){return""},getField:function(){return""}};k.asArray=function(){return[k]};k.each=function(m){m(k)};j(k)});return this};a.getPersonsAsync=a.getPeopleAsync=function(g,l,k){if(c.isFunction(l)){k=l;l={timeout:10*1000,complate:undefined}}if(l.timeout===undefined){l.timeout=10*1000}var e=opensocial;var j=e.newDataRequest();if(!c.isArray(g)){g=[g]}var f={};c.each(g,function(){f[this]=1});users=[];c.each(f,function(m){users.push(m)});if(c.isFunction(l.complate)){var d=k;var i=users.length;var h=function(){l.complate();l.complate=function(){}};var d=k;k=function(){d.apply(this,arguments);if(!i--){h()}};setTimeout(h,l.timeout)}c.each(users,function(){a.getPeople(this-0,l,k)});return this};a.getPersonsSync=a.getPeopleSync=function(f,h,k){if(c.isFunction(h)){k=h;h={timeout:10*1000}}if(h.timeout==undefined){h.timeout=10*1000}var j=opensocial;var i=j.newDataRequest();if(!c.isArray(f)){f=[f]}var g={};users=[];c.each(f,function(){g[this]=1});c.each(g,function(l){users.push(l)});var e=[];if(h.timeout){setTimeout(function(){k(e);k=function(){}},h.timeout)}var d=k;k=function(){var l={};c.each(e,function(){l[this.getId()]=this});d(c.map(users,function(m){return l[m]}))};c.each(users,function(){a.getPeople(this-0,h,function(l){e.push(l.asArray()[0]);if(users.length!==e.length){return}k(e);k=function(){}})});return this};a.requestShareApp=function(e){var d=opensocial;d.requestShareApp("VIEWER_FRIENDS",null,function(f){if(c.isFunction(e)){return e(f)}});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"];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:"HIGH"}}if("string"===typeof h){h={priority:h}}if(!h){h={priority:"HIGH"}}if(c.isArray(h)){h={target:h,priority:"HIGH"}}h.priority=g[h]||h.priority;if(!h.priority){h.priority="HIGH"}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);f.requestCreateActivity(i,h.priority,e(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);f.requestSendMessage(j,i,e(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("object"!=typeof g){d=g;g=undefined}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); 
     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 g=gadgets.io[this["obj"]][d[this["req"]]];if(g!==undefined){f[e[this["req"]]]=g}});if(d.REFRESH_INTERVAL!==undefined){f[gadgets.io.RequestParameters.REFRESH_INTERVAL]=d.REFRESH_INTERVAL}c.each(["GET_SUMMARIES","HEADERS","NUM_ENTRIES"],function(){if(d[this]!==undefined){f[this]=s[this]}});gadgets.io.makeRequest(d.url,function(g){d.success(g.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 0},getDisplayName:function(){return""},getField:function(){return""}};k.asArray=function(){return[k]};k.each=function(m){m(k)};j(k)});return this};a.getPersonsAsync=a.getPeopleAsync=function(g,l,k){if(c.isFunction(l)){k=l;l={timeout:10*1000,complate:undefined}}if(l.timeout===undefined){l.timeout=10*1000}var e=opensocial;var j=e.newDataRequest();if(!c.isArray(g)){g=[g]}var f={};c.each(g,function(){f[this]=1});users=[];c.each(f,function(m){users.push(m)});if(c.isFunction(l.complate)){var d=k;var i=users.length;var h=function(){l.complate();l.complate=function(){}};var d=k;k=function(){d.apply(this,arguments);if(!i--){h()}};setTimeout(h,l.timeout)}c.each(users,function(){a.getPeople(this-0,l,k)});return this};a.getPersonsSync=a.getPeopleSync=function(f,h,k){if(c.isFunction(h)){k=h;h={timeout:10*1000}}if(h.timeout==undefined){h.timeout=10*1000}var j=opensocial;var i=j.newDataRequest();if(!c.isArray(f)){f=[f]}var g={};users=[];c.each(f,function(){g[this]=1});c.each(g,function(l){users.push(l)});var e=[];if(h.timeout){setTimeout(function(){k(e);k=function(){}},h.timeout)}var d=k;k=function(){var l={};c.each(e,function(){l[this.getId()]=this});d(c.map(users,function(m){return l[m]}))};c.each(users,function(){a.getPeople(this-0,h,function(l){e.push(l.asArray()[0]);if(users.length!==e.length){return}k(e);k=function(){}})});return this};a.requestShareApp=function(e){var d=opensocial;d.requestShareApp("VIEWER_FRIENDS",null,function(f){if(c.isFunction(e)){return e(f)}});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"];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:"HIGH"}}if("string"===typeof h){h={priority:h}}if(!h){h={priority:"HIGH"}}if(c.isArray(h)){h={target:h,priority:"HIGH"}}h.priority=g[h]||h.priority;if(!h.priority){h.priority="HIGH"}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);f.requestCreateActivity(i,h.priority,e(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);f.requestSendMessage(j,i,e(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("object"!=typeof g){d=g;g=undefined}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);