Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var followingct = 0;
- var followerct = 0;
- var following;
- var followers;
- if(#page.properties.following.text >2){
- let following = json.parse(page.properties["following"].text);
- let followingct = #following;
- };
- if(#page.properties.followers.text >2){
- let followers = json.parse(page.properties["followers"].text);
- let followerct = #followers;
- };
- <div style="float:right;" id="followblock">
- <h3>"Follow Profile";</h3>
- <table id="followprofiletable" class="table">
- <tbody>
- <tr>
- <th>"Following";</th>
- <th>"Followers";</th>
- </tr>
- <tr>
- <td>followingct;</td>
- <td>followerct;</td>
- </tr>
- </tbody>
- </table>
- <table class="table" id="followertable">
- <tbody>
- <tr>
- <th>page.revisions[0].author.name .. " is following:";</th>
- </tr>
- if(followingct > 0 ){
- foreach(var flwng in following){
- <tr>
- <td>flwng.leadername;</td>
- </tr>
- };
- }
- else {
- <tr>
- <td>"No one.";</td>
- </tr>
- };
- </tbody>
- </table>
- <br />
- <table>
- <tbody>
- <tr>
- <td style="33%;"></td>
- <td style="33%;">if(!user.anonymous){
- dekiapi();
- var fbval='follow me!';
- if (user.homepage.properties.following.text){
- if(string.contains(user.homepage.properties.following.text, page.revisions[0].author.name)) {
- let fbval='unfollow me';
- }
- };
- <input type="hidden" value="{{page.revisions[0].author.name}}" id="pgauthor" />
- <input type="hidden" value="{{user.homepage.api}}" id="pageapi" />
- <input type="hidden" value="{{user.name}}" id="curusr" />
- <input type="button" id="followbutton" value="{{fbval}}" ctor="
- when($this.click){
- if ($this.val() =='follow me!'){
- @followadd({leadervals: {leadername: #pgauthor.val(), contribs: 'true'}, leadername: #pgauthor.val(), pageapi: #pageapi.val()});
- @followeradd({followervals: {followername: #curusr.val()}, followername: #curusr.val() });
- }
- else {
- @followremove({leadervals: {leadername: #pgauthor.val(), contribs: 'true'}, leadername: #pgauthor.val(), pageapi: #pageapi.val()});
- @followerremove({followervals: {followername: #curusr.val()}, followername: #curusr.val() });
- }
- };
- when(@followadd){
- Deki.Api.ReadPageProperty(@followadd.pageapi, 'urn:custom.mindtouch.com#following',
- function(result) {
- var data = eval('(' + (result.value || '[]') + ')');
- data.push(@followadd.leadervals);
- if(result.etag){
- Deki.Api.UpdatePageProperty(result.href, YAHOO.lang.JSON.stringify(data), result.etag,
- function() {
- alert('You are now following ' + @followadd.leadername + '.');
- #followbutton.val('unfollow me');
- },
- function() {
- alert('An error occurred while trying to follow this person. Please try again.');
- }
- );
- }
- else {
- Deki.Api.CreatePageProperty(@followadd.pageapi, 'urn:custom.mindtouch.com#following', YAHOO.lang.JSON.stringify(data),
- function() {
- alert('You are now following ' + @followadd.leadername + '.');
- #followbutton.val('unfollow me');
- },
- function() {
- alert('An error occurred while trying to follow this person. Please try again.');
- }
- );
- }
- },
- function() {
- alert('An error occurred trying to access your followers list. Please try again.');
- }
- );
- };
- when(@followeradd){
- Deki.Api.ReadPageProperty(null, 'urn:custom.mindtouch.com#followers',
- function(result) {
- var data = eval('(' + (result.value || '[]') + ')');
- data.push(@followeradd.followervals);
- if(result.etag){
- Deki.Api.UpdatePageProperty(result.href, YAHOO.lang.JSON.stringify(data), result.etag,
- function() {
- Deki.Api.Reload(#followprofiletable);
- },
- function(){
- }
- );
- }
- else {
- Deki.Api.CreatePageProperty(null, 'urn:custom.mindtouch.com#followers', YAHOO.lang.JSON.stringify(data),
- function() {
- Deki.Api.Reload(#followprofiletable);
- },
- function() {
- }
- );
- }
- },
- function() {
- alert('An error occurred trying to access the followers list. Please try again.');
- }
- );
- };
- when(@followremove){
- Deki.Api.ReadPageProperty(@followremove.pageapi, 'urn:custom.mindtouch.com#following',
- function(result){
- var data = eval('(' + (result.value || '[]') + ')');
- data.splice(@followremove.leadervals);
- Deki.Api.UpdatePageProperty(result.href, YAHOO.lang.JSON.stringify(data), result.etag,
- function() {
- alert('You are no longer following ' + @followremove.leadername + '.');
- },
- function() {
- alert('An error occurred while trying to unfollow this person. Please try again.');
- }
- );
- },
- function(){}
- );
- };
- when(@followerremove){
- Deki.Api.ReadPageProperty(null, 'urn:custom.mindtouch.com#followers',
- function(result){
- var data = eval('(' + (result.value || '[]') + ')');
- data.splice(@followerremove.followervals);
- Deki.Api.UpdatePageProperty(result.href, YAHOO.lang.JSON.stringify(data), result.etag,
- function(){
- #followbutton.val('follow me!');
- Deki.Api.Reload(#followprofiletable);
- },
- function(){}
- );
- }
- );
- };"
- />
- }</td>
- <td style="33%;"></td>
- </tr>
- </tbody>
- </table>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement