Make auto solved

Go down

Solved Make auto solved

Post by Luis Ferreira on Sat 14 Nov - 20:52

Forum version : Phpbb2
Position : Administrator 
Concerned browser(s) : Google Chrome 
Who the problem concerns : all
Forum link : http://gamemunity.team-talk.net/




i have a button called "Mark solved" how i can do it to make auto solved when pressed like this forum ?



Code:
$(function() {
  var icon_id = 2,
        notice_msg = '<img src=http://oi65.tinypic.com/1051e8w.jpg height=20 style=vertical-align:middle> Help organize the forum if your question has been resolved click solved',
      button_icon = '<img src=http://oi65.tinypic.com/1051e8w.jpg>',
 
      postbody = $('.postbody')[0],
      edit, icon;
 
  if (postbody) {
    edit = $(postbody).closest('.post').find('.i_icon_edit')[0];
 
    if (edit) {
      $('#page-body').prepend('<div style="background:#000000;border:1px color:#545252;padding:5px;color:#FFFFFF;text-align:center;font-family:Verdana;font-size:11px">' + notice_msg + '</div>');
      $('.nav:has(> a[href*="mode=reply"])').append('&nbsp&nbsp&nbsp<a href="' + edit.parentNode.href + '&solved=true">' + button_icon + '</a>');
    }
  }
 
  if (location.href.match(/&solved=true/)) {
    icon = document.getElementById('post_icon_' + icon_id);
    if (icon) {
      icon.checked = true;
      document.post && document.post.post.click();
    }
  }
});


Last edited by Luis Ferreira on Mon 23 Nov - 15:09; edited 1 time in total

Luis Ferreira
Forumember

Posts : 53
Reputation : 1
Language : Poruguese

http://gamemunity.team-talk.net/

Back to top Go down

Solved Re: Make auto solved

Post by SLGray on Sat 14 Nov - 22:33

So that JavaScript is not working?


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 43479
Reputation : 3090
Language : English
Location : United States

http://fmthemesdesignteam.forumotion.com/

Back to top Go down

Solved Re: Make auto solved

Post by Luis Ferreira on Sat 14 Nov - 23:14

it works but when i press the button goes to edit and i want to make it aproved by him self

Luis Ferreira
Forumember

Posts : 53
Reputation : 1
Language : Poruguese

http://gamemunity.team-talk.net/

Back to top Go down

Solved Re: Make auto solved

Post by SLGray on Sat 14 Nov - 23:29

Where did you get the JavaScript?


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 43479
Reputation : 3090
Language : English
Location : United States

http://fmthemesdesignteam.forumotion.com/

Back to top Go down

Solved Re: Make auto solved

Post by Luis Ferreira on Sat 14 Nov - 23:31

in a post here

Luis Ferreira
Forumember

Posts : 53
Reputation : 1
Language : Poruguese

http://gamemunity.team-talk.net/

Back to top Go down

Solved Re: Make auto solved

Post by SLGray on Sat 14 Nov - 23:40

Could you please post the link to the topic?


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 43479
Reputation : 3090
Language : English
Location : United States

http://fmthemesdesignteam.forumotion.com/

Back to top Go down

Solved Re: Make auto solved

Post by Luis Ferreira on Sun 15 Nov - 0:39

i saw so many post ... idk men

Luis Ferreira
Forumember

Posts : 53
Reputation : 1
Language : Poruguese

http://gamemunity.team-talk.net/

Back to top Go down

Solved Re: Make auto solved

Post by Luis Ferreira on Mon 16 Nov - 10:59

Bump

Luis Ferreira
Forumember

Posts : 53
Reputation : 1
Language : Poruguese

http://gamemunity.team-talk.net/

Back to top Go down

Solved Re: Make auto solved

Post by Luis Ferreira on Fri 20 Nov - 12:08

Can you say something ? like oh i dont know or im trying to fix or it is impossible

Luis Ferreira
Forumember

Posts : 53
Reputation : 1
Language : Poruguese

http://gamemunity.team-talk.net/

Back to top Go down

Solved Re: Make auto solved

Post by SLGray on Fri 20 Nov - 12:10

Maybe @Ange Tuteur can help you.


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 43479
Reputation : 3090
Language : English
Location : United States

http://fmthemesdesignteam.forumotion.com/

Back to top Go down

Solved Re: Make auto solved

Post by Ange Tuteur on Fri 20 Nov - 13:19

Hi,

Try adding the following script to your JavaScripts.
Modules > JavaScript codes management > New

Placement : In the topics
Code:
$(function() {
  window.$fa_solved = {
   
    icon : {
      id : 3
    },
   
    lang : {
      mark : '<i class="fa"></i> Mark Solved',
      mark_title : 'Marking your topic with the Solved icon will let staff know your problem has been resolved.',
      mark_title_mod : 'Mark this topic Solved',
      marking : '<i class="fa fa-spin"></i> Marking...',
      marked : '<i class="fa"></i> Solved !'
    },
   
    post_id : $('tr.post')[0].id.slice(1),
   
    encode : function(string) {
      return encodeURIComponent(escape(string).replace(/%u[A-F0-9]{4}/g, function(match) {
        return '&#' + parseInt(match.substr(2), 16) + ';';
      })).replace(/%25/g, '%');
    }
   
  };
 
  var main = document.getElementById('page-body'), post = $('tr.post', main)[0], author = $('.poster-profile a[href^="/u"]', post).text(), mod = $('.i_icon_ip', post)[0], button = document.createElement('A');
 
  if (!mod && author != _userdata.username) return;
 
  button.innerHTML = $fa_solved.lang.mark;
  button.title = mod ? $fa_solved.mark_title_mod : $fa_solved.mark_title;
  button.className = 'button1 markSolved';
  button.href = '#';
 
  button.onclick = function() {
    var t = this;
    t.innerHTML = $fa_solved.lang.marking;
    t.removeAttribute('title');
    t.onclick = function() { return false };
   
    $.get('/post?p=' + $fa_solved.post_id + '&mode=editpost', function(d) {
      var auth = $('input[name="auth[]"]', d);
      $.post('/post', 'subject=' + $fa_solved.encode($('input[name="subject"]', d)[0].value) + '&message=' + $fa_solved.encode($('#text_editor_textarea', d)[0].value) + '&p=' + $fa_solved.post_id + '&post_icon=' + $fa_solved.icon.id + '&mode=editpost&auth[]=' + auth[0].value + '&auth[]=' + auth[1].value + '&post=1', function() {
        t.innerHTML = $fa_solved.lang.marked;
        t.className += ' marked';
      });
    });
   
    return false;
  };
 
  main.insertBefore(button, main.firstChild);
  'par ange tuteur';
});

Make sure to replace the 3 in
Code:
id : 3
with the ID of your solved icon. Also, this script was originally meant for phpbb3, so if there are any problems let me know.
avatar
Ange Tuteur
Forumaster

Male Posts : 13202
Reputation : 2917
Language : EN10, FR5, JA5
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Solved Re: Make auto solved

Post by Luis Ferreira on Fri 20 Nov - 16:06

the name i gaved was done so de id is "done" ? or how i see it ?

Luis Ferreira
Forumember

Posts : 53
Reputation : 1
Language : Poruguese

http://gamemunity.team-talk.net/

Back to top Go down

Solved Re: Make auto solved

Post by Ange Tuteur on Fri 20 Nov - 16:09

You can see the id by opening your Devtools ( F12 ) and going to the DOM inspector. Then proceed to select an element from the page and hover over your solved icon's radio button. The number will be at the end, "6" in this example :
avatar
Ange Tuteur
Forumaster

Male Posts : 13202
Reputation : 2917
Language : EN10, FR5, JA5
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Solved Re: Make auto solved

Post by Luis Ferreira on Sat 21 Nov - 12:05

Code:
$(function() {
  window.$fa_solved = {
  
    icon : {
      id : "post_icon_1"
    },
  
    lang : {
      mark : '<i class="fa"></i> Mark Solved',
      mark_title : 'Marking your topic with the Solved icon will let staff know your problem has been resolved.',
      mark_title_mod : 'Mark this topic Solved',
      marking : '<i class="fa fa-spin"></i> Marking...',
      marked : '<i class="fa"></i> Solved !'
    },
  
    post_id : $('tr.post')[0].id.slice(1),
  
    encode : function(string) {
      return encodeURIComponent(escape(string).replace(/%u[A-F0-9]{4}/g, function(match) {
        return '&#' + parseInt(match.substr(2), 16) + ';';
      })).replace(/%25/g, '%');
    }
  
  };
 
  var main = document.getElementById('page-body'), post = $('tr.post', main)[0], author = $('.poster-profile a[href^="/u"]', post).text(), mod = $('.i_icon_ip', post)[0], button = document.createElement('A');
 
  if (!mod && author != _userdata.username) return;
 
  button.innerHTML = $fa_solved.lang.mark;
  button.title = mod ? $fa_solved.mark_title_mod : $fa_solved.mark_title;
  button.className = 'button1 markSolved';
  button.href = '#';
 
  button.onclick = function() {
    var t = this;
    t.innerHTML = $fa_solved.lang.marking;
    t.removeAttribute('title');
    t.onclick = function() { return false };
  
    $.get('/post?p=' + $fa_solved.post_id + '&mode=editpost', function(d) {
      var auth = $('input[name="auth[]"]', d);
      $.post('/post', 'subject=' + $fa_solved.encode($('input[name="subject"]', d)[0].value) + '&message=' + $fa_solved.encode($('#text_editor_textarea', d)[0].value) + '&p=' + $fa_solved.post_id + '&post_icon=' + $fa_solved.icon.id + '&mode=editpost&auth[]=' + auth[0].value + '&auth[]=' + auth[1].value + '&post=1', function() {
        t.innerHTML = $fa_solved.lang.marked;
        t.className += ' marked';
      });
    });
  
    return false;
  };
 
  main.insertBefore(button, main.firstChild);
  'par ange tuteur';
});

