Page 4 of 8 FirstFirst ... 23456 ... LastLast
Results 31 to 40 of 80

Thread: Turn simple javascript code to a button

  1. #31
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,496
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    OK, thanks. I agree with what the PB person is saying. Why IE makes an issue of it and other browsers do not is a mystery, though very much in keeping with IE's legend of being weird. Fortunately, IE is finally being completely discontinued. But that won't help us in the near term. So, that's why I'm trying to abort the full loading of the page. I've done a lot of work with cross domain scripting and I realize that sometimes you just need to make a reference back to the domain you are servicing (in this case one of your forums) and that it doesn't mean anything other than that the loop is completed. Other times vital information is communicated in that way. If it's the former, interrupting the load of the page should fix the problem. If the latter, it should also fix it, but may also mess up the postimage script in one or more ways.

    In any case, you putting the script I wrote up on the live forum has led me to realize I made an error in writing it. It should be:

    Code:
    <script type="text/javascript">
    if(/postimage_id/.test(location.href)){location.href = 'about:blank';}
    </script>
    Let's give that a try and see what happens. If there is a new problem or problems from that, I already have an idea how to fix it.



    Oh, and as I said, I'm not sure if it was really image size or bandwidth on the test forum. It could even be something else. I will say that it usually worked there in IE. Only on occasion was there the AJAX message issue, whereas the other forum (scooter professor) always seemed to have the problem.
    Last edited by jscheuer1; 02-26-2015 at 03:28 AM. Reason: add last paragraph
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  2. #32
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Well John I believe we are getting closer.....I think. LOL I put the code in right under the head in the forum wrapper and for sure the Ajax pop up is gone but when one clicks on the image uploader you get the old Blank Page and you're done, not browsing for your image nothing a blank page.

    I then took a shot at moving the code to right above the button code in the Quick Reply template, the results were the opposite, you could browse and find your image but when you click on Upload the Blank Page comes back.

    So again just for kicks I moved it right under the button code and no Blank Page and you could get the URL link to paste on the posting page but when you hit the Post Quick Reply button it goes whack-o it may put 3 photos in or take forever to download, acted crazy.

    But no Ajax message. So I put it back under the Head tag in the forum wrapper.

    Thanks I'll await your next code.
    Last edited by JRR; 02-26-2015 at 11:59 AM.

  3. #33
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,496
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well I only have a test form to try things here. And there are a lot of differences, perhaps even how the script communicates with itself. So I was hoping that just putting the code at the beginning of the head would work for the forums. But it didn't work for my form. I've added an AJAX call and other things to my form to try duplicating the error we get in IE on the forums, but so far, no luck. Anyways, after putting my script in the head, my test form no longer worked at all in any browser. So I figured that the postimage code needed to see something (more likely interact with something) on the page it was loading into the popup in order to work. The most logical things are either the postimage script itself or one that it inserts into the page. So I moved the postimage script to the head of the page, right before my code that kills the rest of the page and things worked again. We now have, at least potentially, the best of both worlds. The script can communicate with itself, but the rest of the page doesn't load or create problems. I also checked the DOM, and somehow (almost certainly because it does these onload) the postimage script is still finding (on the main page - the one in the full browser window) the .message div and inserting its link as well as its span and br, and is of course available to our custom link/button. So everything should work. To do this, get rid of:

    Code:
    <script type="text/javascript" src="http://mod.postimage.org/website-english-family.js" charset="utf-8"></script>
    from the form. Place it instead in the head of the page just before my code (just before this script):

    Code:
    <script type="text/javascript">
    if(/postimage_id/.test(location.href)){location.href = 'about:blank';}
    </script>
    That should do it. If not, leave it that way so I can have a look. You need do this only on the Scooter Professor forum for now (the one I have an account on).

    As usual, the browser cache may need to be cleared and the page refreshed to see changes.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #34
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    You are a genius! It's working flawlessly in IE and Firefox and I'm waiting on a friend to give me feedback on Chrome! Question? If I put the button code in another template location for this to be used in two locations of the forum will the button call to the same script on the Forum wrapper head?

    Oh I almost forgot PB is lit up today with code request modifications for problems with the new Firefox 36 download. Have you used this updated version yet? If not then I'm going to try to find someone who uses it to check this too.

    John I appreciate your help so much!


    Edit: John I just check this in the new Firefox 36 and all is ok.
    Last edited by JRR; 02-26-2015 at 06:21 PM.

  5. #35
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,496
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by JRR View Post
    If I put the button code in another template location for this to be used in two locations of the forum will the button call to the same script on the Forum wrapper head?
    It should, just try it out and see. In fact, if the styles that kill (hide really) the default link and its span and br are either in the template or in a stylesheet used by the template, and the script I wrote is in the template along with the postimage script tag right before that, then any page that allows you to reply to a message should be able to have the custom link/button added and have it work. The only proviso might be that the form that allows for the reply may have to have a parent with the class of message. All ordinary forum post reply forms do I would think. Private messages might not, but they may, and even if they don't, they might still work. I think the only thing that might need tweaking if the class is different are the selector for the style that hides the span and br.

    But if there are any problems, be more specific and let me see the page.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #36
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Alright John go to the test forum where you have a account, click on the thread we have been testing on and scroll down to the quick reply and look over to the right and click on "Normal Reply" This brings up what has always been PB main posting window with all of the buttons, etc. The Quick Reply was very plain Jane but with the recent change to V5 people have dressed it up with virtually all the options that the Normal Reply spot has via plugins. The Normal Reply allows members in their profile settings to choose the Preview Mode or BBCode which is what the Quick Reply area is and has always been, no Preview Mode for the QR. When you use the image button on the NR spot and hit enter the photo instantly appears instead of the URL link code like the QR does. This alone may be a problem because PB treats both spots differently and I don't know if the image uploader will put the image in?

    I have added the button code in the templates there and here is the Normal Reply template code:
    Code:
    <div class="container new-area wysiwyg-area">
    	<div class="title-bar">
    		<h2>$[title_bar]</h2>
    	</div>
    	<div class="content cap-bottom">
    		$[form.header]
    			{if $[form.created_by_guest_name.input]}
    				<div class="guest_name">
    					<label>Guest Name:</label>
    					$[form.created_by_guest_name.input]
    				</div>
    			{/if}
    			<div class="subject_line">
    				<table>
    					<tr>
    						<td class="subject">
    							<label>Subject:</label>
    						</td>
    						<td>
    							<div class="controls">
    								$[poll_button]
    								$[event_button]
    								$[attachment_button]
    								$[options]
    							</div>
    							<div class="subject_input">
    								$[form.subject.input]
    							</div>
    						</td>
    					</tr>
    				</table>
    			</div>
    			{if $[form.recipients.input]}
    				<div class="recipients">
    					<label>Recipients:</label>
    					$[form.recipients.input]
    				</div>
    			{/if}
    			{if $[participant]}
    				<div class="participants">
    					Participants:
    					<span class="$[participant_list_class]">
    						{foreach $[participant]}$[participant]$[participant.comma] {/foreach}
    					</span>
    					{if $[change_participants_button]}($[change_participants_button]){/if}
    				</div>
    			{/if}
    			<div class="editor ui-helper-clearfix">
    				$[form.message.input]
    			</div>
    			{if $[form.updated_reason.input]}
    				<div class="edit_reason content-box pad-all-double">
    					<label>Edit Reason (optional):</label>
    					<div>$[form.updated_reason.input]</div>
    				</div>
    			{/if}
    			{if $[posting_errors]}
    				<div class="posting-errors">$[posting_errors]</div>
    			{/if}
    			$[captcha]
    			<div class="submit content-box pad-all-double">
    				<span class="float-right">$[form.post.button]<a href="javascript:void(0);" onclick="postimage_upload(0);" class="button">Insert Image</a></span>
    				<span class="note small left-item" id="$[transcription.id]"></span>
    			</div>
    			
    			<div id="show-attachment" class="attachment">
    				$[attachment_widget]
    			</div>
    		$[form.footer]
    	</div>
    </div>
    
    {if $[summary]}
    	<div class="container $[summary.class]">
    		<div class="title-bar">
    			<h2>$[summary.title]</h2>
    		</div>
    		<div class="content cap-bottom">
    			<table class="list">
    				<tbody class="$[list_class]">
    					$[summary]
    				</tbody>
    			</table>
    		</div>
    	</div>
    {/if}
    You can see where I inserted the button code. The Insert Image button is in the bottom right hand corner with two other buttons in the Normal Reply window.

    When you click on it all works correctly but here is where it fails. When you hit Upload the outside server host does it's job but the URL link will not appear in the post, I'm thinking because of the Preview Mode?

  7. #37
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,496
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Mmm, before we get too involved with this. Didn't you say that the normal reply already has its own insert image thing? If so, why not just use that?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #38
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    It has a menu icon just like here where one can take a URL link from their own outside image host or elsewhere and then insert it into the text and then hit Post Reply.

    PB on their last software V4 had what they called a "attachment" button and when pressed just like with this image host thing we finally got working it would copy and paste a URL or any image within a certain size from your own computer files to the forum, no worries or no need for a outside host like Photobucket. Only time you needed a outside host was if the image was bigger than they allowed. The one difference in the Normal Reply versus the QR is when you paste the URL link in it grabs is and puts the image in instantly before your eyes for you to Preview where as the QR puts the URL link in and the photo appears after you post your reply.

    But on V5 they decided due to their server load (or as they say it was) to limit the attachment button option to 100mb of storage, after that you can buy more storage (shoots down the server load theory) and a lot of forums mine included when converted from V4 to V5 already were over the limit thus this option is useless unless you want to pay. I donate all my time to keeping the forum up just like I'm donating my time to try to make this option work and I'm not going to pay a fee for image space on their server when I can and did remove the attachment button/feature from the forum and tell members to use their own host.

    But I do like a lot of forum owners have those who are very basic in computer knowledge and moan and groan about not knowing how to use a outside image host. This idea came to me when I was browsing PB for feature options for my forums and as I said before came across this image host thing from a person who made a plugin that now no longer works and has been abandoned. PB will not intervene on a persons work even if they have totally quit giving member support for it and that's why I started this project too.


    So if it is possible to make it work in the other posting area I would love to do so. My members will go nuts over this feature and I'm about to make a announcement about what we have done so far.
    Last edited by JRR; 02-27-2015 at 02:14 AM.

  9. #39
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,496
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    What we have so far is enough for most folks. I also understand what you are saying about the NR and will have a look. However, it seems pretty clear to me that the postimage script is intended primarily for QR and so will be difficult to adapt to NR. It might be impossible even, or at least beyond me. I will have look though as I say.

    Can you make a div with the class of message for the NR form? I'm not sure if it has to be a parent or a child of the NR form. It would probably have to be like the message class div for the QR form. I forget which it is at the moment (parent or child). Good thing it's a class (id's have to be unique) but that's no guarantee it will work, just a possibility.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  10. #40
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Not sure but I'll inquire and get back.

Similar Threads

  1. Please write a simple javascript code for me
    By laperashvili in forum JavaScript
    Replies: 2
    Last Post: 06-18-2012, 03:10 PM
  2. adding rollover button to javascript code
    By Repatilian in forum JavaScript
    Replies: 6
    Last Post: 12-04-2011, 10:28 AM
  3. Help with javascript code to make next and previous button dissapear
    By ajmancilla in forum Looking for such a script or service
    Replies: 1
    Last Post: 02-07-2011, 03:00 PM
  4. Looking for a simple Javascript code for a web board
    By donelian in forum Looking for such a script or service
    Replies: 1
    Last Post: 08-15-2007, 10:24 PM
  5. How to turn a menu into a javascript file?
    By Eternal_Howl in forum JavaScript
    Replies: 4
    Last Post: 07-23-2007, 07:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •