Advertisement
Guest User

Untitled

a guest
May 7th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var followingct = 0;
  2. var followerct = 0;
  3. var following;
  4. var followers;
  5. if(#page.properties.following.text >2){
  6.     let following = json.parse(page.properties["following"].text);
  7.     let followingct = #following;
  8. };
  9. if(#page.properties.followers.text >2){
  10.     let followers = json.parse(page.properties["followers"].text);
  11.     let followerct = #followers;
  12. };
  13. <div style="float:right;" id="followblock">
  14. <h3>"Follow Profile";</h3>
  15. <table id="followprofiletable" class="table">
  16.     <tbody>
  17.         <tr>
  18.             <th>"Following";</th>
  19.             <th>"Followers";</th>
  20.         </tr>
  21.         <tr>
  22.             <td>followingct;</td>
  23.             <td>followerct;</td>
  24.         </tr>
  25.     </tbody>
  26. </table>
  27. <table class="table" id="followertable">
  28.     <tbody>
  29.         <tr>
  30.             <th>page.revisions[0].author.name .. " is following:";</th>
  31.         </tr>
  32.     if(followingct > 0 ){
  33.             foreach(var flwng in following){
  34.                 <tr>
  35.                     <td>flwng.leadername;</td>
  36.                 </tr>
  37.             };
  38.     }
  39.     else {
  40.         <tr>
  41.             <td>"No one.";</td>
  42.         </tr>
  43.     };            
  44.     </tbody>
  45. </table>
  46. <br />
  47. <table>
  48.     <tbody>
  49.         <tr>
  50.             <td style="33%;"></td>
  51.             <td style="33%;">if(!user.anonymous){
  52.                 dekiapi();
  53.                 var fbval='follow me!';
  54.                 if (user.homepage.properties.following.text){
  55.                     if(string.contains(user.homepage.properties.following.text, page.revisions[0].author.name)) {
  56.                         let fbval='unfollow me';
  57.                     }
  58.                 };
  59.                 <input type="hidden" value="{{page.revisions[0].author.name}}" id="pgauthor" />
  60.                 <input type="hidden" value="{{user.homepage.api}}" id="pageapi" />
  61.                 <input type="hidden" value="{{user.name}}" id="curusr" />
  62.                     <input type="button" id="followbutton" value="{{fbval}}" ctor="
  63.                        when($this.click){
  64.                if ($this.val() =='follow me!'){
  65.                            @followadd({leadervals: {leadername: #pgauthor.val(), contribs: 'true'}, leadername: #pgauthor.val(), pageapi: #pageapi.val()});
  66.                            @followeradd({followervals: {followername: #curusr.val()}, followername: #curusr.val() });
  67.                        }
  68.                else {
  69.                            @followremove({leadervals: {leadername: #pgauthor.val(), contribs: 'true'}, leadername: #pgauthor.val(), pageapi: #pageapi.val()});
  70.                            @followerremove({followervals: {followername: #curusr.val()}, followername: #curusr.val() });
  71.                        }
  72.                };
  73.  
  74.                    when(@followadd){
  75.                        Deki.Api.ReadPageProperty(@followadd.pageapi, 'urn:custom.mindtouch.com#following',
  76.                            function(result) {
  77.                                var data = eval('(' + (result.value || '[]') + ')');
  78.                                data.push(@followadd.leadervals);
  79.                                if(result.etag){
  80.                                    Deki.Api.UpdatePageProperty(result.href, YAHOO.lang.JSON.stringify(data), result.etag,
  81.                                        function() {
  82.                                            alert('You are now following ' + @followadd.leadername + '.');
  83.                                            #followbutton.val('unfollow me');
  84.                                        },
  85.                                        function() {
  86.                                            alert('An error occurred while trying to follow this person. Please try again.');
  87.                                        }
  88.                                    );
  89.                                }
  90.                                else {
  91.                                    Deki.Api.CreatePageProperty(@followadd.pageapi, 'urn:custom.mindtouch.com#following', YAHOO.lang.JSON.stringify(data),
  92.                                        function() {
  93.                                            alert('You are now following ' + @followadd.leadername + '.');
  94.                                            #followbutton.val('unfollow me');
  95.                                        },
  96.                                        function() {
  97.                                            alert('An error occurred while trying to follow this person. Please try again.');
  98.                                        }
  99.                                    );
  100.                                }
  101.                            },
  102.                            function() {
  103.                                alert('An error occurred trying to access your followers list. Please try again.');
  104.                            }
  105.                        );
  106.                    };
  107.  
  108.                    when(@followeradd){
  109.                        Deki.Api.ReadPageProperty(null, 'urn:custom.mindtouch.com#followers',
  110.                            function(result) {
  111.                                var data = eval('(' + (result.value || '[]') + ')');
  112.                                data.push(@followeradd.followervals);
  113.                                if(result.etag){
  114.                                    Deki.Api.UpdatePageProperty(result.href, YAHOO.lang.JSON.stringify(data), result.etag,
  115.                                        function() {
  116.                                            Deki.Api.Reload(#followprofiletable);
  117.                                        },
  118.                                        function(){
  119.                                        }
  120.                                    );
  121.                                }
  122.                                else {
  123.                                    Deki.Api.CreatePageProperty(null, 'urn:custom.mindtouch.com#followers', YAHOO.lang.JSON.stringify(data),
  124.                                        function() {
  125.                                            Deki.Api.Reload(#followprofiletable);
  126.                                        },
  127.                                        function() {
  128.                                        }
  129.                                    );
  130.                                }
  131.                            },
  132.                            function() {
  133.                                alert('An error occurred trying to access the followers list. Please try again.');
  134.                            }
  135.                        );
  136.                    };
  137.  
  138.                        when(@followremove){
  139.                            Deki.Api.ReadPageProperty(@followremove.pageapi, 'urn:custom.mindtouch.com#following',
  140.                                function(result){
  141.                                    var data = eval('(' + (result.value || '[]') + ')');
  142.                                    data.splice(@followremove.leadervals);
  143.                                    Deki.Api.UpdatePageProperty(result.href, YAHOO.lang.JSON.stringify(data), result.etag,
  144.                                        function() {
  145.                                            alert('You are no longer following ' + @followremove.leadername + '.');
  146.                                                                  
  147.                                        },
  148.                                        function() {
  149.                                            alert('An error occurred while trying to unfollow this person. Please try again.');
  150.                                        }
  151.                                    );
  152.                                },
  153.                                function(){}
  154.                            );
  155.                        };
  156.                
  157.                        when(@followerremove){
  158.                            Deki.Api.ReadPageProperty(null, 'urn:custom.mindtouch.com#followers',
  159.                                function(result){
  160.                                    var data = eval('(' + (result.value || '[]') + ')');
  161.                                    data.splice(@followerremove.followervals);
  162.                                    Deki.Api.UpdatePageProperty(result.href, YAHOO.lang.JSON.stringify(data), result.etag,
  163.                                        function(){
  164.                                            #followbutton.val('follow me!');                            
  165.                                            Deki.Api.Reload(#followprofiletable);
  166.                                        },
  167.                                        function(){}
  168.                                    );
  169.                                }
  170.                            );
  171.                        };"
  172.                     />
  173.                 }</td>
  174.             <td style="33%;"></td>
  175.         </tr>
  176.     </tbody>
  177. </table>
  178. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement