A friend of mine asked me a favor, help him to install CK Editor into SnitzForum (yeah old I know). Since I am not into asp lang. I have a problem since after putting into the head the CDN code I have to put below the tag this code:
<script> CKEDITOR.replace( 'editor1' ); </script>
So this is the part where the textarea is into the file post.asp:
<%
end if
end if
Response.Write " </font></td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" </table>" & vbNewLine & _
" </font></td>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """><textarea cols=""" & intCols & """ name=""editor1"" rows=""" & intRows & """ wrap=""VIRTUAL"" onselect=""storeCaret(this);"" onclick=""storeCaret(this);"" onkeyup=""storeCaret(this);"" onchange=""storeCaret(this);"">" & Trim(CleanCode(TxtMsg)) & "</textarea><br /></td>" & vbNewLine & _
" </tr>" & vbNewLine
end if
select case strRqMethod
case "Reply", "ReplyQuote", "TopicQuote"
Response.Write " <script language=""JavaScript"" type=""text/javascript"">document.PostTopic.Message.focus();</script>" & vbNewLine
end select
How can I add that script? Thanks :)
Edited Code:
<!--#INCLUDE FILE="inc_smilies.asp" -->
<%
end if
end if
Response.Write " </font></td>" & vbNewLine & _
" </tr>" & vbNewLine & _
" </table>" & vbNewLine & _
" </font></td>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """><textarea cols=""" & intCols & """ name=""Message"" rows=""" & intRows & """ wrap=""VIRTUAL"" onselect=""storeCaret(this);"" onclick=""storeCaret(this);"" onkeyup=""storeCaret(this);"" onchange=""storeCaret(this);"">" & Trim(CleanCode(TxtMsg)) & "</textarea><br /></td>" & vbNewLine & _
" </tr>" & vbNewLine
%>
<script>
tinymce.init({
selector: 'textarea',
toolbar_mode: 'floating',
});
</script>
<%
end if
select case strRqMethod
case "Reply", "ReplyQuote", "TopicQuote"
Response.Write " <script language=""JavaScript"" type=""text/javascript"">document.PostTopic.Message.focus();</script>" & vbNewLine
end select
Ok, so an working example with a text box could (would) be this:
<script src="https://cdn.ckeditor.com/4.16.2/standard/ckeditor.js"></script>
<div style="width:50%">
<asp:TextBox ID="TextBox1" runat="server" Height="304px" Width="617px"
TextMode="MultiLine"
ClientIDMode="Static"
></asp:TextBox>
</div>
<script>
CKEDITOR.replace('TextBox1');
</script>
And we now get this:
So, as noted, it probably better to hide/show the one div above, then trying to inject the above markup into the page. And the REASON why is that then in code behind, you want to be able to get the textbox by using
TextBox1.text
So, by placing a plane jane text box (TextBox1) on the form, then code behind can use that text box. If you inject the markup, then code behind will have a much more difficult time using that markup and using TextBox1.Text to get the results of the markup in that text box.
So I don't see the need to use "code" to inject the above. As I noted, perhaps you need to hide/show this?
Then add a "ID" to the div like this:
<div id="mycooleditor" runat="server" style="width:35%;display:none">
<asp:TextBox ID="TextBox1" runat="server" Height="304px" Width="617px"
TextMode="MultiLine"
ClientIDMode="Static"
></asp:TextBox>
</div>
Now, in code behind, to display the editor, we can go:
mycooleditor.Style.Add("display", "normal")
So, unless you make a REALLY good case as to why we using code to inject the html into the web page as opposed just dropping in the markup as per above without any code (and saving world poverty's at the same time), then I see no reason to spend the time + effort writing code that does the same thing?
You can write code to inject, but I see no reason why when you can just drop in the markup anyway???
Overworked. Put the tinymce files in their own folder (titled "tinyMCE") below the forum root. In the file "inc_header.asp", look for this code (appx lines 240-242):
'## START - REMOVAL, MODIFICATION OR CIRCUMVENTING THIS CODE WILL VIOLATE THE SNITZ FORUMS 2000 LICENSE AGREEMENT
Response.Write "<meta name=""copyright"" content=""This Forum code is Copyright (C) 2000-09 Michael Anderson, Pierre Gorissen, Huw Reddick and Richard Kinser, Non-Forum Related code is Copyright (C) " & strCopyright & """>" & vbNewline
'## END - REMOVAL, MODIFICATION OR CIRCUMVENTING THIS CODE WILL VIOLATE THE SNITZ FORUMS 2000 LICENSE AGREEMENT
Below that bit, insert this:
If strScriptName = "post.asp" Then
Response.Write " <script src=""./tinyMCE/tinymce.js""></script>" & vbNewLine & _
" <script language=""Javascript"">tinymce.init ({" & vbNewLine & _
" selector:'textarea'," & vbNewLine & _
" theme:'modern'," & vbNewLine & _
" browser_spellcheck:'true'," & vbNewLine & _
" plugins:['advlist anchor autolink charmap code contextmenu directionality emoticons fullscreen hr insertdatetime image link lists media nonbreaking paste print preview pagebreak save searchreplace table template textcolor visualblocks visualchars wordcount']," & vbNewLine & _
" content_css:'css/combined-min.css'," & vbNewLine & _
" toolbar:'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | preview media fullpage | forecolor backcolor emoticons'," & vbNewLine & _
" });</script>" & vbNewLine
End If
That will take over all instances of the text area in "post.asp". If you want to use it throughout the forum for text areas, remove the If/End If lines.
Related
I have an AppleScript that creates a new (HTML-formatted) email in Outlook. I have everything working the way I want but I can't seem to change the color of some of the text within the body of the email. Can this be done via AppleScript?
Thank you in advance,
Jon :-)
Here is a simple example of a body with some red text that can be included in your email creation Applescript:
set theContent to ("Hi:" & "<br>" & "<br>" & "Second <span style=" & "color:red;" & ">word</span> is red." & "<br>" & "<br>" & "Bye," & "<br>" & "<br>" & "Buddy")
Below I have my dilemma. I need to get the txtPreview.Value copied to the clipboard and the end of the UpdatePreview sub. As it is showing here, I have the sub UpdatePreview to flood specific data and values from other parts of the page to a preview pane, and the button below to run said sub. I can't seem to get the right combination of things to have the txtPreview.Value copy to the clipboard.
Sub UpdatePreview
txtPreview.Value = "Customer/Agency " &_
vbNewLine & Customer.Value & " / " & AgencyName.value & " #" & AgencyID.value &_
vbNewLine &_
vbNewLine & "1. QUESTIONS/NEEDS/VALUE" &_
vbNewLine & issue1.value &_
vbNewLine &_
vbNewLine & "2. TROUBLESHOOTING" &_
vbNewLine & issue2.value &_
vbNewLine &_
vbNewLine & "3. SOLUTIONS " &_
vbNewLine & issue3.value &_
vbNewLine &_
vbNewLine & "4. OUTCOME " &_
vbNewLine & issue4.value &_
vbNewLine &_
vbNewLine
End Sub
<input type="button" class="note" value="Preview" OnClick=UpdatePreview>
<html>
<body>
<script language=vbscript>
document.write document.parentwindow.clipboardData.GetData("TEXT")
</script>
</body>
</html>
To put text on the clipboard use document.parentwindow.clipboardData.SetData "TEXT", txtPreview.Value
See slimmed down code. I'm essentially creating a list of items (printers) along with a dynamically created unique radio button ID, and then I'd like to be able reference said Radio ID in order to toggle the Checked between True/False in Sub SetDefaultPrinter. Why? Because using Add Devices / Search is too hard for some of our users, hence, a cute little GUI. Why dynamic? Because I have multiple separate networks and I'd prefer the script to adjust itself as needed.
<html>
<head>
<title>My HTML application</title>
<HTA:APPLICATION
APPLICATIONNAME="My HTML application"
ID="MyHTMLapplication"
VERSION="1.0"/>
</head>
<script language="VBScript">
Public jj, strPrinters, strModels, strLocations
Sub Window_OnLoad
strPrinters = Array("Printer1", "Printer2")
strModels = Array("HP Color LaserJet 4525", "HP Color LaserJet 4525")
strLocations = Array("Room 1", "Room 2")
jj = UBound(strPrinters)
Call OnClickGo()
End Sub
Sub OnClickGo()
DataArea1.InnerHTML = ""
For i = 0 To jj
DataArea1.InnerHTML = DataArea1.InnerHTML & "<BR><font style=color:green;font-weight=bold;>" &_
"<input type=""" & "radio""" & " name=""" &_
strPrinters(i) & "Radio""" & " id=""" & "Radio" & i & """" &_
" title=""" & "Clicking here will set " & strPrinters(i) & " as default printer.""" &_
" onclick=""" & "SetDefaultPrinter(" & i & ")""" & " onmouseover=""" & "Pointer""" &_
" onmouseout=""" & "DefaultCursor""" & "></input>" &_
"<span id=""" & strPrinters(i) & "Span""" &_
" title=""" & "Click here delete printer mapping for " & strPrinters(i) & """" &_
" onmouseover=""" & "Pointer""" & " onmouseout=""" & "DefaultCursor""" &_
" onclick=""" & "OnClickDelete(" & i & ")""" &_
">" & strPrinters(i) & ", " & strModels(i) & ", Location: " & strLocations(i) & "</span></font>"
Next
End Sub
'========================================
'= Set Default Printer ==================
'========================================
Sub SetDefaultPrinter(ii)
DataArea2.InnerHTML = strPrinters(ii) & " would have been set as default if this was fully functional."
'
' Radio0 and Radio1 are dynamically created IDs, *really* want to somehow
' dynamically reference the dynamically created IDs.
' i.e. something like
' If ii <> 0 Then (Radio & ii).checked = False
'
If ii <> 0 Then Radio0.checked = False
If ii <> 1 Then Radio1.checked = False
End Sub
'========================================
'= Delete Printer Mapping ===============
'========================================
Sub OnClickDelete(ii)
DataArea2.InnerHTML = strPrinters(ii) & " would have been deleted if this was fully functional."
'Set wshnetwork = CreateObject("WScript.Network")
'wshnetwork.RemovePrinterConnection "\\SERVER\" & strPrinters(PrinterToDelete)
End Sub
'========================================
'= MOUSE Pointers =======================
'========================================
Sub Pointer
document.body.style.cursor = "hand"
End Sub
Sub DefaultCursor
document.body.style.cursor = "default"
End Sub
</script>
<body bgcolor="white">
<span id="DataArea1"></span>
<BR><BR><BR>
<span id="DataArea2"></span>
</body>
</html>
user2345916, I have modified your code where the variables pass like you wanted. I left your comments intact, so you can pick up where you left off. Hope this helps!
Basically, the answer to your problem lies within the button's "ID", "VALUE" and "ONCLICK" values.
The ONCLICK='SetDefaultPrinter(" & i & ")' will pass the looped number to the SubRoutine.
The SetDefaultPrinter(Radioii) sets a variable from the "ONCLICK" field of the button that sends you to that SubRoutine (In this case, it's a 0 or 1).
The "FileName = document.getElementById("Radio" & Radioii).value" gets the "VALUE" field of the button that matches the "ID" field that is set between the "()", which in your case is also the variable that was pulled from the ONCLICK.
From here, you can use (FileName) variable to do whatever you want (Match IF/THEN, etc)
<script language=vbscript>
Sub Window_OnLoad
window.resizeTo 500,300
strPrinters = Array("Printer 1", "Printer 2")
strModels = Array("HP Color LaserJet 4525", "HP Color LaserJet 4525")
strLocations = Array("Room 1", "Room 2")
jj = UBound(strPrinters)
For i = 0 To jj
strHTML1 = "<span id='Delete" & i & "' value='" & strPrinters(i) & "'title='Click here delete printer mapping for " & strPrinters(i) & "' onmouseover='Pointer' onmouseout='DefaultCursor' onclick='OnClickDelete(" & i & ")'> " & strPrinters(i) & " - " & strModels(i) & ", Location: " & strLocations(i) & "</span>"
strHTML2 = strHTML2 & "<input type='radio' name='radio' value='" & strPrinters(i) & "' id='Radio" & i & "' title='Clicking here will set " & strPrinters(i) & " as default printer.' onclick='SetDefaultPrinter(" & i & ")' onmouseover='Pointer' onmouseout='DefaultCursor'>" &_
"" & strHTML1 & "</input><br>"
DataArea1.InnerHTML = strHTML2
Next
End Sub
'========================================
'= Set Default Printer ==================
'========================================
Sub SetDefaultPrinter(Radioii)
FileName = document.getElementById("Radio" & Radioii).value
DataArea3.InnerHTML = Filename & " would have been set as default if this was fully functional."
'
' Radio0 and Radio1 are dynamically created IDs, *really* want to somehow
' dynamically reference the dynamically created IDs.
' i.e. something like
' If ii <> 0 Then (Radio & ii).checked = False
'
If Radioii = 0 Then Radio0 = False
If Radioii = 1 Then Radio1 = False
End Sub
'========================================
'= Delete Printer Mapping ===============
'========================================
Sub OnClickDelete(Deleteii)
RemoveName = document.getElementById("Delete" & Deleteii).value
DataArea3.InnerHTML = RemoveName & " would have been deleted if this was fully functional."
'Set wshnetwork = CreateObject("WScript.Network")
'wshnetwork.RemovePrinterConnection "\\SERVER\" & strPrinters(PrinterToDelete)
End Sub
'========================================
'= MOUSE Pointers =======================
'========================================
Sub Pointer
document.body.style.cursor = "hand"
End Sub
Sub DefaultCursor
document.body.style.cursor = "default"
End Sub
</script>
I asked a few month back how to hide a few drop down option on a Classic ASP page which were being pulled from a database so that users could not select those options. But now on one of the remaining options there appear 3 radio box options. I have to remove one of those options. The option which I need to remove is called value="_BML7(B)" according to Chrome.
The last time I inserted the following code into the following code into the include.asp file which worked great but that was to hide drop down options. This I need to hide one radio button option from the current drop down options.
Sub buildDropDownList(strCurrentSelection, objListData, strCodeName, strDescriptionName, blnIncludeOther)
If Not objListData.BOF Then
objListData.MoveFirst
End If
Dim currentCodeValue
While Not objListData.EOF
currentCodeValue = objListData(strCodeName)
If (UCase(currentCodeValue)<>"_04GIDBM") And _
(UCase(currentCodeValue)<>"_05GIDFM") And _
(UCase(currentCodeValue)<>"_03MIS(Q") And _
(UCase(currentCodeValue)<>"_06GIDMS") And _
(UCase(currentCodeValue)<>"_08EXHRM") And _
(UCase(currentCodeValue)<>"_10EXMKT") And _
(UCase(currentCodeValue)<>"_12EXTTH") And _
(UCase(currentCodeValue)<>"_15AFT") And _
(UCase(currentCodeValue)<>"_16HSC") And _
(UCase(currentCodeValue)<>"_18LTD") And _
(UCase(currentCodeValue)<>"_19EBM") And _
(UCase(currentCodeValue)<>"_17EXHSC") Then
Response.Write "<option value='" & currentCodeValue & "' "
If StrComp(strCurrentSelection, currentCodeValue, 1) = 0 then
Response.Write "selected"
End If
Response.Write ">" & objListData(strDescriptionName) & "</option>" & VbCrLf
End If
I could really use the help on this and thank everyone in advance for their help! I not very good with Classic ASP but I'm trying.
Here is the code that I inserted last time on the include.asp file.
<p align="center">
<%
do until rsProgramLevel.EOF
Response.Write "<input type=""radio"" name=""programcode"" onclick=""onProgramCode()"" "
Response.Write "value=""" & rsProgramLevel("ProgramCode") & """ "
if rsProgramLevel("ProgramCode") = strProgramCode then
Response.Write "checked"
end if
Response.Write ">"
Response.Write " "
Response.Write rsProgramLevel("LevelDescription") & " (£" & FormatNumber(rsProgramLevel("ChargeValue"), 2) & ") "
Response.Write " "
rsProgramLevel.MoveNext
loop
%>
</p>
You could compile the list into a string, like so...
Const ignoreCodes = " _04GIDBM _05GIDFM _03MIS(Q _06GIDMS _08EXHRM _10EXMKT _12EXTTH _15AFT _16HSC _18LTD _19EBM _17EXHSC "
Add it to the very top of your file (after any Option Explicit commands). If you have new codes to add to it simply ensure that there's a space either side of it.
Then just test against it...
If Instr(ignoreCodes, UCase(currentCodeValue)) = 0 Then
Response.Write("<option value='" & currentCodeValue & "' ")
If StrComp(strCurrentSelection, " " & currentCodeValue & " ", 1) = 0 then
Response.Write " selected "
End If
Response.Write(">" & objListData(strDescriptionName) & "</option>")
End If
If you think about this further, then simply include the list in a redundant codes table in a database.
To make this simple, just wrap the code sending the HTML with a basic If..Then statement:
Dim currentCode
do until rsProgramLevel.EOF
currentCode = rsProgramLevel("ProgramCode")
If UCase(currentCode)<>"_BML7(B)" Then
Response.Write "<input type=""radio"" name=""programcode"" onclick=""onProgramCode()"" "
Response.Write "value=""" & currentCode & """ "
if rsProgramLevel("ProgramCode") = strProgramCode then
Response.Write "checked"
end if
Response.Write ">"
Response.Write " "
Response.Write rsProgramLevel("LevelDescription") & " (£" & FormatNumber(rsProgramLevel("ChargeValue"), 2) & ") "
Response.Write " "
End If
rsProgramLevel.MoveNext
loop
I am maintaining a site that uses a HTML editor with an image upload feature. When you click upload it opens a popup that lists a path to every image in the folder. There are currently more than 7000 images in the folder.
The code is quite messy. It uses the Scripting.FileSystemObject to get an array of the files and then loops using a for each statement.A response.write is used to display each file's info and for some reason an issue is occurring if there's more than 4015 images in the folder. No error is occurring as such but it seems the function writing out the files just fails silently and the page stops rendering.
I am confused why it works when there's less than 4015 files. Could it be a memory issue ? I was expecting to receive an error of some sort.
Thanks for any info.
Below is the Response.Write being used for each file
Response.Write "<tr style='background:" & sColorResult & "'>" & VbCrLf & _
"<td><img src='images/"&sIcon&"'></td>" & VbCrLf & _
"<td valign=top width=100% ><u id=""idFile"&nIndex&""" style='cursor:pointer;' onclick=""selectFile(" & nIndex & ")"">" & oFile.name & "</u> <img style='cursor:pointer;' onclick=""downloadFile(" & nIndex & ")"" src='download.gif'></td>" & VbCrLf & _
"<td valign=top align=right nowrap>" & FormatNumber(oFile.size/1000,1) & " kb </td>" & VbCrLf & _
"<td valign=top nowrap onclick=""deleteFile(" & nIndex & ")""><u style='font-size:10px;cursor:pointer;color:crimson' " & sFolderAdmin & ">" & VbCrLf
if not bWriteFolderAdmin then
Response.Write "<script>document.write(getTxt('del'))</script>" & VbCrLf
end if
Response.Write "</u></td></tr>" & VbCrLf
Sounds like the issue here was the response buffer filling up. Either of these solutions should work:
Disable buffering by adding Response.Buffer = False as the first line of code.
Leave buffering enabled but call Response.Flush() at certain intervals to flush the buffer.