Hey it's me again! lately I've been thinking that I haven't done a web project in a long time, so I started brainstorming ideas. I thought and thought, and thought a little more, but nothing of good interest came to mind. Then I remembered a project a friend of mine did for his final project in his programming class. It is basically a userscript that parses a page for a certain tag and inserts html where ever this tag appears. so basically you could use a BBcode tag and insert html where ever you wanted. Now this is a pretty hard project for me do do alone, so I was thinking that this could be a group collaboration. My basic idea for this is to write a simple userscript that would allow you to access functions of Cemetech with code that you put in your posts. so basically you could type
Code:
[func=sax_chat_post]hello world[/func]
and it would create a link that when pressed would post hello world to sax. Or you could have a "[jsTIfied]" tag that would insert JsTIfied into the post with the selected program ready for use (ROM not included!). I mean the possibilities could be pretty cool. If anyone is interested in helping with this project, I would love the help a lot. please Post any ideas, comments or if you would like to help in the topic below!

PS. by the way fiddle is not dead im just throwing this out for future ideas.
it sounds interesting, but i wonder about the use of such functions, and whether it would clutter up that SAX as people use it.
Well that was just an example but if you have any ideas for this please let me know I think it would be a great Cemetech project.
I agree that the site is fairly static though Cemetech is already a heavily modded version of phpBB2. It'd be super hard to do anything client-side - even update phpBB! I encourage you to pursue this as best you can from a user-side perspective. Perhaps create a script that enhances part of the forum; Place "Original Poster" or "Topic Starter" in the user info at the left of each post, but only if the user is the person who started the post so people can quickly pick out their replies. That's one idea!

If and whenever we switch over to phpBB3 or another forum system, we'll come to you guys and see how we can make the site more dynamic.
For the life of me I cant get this code to add html to the page more than once and not mess up. can someone please help me?


Code:

<script type="text/javascript">
function htmlreplace(a, b, element) {   
    if (!element) element = document.body;   
    var nodes = element.childNodes;
    for (var n=0; n<nodes.length; n++) {
            var r = new RegExp(a, 'gi');
            nodes[n].innerHTML = nodes[n].textContent.replace(r, b);
    }
}

 htmlreplace('[red]','<font color="red">');
 htmlreplace('[/color]','</font">');
</script>
If anyone has any code or ideas I could use, please let me know. I think that this could add some cool features to Cemetech or even other sites if adapted correctly. So please any help would be great, because to tell you the truth I don't know much about Javascript.
spud2451 wrote:
If anyone has any code or ideas I could use, please let me know. I think that this could add some cool features to Cemetech or even other sites if adapted correctly. So please any help would be great, because to tell you the truth I don't know much about Javascript.


We appreciate it if you refrain from double posting within 24 hours. Most of us have 8 hour jobs or at school and in our studies for a good deal of the day and social lives outside of that - even a combination of all 3! Most topics will have a response in 12 hours but topics with a more specific audience will typically be longer.

There's another topic you double posted recently in but I'm not sure which one it was at the moment.
Personally, I'd iterate over the document with a TreeWalker, rather than brute-force string replacements. That'll help ensure the markup remains valid (replacements won't be able to begin in one node and end in another), and it's conceptually close to what you want.

At the very least, you also want to ensure there are closing tags before doing any replacement. Consider:
Code:
<p>[red]HAHAHA, NOW YOUR PAGE IS RED</p>
Exact behaviour depends on the browser's response to invalid markup, but there's a good chance the rest of the page's text will become red.
Generally speaking, though, simple regex searches to "parse" non-regular languages like this is a Bad Idea.
insert-spud
spud2451 wrote:
this is a test!
<font color=#ff0000> this is a test </font>
insert-jstified


Firstly: You might want to fully learn the syntax to HTML before you go and tackle something like this.

Secondly: This isn't very friendly to look at it. As someone who won't be downloading this script I will outright ignore your topics if they are all formatted for your script.

Secondly and a half: The best scripts change the existing formatting, such as this script that was then ultimately added to Cemetech.

Thirdly: Font colors are already present in BBCode.
Well anyways here's the script.


Code:

// ==UserScript==
// @name       The Ultimate Cemetech Userscript
// @namespace 
// @version    0.1
// @description Adds some awesome features to the Cemetech forums.
// @match
// @copyright  2013+, Nathaniel Fitzpatrick
// ==/UserScript==

var jstified = false

function replace(a,b){
var r = RegExp(a,"gi")
document.body.innerHTML = document.body.innerHTML.replace(r,b)
}


replace("color-red",'<font color=#ff0000>');
replace("color-green",'<font color=#00ff00>');
replace("color-blue",'<font color=#0000ff>');
if (jstified){
replace("insert-jstified",'<iframe allowtransparency="true" width="320" height="640" src="http://www.cemetech.net/projects/jstified/" frameborder="0"></iframe>');
}
replace("color-end",'</font>');
replace("0x5",'LOL');
replace("KermMartian",'KermM');
replace("spud2451",'Spud');
replace("ComicIdiot",'Comic');
replace("insert-kermm",'<input type="button" value="KermM++" onClick="document.getElementById(\'saxtalk\').value = \'KermM++\';saxAdd();">');
replace("insert-spud",'<input type="button" value="Spud++" onClick="document.getElementById(\'saxtalk\').value = \'Spud++\';saxAdd();">');
replace("insert-comic",'<input type="button" value="Comic++" onClick="document.getElementById(\'saxtalk\').value = \'Comic++\';saxAdd();">');
replace("insert-luxen",'<input type="button" value="Luxen++" onClick="document.getElementById(\'saxtalk\').value = \'Luxen++\';saxAdd();">');

I sure hope you fix me name! im Luxen, not Luxin!

also, if you used it to affect your tag as red, it only seems to effect the last one. your previous posts have a normal colored tag.
Ok Luxen I changed the name. also here are the tags you can use:

color-red
color-green
color-blue
insert-JsTIfied
insert-KermM
insert-Spud
insert-Comic
insert-Luxen
cant make it Insert-"Name" and it works to do a ++ to "Name"?
Spud++
I finally tried this out and I am impressed.
Actually, I found a practical use for your ++ing code. In fact, it might be a nifty feature to have site-wide. I looked at your code last night and thought, wouldn't it be great to have a "Like This Project" button in the "Your Projects" subfora. Essentially, what it would do is ++ the user who made the project.
this could actually justify me making a bot. this bot will keep track of likes and then send them to a file which I can then use with the userscript to display the number of likes on pages.
spud2451 wrote:
this could actually justify me making a bot. this bot will keep track of likes and then send them to a file which I can then use with the userscript to display the number of likes on pages.


I like that idea, perhaps you can start a collaboration with Merth to use the same DecBot counts. Be prepared for the overhead though, you'll need to catch what posts have already been tallied so subsequent page loads from other (and the same) users don't increase the counts.
this is a test for the new version of the script
[karma]spud2451[/karma]
Does anyone have any ideas for bb code that they want me to put into the script?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement