News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

AJAX Instant Quick Reply

Started by SlammedDime, May 29, 2008, 06:59:11 PM

Previous topic - Next topic

Ryan

Hi SlammedDime, First off would like to thank you for support your giving to everyone!
Somthings wrong on my attempt ive spent 2 hours with no luck im outa ideas.. 
It installed everything apart from display.template.php i manualy added the stuff in there.. When i post it shows that message at top of forum its posting but then it refrehes page without using the ajax posting method..

I looked through display.php turned out some bits wernt inserted by package manager but after i added them still posts normal way.

I have attached following
display.php
display.template.php
xmltopic.js
xml.template.php

Download here: http://www.h2kclan.com/files.rar

My forum is located at:
http://www.h2kclan.com/forum/
Login
User: test
pass: test

Would realy apreciate it..
Ive always wanted Ajax on SMF!

kai920

#161
Quote from: SlammedDime on June 11, 2008, 04:28:07 PM
I'm almost 100% sure that this won't work with the Joomla or Mambo bridge with SEF urls turned on on the Mambo or Joomla side without some modification (at least that was my experience).  You can most certainly try making the fixes you suggested in the JS files and see if that solves the problem for you, but I'm not sure.  I use Mambo but haven't had a chance to even test or install this on my live site.

As for the uninstalling: You'll have to perform the uninstall, ignoring the error, and then use the Package Parser integrated into the mod's download page and go through Display.Template.php and remove anything that was installed by the mod by hand.
Can you let me know which file I should look at? I looked at xmltopic.js, line 68 and it was the function sendXMLDocument... from where does "ajax instant quick reply" call this function and pass it the URL? Sorry I'm a bit new to this... (is it function ajax_reply() inside xml_topic.js?)

1. edit: seems to work now! just changed the corresponding line to:
    sendXMLDocument(smf_scripturl + "/action,post2/topic," + smf_topic + "/xml,xml", x.join("&"), onPostDone);


:) Now my next question is: how can I send different versions of the javascript statement (a) slashes&commas, instead of b) semi-colons&equals depending on the state of _REQUEST['option']?


2. I don't have the 1.0 package file anymore. Can I discern which manual edits were made to display.template.php using the 1.0.1 file?  BTW, I ran the 1.0.1 file through this parser and got an error for some reason..

SlammedDime

1.0.0 and 1.0.1 are both on the mod site.  If you choose from the drop down under the links to download the version of SMF you are running and click 'Submit', you will get manual instructions for installing the mod (just reverse them for uninstalling): http://custom.simplemachines.org/mods/index.php?mod=1214.  Make sure you choose the radio button next to 1.0 first.

As for different versions of the javascript statement: there really isn't any good way to do it without really modifying the javascript.  The easiest way would be to modify the bridge so that it doesn't transform the smf_scripturl variable in the header of the HTML (Orstio's bridge does this anyway), so regardless of which SMF version your viewing (through the bridge or standalone), any AJAX function of SMF will work.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

SlammedDime

#163
M3THOD: Try the attached Display.template.php. :)
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

kai920

Quote from: SlammedDime on June 12, 2008, 03:42:49 AM
As for different versions of the javascript statement: there really isn't any good way to do it without really modifying the javascript.  The easiest way would be to modify the bridge so that it doesn't transform the smf_scripturl variable in the header of the HTML (Orstio's bridge does this anyway), so regardless of which SMF version your viewing (through the bridge or standalone), any AJAX function of SMF will work.

Can javascript be made to check for _REQUEST['option'] inside the ajax_reply() function?

SlammedDime

You could analyze the querystring and set a variable based on if option=com_smf exists or not.  Keep in mind though, $_REQUEST houses all of $_POST and $_GET, whereas analyzing the query string in javascript is similar to looking at just the $_GET array in php.  I can't think of a moment when an SMF page would load with the option set in a $_POST variable, at least as far as anything ajax related is concerned, so its not a big deal, just wanted to make that distinction.

Here is a google search you may want to look at: http://www.google.com/search?&q=javascript%20querystring
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

Ryan

Quote from: SlammedDime on June 12, 2008, 03:55:23 AM
M3THOD: Try the attached Display.template.php. :)
Thanks mate that did the job :) there was a missing '; on line 616 but i put it in and works like charm :)  :D

L'AltroWeb

Hi!
How i can install and use with babylon theme?

SlammedDime

The same way you would with any other theme.  Please read the first post of the topic as well as the install instructions carefully in the xml file.

Manual Installation of Mods
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

razorblitz07

hey ummm, I just installed the SEO pretty urls mod onto my site...now the ajax function on the quick reply is broken.  The javascript doesn't go all the way through.  Like I click on Post and the green javascript bar pops up and says Loading... but it doesn't disappear.  It just stays never and never follows all the way through.  I have to click refresh to see that my post has been made but the ajax/javascript doesn't go through anymore.  Is there any compatibility issues between the SEO mod and this mod?

SlammedDime

Yes, there are issues.

Open Display.php
Code (Find) Select
if ((isset($context['pretty']['oldschoolquery']) || $context['pretty']['query_string']['board'] != $context['pretty']['board_urls'][$board]) && $modSettings['pretty_enable_filters'])

Code (Replace) Select
if (!isset($_REQUEST['xml']) && (isset($context['pretty']['oldschoolquery']) || $context['pretty']['query_string']['board'] != $context['pretty']['board_urls'][$board]) && $modSettings['pretty_enable_filters'])
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

razorblitz07


kai920

#172
I'm not sure if this problem is related to this mod... just noticed that when I am a guest, my site's template is screwy and my main content area is wrapped by a form id="quickmodform", which is very strange.

any ideas? I've got a screenshot below... and if you go to this link you can see it live. once logged in, the issue disappears.

problem doesn't occur inside board index, forum index, no matter logged in or not.

ps. I am still using version 1.0 of the mod, and I made the small edits to xml_topic.js to make it joomla-sef friendly.

SlammedDime

That's normal.  that form is ALWAYS wrapped around the post, guest or not.  Just how the template is made.  It's there when you're logged in to.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

L'AltroWeb

Ok i have installed (with more problem cause of many other mod and modification to my display.template.php) also to babylon theme and now is ok.
I have pretty urls and i have see that this edit is still integrated:
Quotef (!isset($_REQUEST['xml']) && (isset
All good :)
-
Only one questions: in the first topic post i have see:
Fix for 1.1.5 or B3.1...
and i have inserted goback line:
Quotex[x.length] = 'goback=' + parseInt(document.forms.postmodify.elements['goback'].value);
but: i dont have this line:
Quotex[x.length] = 'subject=' + escape(textToEntities(document.forms.postmodify['subject'].value.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
i have this:
Quotex[x.length] = 'message=' + escape(textToEntities(document.forms.postmodify['message'].value.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
really small difference, is ok?

SlammedDime

You should have both.  If not, you're not looking in the correct place.  It will be in the ajax_reply() function in xml_topic.js.  There is more than one line like that, you need to find the specific one.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

L'AltroWeb

#176
This is the modification for xml_topic.js:
(small difference with first post patch)

function ajax_reply()
{
var i, x = new Array();
x[x.length] = 'topic=' + parseInt(document.forms.postmodify.elements['topic'].value);
x[x.length] = 'subject=' + escape(textToEntities(document.forms.postmodify['subject'].value.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
x[x.length] = 'message=' + escape(textToEntities(document.forms.postmodify['message'].value.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
x[x.length] = 'icon=' + escape(textToEntities(document.forms.postmodify['icon'].value.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
x[x.length] = 'notify=' + escape(textToEntities(document.forms.postmodify['notify'].value.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
x[x.length] = 'num_replies=' + parseInt(document.forms.postmodify.elements['num_replies'].value);
x[x.length] = 'sc=' + escape(textToEntities(document.forms.postmodify['sc'].value.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");

// Send in the XMLhttp request and let's hope for the best.
if (typeof window.ajax_indicator == "function")
ajax_indicator(true);

sendXMLDocument(smf_scripturl + "?action=post2;xml", x.join("&"), onPostDone);

return false;
}

function onPostDone(XMLDoc)
{
// We've finished the loading stuff.
if (typeof window.ajax_indicator == "function")
ajax_indicator(false);

// Update the num_replies counter so if the user replies more than once without refreshing, we don't get an error.
document.postmodify.num_replies.value = parseInt(document.postmodify.num_replies.value) + 1;

var myTable = document.getElementById("postTable"), myRow, myCell, myData;

var post = XMLDoc.getElementsByTagName('post')[0];
var errors = XMLDoc.getElementsByTagName('errors')[0];

// If there are errors, its better to just let SMF deal with them, so we'll submit the form and let its take its course
if (errors) {
document.postmodify.submit();
}
// Otherwise, the post was successful so lets add it in.
else if (post) {
myRow = myTable.insertRow((view_newest_first == 1) ? 0 : myTable.rows.length-1);
myCell = myRow.insertCell(-1);
myCell.style.padding = "1px 1px 0 1px";
myData = post.childNodes[0].nodeValue;
setInnerHTML(myCell, myData);

// And empty the post reply box
document.postmodify.message.value = "";
}
else {
window.location.reload(true);
}
}
I have simply inserted this line: x[x.length] = 'subject=' ....
x[x.length] = 'goback=' + parseInt(document.forms.postmodify.elements['goback'].value);
x[x.length] = 'message=' ...

Sorry, my error with copy and paste line.
The difference is:
First post of this topic:
   x[x.length] = 'subject=' + escape(textToEntities(document.forms.postmodify['subject'].value.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
Mod:
x[x.length] = 'subject=' + escape(textToEntities(document.forms.postmodify['subject'].value.replace(/&#/g, "&#"))).replace(/\+/g, "%2B");
(see: "&#") instead of: &#"):)

SlammedDime

Thanks for pointing that out.  I adjusted the first post.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

L'AltroWeb

Thank you too for your work :)

kai920

Quote from: SlammedDime on June 13, 2008, 03:45:59 PM
That's normal.  that form is ALWAYS wrapped around the post, guest or not.  Just how the template is made.  It's there when you're logged in to.

okay , thanks. I'll try the general support board...

Advertisement: