The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Script RESOLVED problems

View previous topic View next topic Go down

Solved Script RESOLVED problems

Post by Avedo on March 28th 2016, 1:22 pm

Hi,

Thanks to this code @Ange Tuteur provided, we were just wondering if there's anyway to change the script so instead of it adding an icon next the topic icon it will change the topic title to [RESOLVED] Topic title text.

How do i restrict it so it's only available for one category, for example, it only appears in the "Ask questions" section of the forum and nowhere else. & As soon as the button has been pressed it disappears and they can't click it again?

Here's a picture of an example


Here's the code Ange provided:

Code:
$(function() {
  window.$fa_solved = {
 
    icon : {
      id : 2
    },
 
    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 : $('div.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('main-content'), post = $('div.post', main)[0], author = $('.postprofile 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';
});


Last edited by Avedo on April 2nd 2016, 7:45 pm; edited 2 times in total
avatar
Avedo
Forumember

Posts : 39
Reputation : 1
Language : English

http://forum.avedoofficial.com

Back to top Go down

Solved Re: Script RESOLVED problems

Post by Avedo on March 29th 2016, 2:18 pm

Bump


Last edited by Avedo on March 30th 2016, 9:27 pm; edited 1 time in total
avatar
Avedo
Forumember

Posts : 39
Reputation : 1
Language : English

http://forum.avedoofficial.com

Back to top Go down

Solved Re: Script RESOLVED problems

Post by Avedo on March 30th 2016, 9:27 pm

Bump
avatar
Avedo
Forumember

Posts : 39
Reputation : 1
Language : English

http://forum.avedoofficial.com

Back to top Go down

Solved Re: Script RESOLVED problems

Post by SLGray on March 30th 2016, 10:22 pm

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 : 40514
Reputation : 2733
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Solved Re: Script RESOLVED problems

Post by Avedo on March 30th 2016, 10:26 pm

No it's not.

Edit: We've changed the topic title to stop confusion.
avatar
Avedo
Forumember

Posts : 39
Reputation : 1
Language : English

http://forum.avedoofficial.com

Back to top Go down

Solved Re: Script RESOLVED problems

Post by SLGray on March 30th 2016, 10:34 pm

AP > General > Messages & Emails > Configuration
Topics Section
Allow the modification of the topic title: Yes
Display button [solved]: Yes


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

avatar
SLGray
Administrator
Administrator

Male Posts : 40514
Reputation : 2733
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Solved Re: Script RESOLVED problems

Post by Avedo on March 30th 2016, 10:37 pm

I already knew how to do that, I was wondering if it was possible to re code the script so when you press the "Mark solved" button it adds the [SOLVED] text to the topic title.

Like on the photo.
avatar
Avedo
Forumember

Posts : 39
Reputation : 1
Language : English

http://forum.avedoofficial.com

Back to top Go down

Solved Re: Script RESOLVED problems

Post by Ange Tuteur on April 1st 2016, 5:18 pm

Hi,

Try replacing the script with this :
Code:
$(function() {
  if (!/43/.test($('.topic-actions:first .pathname-box a:last', main).attr('href'))) return;

  window.$fa_solved = {
 
    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 : $('div.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('main-content'), post = $('div.post', main)[0], author = $('.postprofile 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('[RESOLVED]' + $('input[name="subject"]', d)[0].value) + '&message=' + $fa_solved.encode($('#text_editor_textarea', d)[0].value) + '&p=' + $fa_solved.post_id + '&mode=editpost&auth[]=' + auth[0].value + '&auth[]=' + auth[1].value + '&post=1', function() {
        t.innerHTML = $fa_solved.lang.marked;
        t.className += ' marked';
        $('.topic-title a').each(function() {
          this.innerHTML = '[RESOLVED]' + this.innerHTML;
        })
      });
    });
 
    return false;
  };
 
  main.insertBefore(button, main.firstChild);
  'par ange tuteur';
});

At the top you'll see this snippet :
Code:
if (!/43/.test($('.topic-actions:first .pathname-box a:last', main).attr('href'))) return;
Replace the number "43" with the id of the forum you want this script to work in. You can see the forum id via the URL : http://help.forumotion.com/f43-scripts-coding-problems
avatar
Ange Tuteur
Forumaster

Male Posts : 13176
Reputation : 2879
Language : EN10, FR5
Location : Macungie, PA

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Script RESOLVED problems

Post by Avedo on April 2nd 2016, 6:29 pm

Hello @Ange Tuteur How would we make the [RESOLVED] text green like the image we provided?
avatar
Avedo
Forumember

Posts : 39
Reputation : 1
Language : English

http://forum.avedoofficial.com

Back to top Go down

Solved Re: Script RESOLVED problems

Post by Ange Tuteur on April 2nd 2016, 6:44 pm

You would need a script which finds all links that contain the texts "[RESOLVED]" and replace the html content to wrap it with tags. See this topic :
http://help.forumotion.com/t133869-style-topic-title-keywords
avatar
Ange Tuteur
Forumaster

Male Posts : 13176
Reputation : 2879
Language : EN10, FR5
Location : Macungie, PA

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Script RESOLVED problems

Post by Avedo on April 2nd 2016, 7:44 pm

This seems rather difficult, so we're going to leave that one out xD Thank you kindly for the help Ange! Smile
avatar
Avedo
Forumember

Posts : 39
Reputation : 1
Language : English

http://forum.avedoofficial.com

Back to top Go down

Solved Re: Script RESOLVED problems

Post by APE on April 2nd 2016, 8:40 pm

Topic solved and archived



avatar
APE
Manager
Manager

Male Posts : 10822
Reputation : 1008
Language : fluent in dork / mumbojumbo & English haha
Location : STUCK IN FORUMOTIONS SERVERS HELP ME !!!!!!

http://chatworld.forumotion.co.uk/

Back to top Go down

View previous topic View next topic Back to top


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