so i have this but doesnt seems to work properly sorry Sad





as you can see it have a infinit "marking..." and sometimes it bugs all the post and then i refresh and its ok but it doestn work properly

Luis Ferreira
Forumember

Posts : 53
Reputation : 1
Language : Poruguese

http://gamemunity.team-talk.net/

Back to top Go down

Solved Re: Make auto solved

Post by Luis Ferreira on Mon 23 Nov - 11:40

Now it say solved but no image appears on there or in the topics selection as you can see 



Luis Ferreira
Forumember

Posts : 53
Reputation : 1
Language : Poruguese

http://gamemunity.team-talk.net/

Back to top Go down

Solved Re: Make auto solved

Post by Ange Tuteur on Mon 23 Nov - 13:49

In your script, change
Code:
id : "post_icon_1"
to
Code:
id : 1
.

The id must be an integer, not a DOM id.
avatar
Ange Tuteur
Forumaster

Male Posts : 13202
Reputation : 2917
Language : EN10, FR5, JA5
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Solved Re: Make auto solved

Post by Luis Ferreira on Mon 23 Nov - 15:09

thanks that worked Very Happy btw i made some changes to add a image instead of a text.

Code:
$(function() {
  window.$fa_solved = {
  
    icon : {
      id : 1
    },
  
    lang : {
      mark : '<i class="fa"></i> <img src=imageurl>',
      mark_title : 'Marking your topic with the Solved icon will let staff know your problem has been resolved.',
      mark_title_mod : 'Mark this topic Solved',
      marking : '<i class="fa fa-spin"></i> <img src=imageurl>,
      marked : '<i class="fa"></i><img src= imageurl>'
    },
  
    post_id : $('tr.post')[0].id.slice(1),
  
    encode : function(string) {
      return encodeURIComponent(escape(string).replace(/%u[A-F0-9]{4}/g, function(match) {
        return '&#' + parseInt(match.substr(2), 16) + ';';
      })).replace(/%25/g, '%');
    }
  
  };
 
  var main = document.getElementById('page-body'), post = $('tr.post', main)[0], author = $('.poster-profile a[href^="/u"]', post).text(), mod = $('.i_icon_ip', post)[0], button = document.createElement('A');
 
  if (!mod && author != _userdata.username) return;
 
  button.innerHTML = $fa_solved.lang.mark;
  button.title = mod ? $fa_solved.mark_title_mod : $fa_solved.mark_title;
  button.className = 'button1 markSolved';
  button.href = '#';
 
  button.onclick = function() {
    var t = this;
    t.innerHTML = $fa_solved.lang.marking;
    t.removeAttribute('title');
    t.onclick = function() { return false };
  
    $.get('/post?p=' + $fa_solved.post_id + '&mode=editpost', function(d) {
      var auth = $('input[name="auth[]"]', d);
      $.post('/post', 'subject=' + $fa_solved.encode($('input[name="subject"]', d)[0].value) + '&message=' + $fa_solved.encode($('#text_editor_textarea', d)[0].value) + '&p=' + $fa_solved.post_id + '&post_icon=' + $fa_solved.icon.id + '&mode=editpost&auth[]=' + auth[0].value + '&auth[]=' + auth[1].value + '&post=1', function() {
        t.innerHTML = $fa_solved.lang.marked;
        t.className += ' marked';
      });
    });
  
    return false;
  };
 
  main.insertBefore(button, main.firstChild);
  'par ange tuteur';
});

Luis Ferreira
Forumember

Posts : 53
Reputation : 1
Language : Poruguese

http://gamemunity.team-talk.net/

Back to top Go down

Solved Re: Make auto solved

Post by SLGray on Mon 23 Nov - 21:03

Is this solved?


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 43479
Reputation : 3090
Language : English
Location : United States

http://fmthemesdesignteam.forumotion.com/

Back to top Go down

Solved Re: Make auto solved

Post by Luis Ferreira on Mon 23 Nov - 21:24

yes it is

Luis Ferreira
Forumember

Posts : 53
Reputation : 1
Language : Poruguese

http://gamemunity.team-talk.net/

Back to top Go down

Solved Re: Make auto solved

Post by brandon_g on Mon 23 Nov - 22:32

Topic solved and archived ~ brandon_g


Remember to mark your topic when a solution is found.
avatar
brandon_g
Support Moderator
Support Moderator

Male Posts : 6867
Reputation : 630
Language : English
Location : USA

http://broadcastingduo.forumotion.com/

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum