Advertisement:

Author Topic: URL Popup  (Read 20845 times)

Offline radu81

  • Jr. Member
  • **
  • Posts: 316
  • Gender: Male
Re: URL Popup
« Reply #20 on: May 05, 2014, 02:19:51 PM »
Simple and powerful, thank you Arantor!
sorry for my bad english

Offline Buneduggy

  • Semi-Newbie
  • *
  • Posts: 95
  • Gender: Male
    • NorCalWheelers
Re: URL Popup
« Reply #21 on: May 07, 2014, 09:17:29 PM »
The really odd thing is I wrote this almost 4 years ago just never published it here...

I just saw this on here and wanted to thank Arantor for this mod. I have been using it for years and it has always worked flawlessly.

Offline fapencio

  • Jr. Member
  • **
  • Posts: 141
  • Gender: Male
    • medilibros
Re: URL Popup
« Reply #22 on: July 30, 2014, 01:22:32 PM »
Hi @‽  Arantor, your mod is awesome, but i have a problem, in the body post without WYSIWYG the mod write this:

Code: [Select]
[url=http://myurl.com]titleofmyurl[/url][url][/url]
i have to delete manually this:
Code: [Select]
[url][/url] for the mod works, please help

My smf forum is 2.0.10 version
my theme is default
language spanish es utf8

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,732
    • Arantor on GitHub
Re: URL Popup
« Reply #23 on: July 30, 2014, 01:24:06 PM »
What other mods are you using? This does not happen when this is the only mod installed.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

Offline fapencio

  • Jr. Member
  • **
  • Posts: 141
  • Gender: Male
    • medilibros
Re: URL Popup
« Reply #24 on: August 01, 2014, 10:57:43 AM »
What other mods are you using? This does not happen when this is the only mod installed.

Hi Arantor @‽  my mods:

1.   QR Code BBcode    1.0.1     
2.   IMG Popup    1.0.2     
3.   Separated Birthdays from Events    1.1.7     
4.   SMF 2.0.8 Update    1.0     
5.   Enhanced PM System    1.1     
6.   Countdown BBCode    2.0.2     
7.   Reason For Editing Mod    2.3.2     
8.   Enhanced Dropdown    1.3     
9.   Post_Board_Select    1.3     
10.   Tabbed smileys    0.3.99c 
11.   URL Popup    1.0.2 

thanks
My smf forum is 2.0.10 version
my theme is default
language spanish es utf8

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,732
    • Arantor on GitHub
Re: URL Popup
« Reply #25 on: August 01, 2014, 10:59:37 AM »
Does it behave if you uninstall img popup?
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

Offline fapencio

  • Jr. Member
  • **
  • Posts: 141
  • Gender: Male
    • medilibros
Re: URL Popup
« Reply #26 on: August 01, 2014, 03:24:22 PM »
Does it behave if you uninstall img popup?

yes, but a new problem emerged in the second pop-up window that appears:



help please (i uninstall img popup)
My smf forum is 2.0.10 version
my theme is default
language spanish es utf8

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,732
    • Arantor on GitHub
Re: URL Popup
« Reply #27 on: August 01, 2014, 03:25:58 PM »
o.O I have no idea what's hapened there. I'll see if I can find some time to investigate but I am pretty swamped with paid mod work right now.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

Offline fapencio

  • Jr. Member
  • **
  • Posts: 141
  • Gender: Male
    • medilibros
Re: URL Popup
« Reply #28 on: August 01, 2014, 03:46:50 PM »
o.O I have no idea what's hapened there. I'll see if I can find some time to investigate but I am pretty swamped with paid mod work right now.

i uninstall your mod, url popup, and I installed again, an now work perfect!!!!!!

but now I'm afraid to install the mod img popup  :(
My smf forum is 2.0.10 version
my theme is default
language spanish es utf8

Offline Steve

  • Support Specialist
  • SMF Hero
  • *
  • Posts: 4,301
  • Gender: Male
  • I have not yet begun to procrastinate.
Re: URL Popup
« Reply #29 on: August 01, 2014, 04:03:33 PM »
Backup your database and try it. If it doesn't work, uninstall it and live without one or the other until he gets time to look at the problem. :P
Online Manual

Please do not PM me for support.

Offline fapencio

  • Jr. Member
  • **
  • Posts: 141
  • Gender: Male
    • medilibros
Re: URL Popup
« Reply #30 on: August 01, 2014, 04:36:43 PM »
Backup your database and try it. If it doesn't work, uninstall it and live without one or the other until he gets time to look at the problem. :P

I tested several modifications to the code until I came to the solution, it is important and mandatory to have installed both mods, both url popup as img popup when installing the second mod installation error which should ignore appear, then open the file called editor.js found in the Themes/default/scripts/editor.js route or in your forum theme, I leave the solution:

if you installed first URL POPUP and then IMG POPUP

in editor.js
search:
Code: [Select]
// URL popup?
if (oButtonProperties.sCode == 'url')
{
// Ask them where to link to.
var sText = prompt(oEditorStrings['prompt_text_url'], 'http://');
if (!sText)
return;

var sDesc = prompt(oEditorStrings['prompt_text_desc']);
if (!sDesc || sDesc == '')
sDesc = sText;

var bbcode = '[url=' + sText + ']' + sDesc + '[/url]';
replaceText(bbcode.replace(/\\n/g, '\n'), this.oTextHandle);
}
// Replace?
else if (!('sAfter' in oButtonProperties) || oButtonProperties.sAfter == null)

replace:
Code: [Select]
// URL popup?
if (oButtonProperties.sCode == 'url')
{
// Ask them where to link to.
var sText = prompt(oEditorStrings['prompt_text_url'], 'http://');
if (!sText)
return;

var sDesc = prompt(oEditorStrings['prompt_text_desc']);
if (!sDesc || sDesc == '')
sDesc = sText;

var bbcode = '[url=' + sText + ']' + sDesc + '[/url]';
replaceText(bbcode.replace(/\\n/g, '\n'), this.oTextHandle);
}
// IMG popup?
else if (oButtonProperties.sCode == 'img')
{
// Ask them where to link to.
var sText = prompt(oEditorStrings['prompt_text_url'], 'http://');
if (!sText)
return;

var bbcode = '[img]' + sText + '[/img]';
replaceText(bbcode.replace(/\\n/g, '\n'), this.oTextHandle);
}
// Replace?
else if (!('sAfter' in oButtonProperties) || oButtonProperties.sAfter == null)

if you installed first IMG POPUP and then URL POPUP

in editor.js
search:
Code: [Select]
// IMG popup?
if (oButtonProperties.sCode == 'img')
{
// Ask them where to link to.
var sText = prompt(oEditorStrings['prompt_text_url'], 'http://');
if (!sText)
return;

var bbcode = '[img]' + sText + '[/img]';
replaceText(bbcode.replace(/\\n/g, '\n'), this.oTextHandle);
}
// Replace?
else if (!('sAfter' in oButtonProperties) || oButtonProperties.sAfter == null)

replace:
Code: [Select]
// IMG popup?
if (oButtonProperties.sCode == 'img')
{
// Ask them where to link to.
var sText = prompt(oEditorStrings['prompt_text_url'], 'http://');
if (!sText)
return;

var bbcode = '[img]' + sText + '[/img]';
replaceText(bbcode.replace(/\\n/g, '\n'), this.oTextHandle);
}

// URL popup?
else if (oButtonProperties.sCode == 'url')
{
// Ask them where to link to.
var sText = prompt(oEditorStrings['prompt_text_url'], 'http://');
if (!sText)
return;

var sDesc = prompt(oEditorStrings['prompt_text_desc']);
if (!sDesc || sDesc == '')
sDesc = sText;

var bbcode = '[url=' + sText + ']' + sDesc + '[/url]';
replaceText(bbcode.replace(/\\n/g, '\n'), this.oTextHandle);
}
// Replace?
else if (!('sAfter' in oButtonProperties) || oButtonProperties.sAfter == null)

thats all, best regards
My smf forum is 2.0.10 version
my theme is default
language spanish es utf8

Offline CarefreeSadie

  • Semi-Newbie
  • *
  • Posts: 10
    • Non-Conformists
Re: URL Popup
« Reply #31 on: August 05, 2014, 04:09:21 PM »
Thank you very much for creating this mod.  I like it a lot.

Offline Taifuuni

  • Newbie
  • *
  • Posts: 5
Re: URL Popup
« Reply #32 on: August 18, 2014, 10:09:08 AM »
Anyway to modify this to automatically input selected text to the URL name input box?

I mean this:

1. Write something.
2. Highlight a word/words.
3. Press URL button.
4. URL popup appears and you input the URL you want.
5. You press OK and in the URL name input box, you already have the word/words you have highlighted on step 2.
6. You press OK and you get the proper url bbcode.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,732
    • Arantor on GitHub
Re: URL Popup
« Reply #33 on: August 18, 2014, 10:51:58 AM »
IIRC it would need a rewrite to do that and I don't have time at present, sorry.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

Offline CarefreeSadie

  • Semi-Newbie
  • *
  • Posts: 10
    • Non-Conformists
Re: URL Popup
« Reply #34 on: August 26, 2014, 03:05:12 PM »
Thank you very much for this mod.  I used one before and now after moving to 2.08 I have installed this one.  It works perfectly and the users are happy.  Thank you again.

Offline unseenua

  • Newbie
  • *
  • Posts: 8
Re: URL Popup
« Reply #35 on: October 01, 2014, 04:04:06 AM »
Anyway to modify this to automatically input selected text to the URL name input box?

I mean this:

1. Write something.
2. Highlight a word/words.
3. Press URL button.
4. URL popup appears and you input the URL you want.
5. You press OK and in the URL name input box, you already have the word/words you have highlighted on step 2.
6. You press OK and you get the proper url bbcode.

You can do it by self. Here are how I did this:

1. Open editor.js and add to beginning this code:

Code: [Select]
/* Here we get selected text for URL popup when RichText is in Disabled mode */
function getSelectionText() {
    var text = "";
    if (window.getSelection) {
        text = window.getSelection().toString();
    } else if (document.selection && document.selection.type != "Control") {
        text = document.selection.createRange().text;
    }
    return text;
}

2. Find string "URL popup?" and replace the code below on this one:
Code: [Select]
// URL popup?
if (oButtonProperties.sCode == 'url')
{
// Ask them where to link to.
var sText = prompt(oEditorStrings['prompt_text_url'], 'http://');
if (!sText)
return;

var sDesc = getSelectionText();
if (!sDesc || sDesc == '')
var sDesc = prompt(oEditorStrings['prompt_text_desc']);
if (!sDesc || sDesc == '')
sDesc = sText;

var bbcode = '[url=' + sText + ']' + sDesc + '[/url]';
replaceText(bbcode.replace(/\\n/g, '\n'), this.oTextHandle);
}

How it works.
Initially, the script checks to see if the selected text. If it is, it takes it as a description. If no text has been selected, the dialog box appears in which the user is prompted to enter a description. If the user does not enter a description and click OK, script insert raw URL as link anchor.

P.S. Code of function getSelectionText I took from hxxp:stackoverflow.com/questions/5379120/get-the-highlighted-selected-text [nonactive]

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,691
  • Mod King
    • XPtsp.com Community
Re: URL Popup
« Reply #36 on: December 29, 2014, 07:06:19 PM »
Hey, Arantor....  I was wondering if I could get permission from you to use a variation of this mod in order to add a URL prompt to my Sports bbcode mod.  I need it to get the URL from the user, then the mod would go to that URL and get the video ID cause it's just a world of pain to try to find it manually for that particular website....

Thanks in advance for your time!
News: Missing GitHub repository...

My Free Simple Machines mods on XPtsp.com, Simple Machines Customization Site, and at GitHub!
Problem uninstalling mods?  Try Arantor's Sortable Packages (and Installed Time) mod!  It's super helpful!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,732
    • Arantor on GitHub
Re: URL Popup
« Reply #37 on: December 29, 2014, 07:10:45 PM »
Go nuts :)
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,691
  • Mod King
    • XPtsp.com Community
Re: URL Popup
« Reply #38 on: December 30, 2014, 04:00:58 AM »
Cool!  Thanks!
News: Missing GitHub repository...

My Free Simple Machines mods on XPtsp.com, Simple Machines Customization Site, and at GitHub!
Problem uninstalling mods?  Try Arantor's Sortable Packages (and Installed Time) mod!  It's super helpful!

Offline bjornforum

  • Semi-Newbie
  • *
  • Posts: 43
Re: URL Popup
« Reply #39 on: January 26, 2015, 06:17:31 AM »
The code from unseenua doesn't seem to work in Firefox and IE. I found this alternative[/url] (in the answer) that works also in IE and Firefox:

Code: [Select]
function getSelectionText() {
    if (window.getSelection) {
        try {
            var ta = $('textarea').get(0);
            return ta.value.substring(ta.selectionStart, ta.selectionEnd);
        } catch (e) {
            console.log('Cant get selection text')
        }
    }
    // For IE
    if (document.selection && document.selection.type != "Control") {
        return document.selection.createRange().text;
    }
}

P.S. I would like to link to my source but am not allowed to post external links..