The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Automatic Solved Button working incorrectly

2 posters

Go down

In progress Automatic Solved Button working incorrectly

Post by soaring hooves September 1st 2017, 6:30 pm

I have the below code for my phpBB2 forum:

Code:
$(function() {
  window.$fa_solved = {
 
    icon : {
      id : 1
    },
 
    lang : {
      mark : '<i class="fa"></i><img src=https://i11.servimg.com/u/f11/19/75/78/74/rsz_1111.png>',
      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"></i><img src=https://i11.servimg.com/u/f11/19/75/78/74/rsz_1111.png>',
      marked : '<i class="fa"></i><img src=https://i11.servimg.com/u/f11/19/75/78/74/rsz_1311.png>'
    },
 
    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';
});

The issues are that firstly, when I hover over the Mark as Solved image it states 'undefined', despite the above coding demanding that it says "Marking your topic with the Solved icon will let staff know your problem has been resolved.". Can anyone tell me why that is not working as it should?

Secondly, once I marked a topic as solved, I may leave and then come back to the topic to find that it will show the original 'Mark as Solved' image again, rather than the 'Marked as Solved' image. In other words, it appears as if you can then remark it as solved, whereas in this forum I believe the image simply disappears altogether or remains another image. It does not revert back to the original option.

Finally, can anyone provide a code that could move this entire function to beside the Post Reply button. It looks rather odd hovering up there just under the navbar, as it does at the moment.

Specifically, in this topic I have been testing the javascript.
soaring hooves
soaring hooves
New Member

Posts : 18
Reputation : 2
Language : English

http://www.creationspaceuk.com/

Back to top Go down

In progress Re: Automatic Solved Button working incorrectly

Post by Draxion September 1st 2017, 8:26 pm

Never mind, there is something wrong with the code and I think it's cause you are using phpbb2 when the code is made for phpbb3. I know it says it should work for phpbb2, which theory it does, it's just not going to work fully.
Draxion
Draxion
Helper
Helper

Male Posts : 2518
Reputation : 321
Language : English
Location : USA

https://www.talesoftellene.com/

Back to top Go down

In progress Re: Automatic Solved Button working incorrectly

Post by soaring hooves September 1st 2017, 9:13 pm

Just to update whoever may be interesting in helping on the issue. Draxion kindly attempted to fix the code but for some reason, it didn't change much; the image of the button keeps reverting back to the original 'Mark As Solved' image, rather than keeping the 'Marked as Solved' image, or disappearing altogether which would be preferred.

Furthermore, if anyone has a code which can move it down to beside the Post Reply button that would be great.

The hover wording has been fixed.
soaring hooves
soaring hooves
New Member

Posts : 18
Reputation : 2
Language : English

http://www.creationspaceuk.com/

Back to top Go down

Back to top

- Similar topics

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