Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: MOD Implementation
 Javascript for Image Upload Mod: Post Placement
 New Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

bobby131313
Senior Member

USA
1163 Posts

Posted - 11 January 2017 :  10:17:25  Show Profile  Visit bobby131313's Homepage  Reply with Quote
Right now when an image is uploaded the post code is put at the end of the post no matter where the cursor happens to be. To be specific, it goes the the end of the post, then hits two carriage returns, and then posts the code.

I would like it to post the code where the cursor is.

Pretty sure this is the code that controls it....


  If ImageFileType=true then
    %>
    <script>
    if (opener.document.PostTopic.Message.createTextRange && opener.document.PostTopic.Message.caretPos) {
      var caretPos = opener.document.PostTopic.Message.caretPos;
      caretPos.text = "\n\n[img]<% =strForumURL %><% =SUBFOLDER %>/<% =filename %>[/img]";
    } else {
    opener.document.PostTopic.Message.value+="\n\n[img]<% =strForumURL %><% =SUBFOLDER %>/<% =filename %>[/img]";
    }
    </script>
    <%
  Else
    %>
    <script>
    if (opener.document.PostTopic.Message.createTextRange && opener.document.PostTopic.Message.caretPos) {
      var caretPos = opener.document.PostTopic.Message.caretPos;
      caretPos.text = "\n\n[img]<% =strForumURL %><% =SUBFOLDER %>/<% =filename %>[/img]";
    } else {
    opener.document.PostTopic.Message.value+="\n\n[img]<% =strForumURL %><% =SUBFOLDER %>/<% =filename %>[/img]";
    }
    </script>
    <%
  End If


Any help would be greatly appreciated, I am very javascript challenged.

Switch the order of your title tags

Edited by - bobby131313 on 11 January 2017 10:19:15

HuwR
Forum Admin

United Kingdom
20578 Posts

Posted - 11 January 2017 :  11:17:47  Show Profile  Visit HuwR's Homepage
I would suggest looking in the file inc_code.js that is the file that puts the code tags in a post, so there are functions which you can re-use to place your image tags

MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

bobby131313
Senior Member

USA
1163 Posts

Posted - 11 January 2017 :  11:44:22  Show Profile  Visit bobby131313's Homepage
Thanks, I'll have a look.

Switch the order of your title tags
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20578 Posts

Posted - 11 January 2017 :  11:58:11  Show Profile  Visit HuwR's Homepage
IIRC there is a getText and AddText function which get the position and add the required text

there are lots of other functions for each particular tag bold etc, but they use those two functions

MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

bobby131313
Senior Member

USA
1163 Posts

Posted - 11 January 2017 :  16:02:18  Show Profile  Visit bobby131313's Homepage
Been playing with it a bit and it doesn't seem any of those will work, I *think* because the click is in a popup and not on the same page. I reckon that's why the JS code wasn't put in inc.code.js?

Switch the order of your title tags
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20578 Posts

Posted - 11 January 2017 :  18:12:29  Show Profile  Visit HuwR's Homepage
if you look at the getText function, you will see that there are two parts to the code that check for the position, the script in your posted code just uses caretpos.text it's possible that is not supported so requires the selectionStart instead ( your else part just appends to the message).

the only ral difference is that in inc_code it uses document.PostTopic.Message and you would need to use window.opener.document.PostTopic.Message

MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

bobby131313
Senior Member

USA
1163 Posts

Posted - 12 January 2017 :  10:25:47  Show Profile  Visit bobby131313's Homepage
Thanks, I'll play with it some more today.

Switch the order of your title tags
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.26 seconds. Powered By: Snitz Forums 2000 Version 3.4.07