Skip to content

Instantly share code, notes, and snippets.

View meltingice's full-sized avatar

Ryan LeFevre meltingice

View GitHub Profile
/*
* this.getTextSelection()
* Utility function that returns the text that is selected
* and is cross-browser compatible.
*/
OsimoEditorControls.prototype.getTextSelection = function(){
var textarea = $('#'+this.input+'_editbox').get(0);
if (window.getSelection) {
var len = textarea.value.length;
var start = textarea.selectionStart;
var that = this;
Overlay = {
init: function(elementToOverlay, content, options) {
that.options = $.extend({
element: 'div',
attributes: {}
}, options);
that.overlay = $(html[that.options.element](that.options.attributes, content))
.click(that.hideOverlay)
<%% using(common) %%>
<%% common/header() %%>
page content
<%% common/footer() %%>
<?
private function parse_view($html){
$html = preg_replace(
array(
"/\{using ([^}]*)\}/i",
"/\{include ([^}]*)\}/i",
"/\{func ([A-Za-z_]*)->([^}]*)\(([^\)]*)\)\}/i"
),
array(
"<?
== About this Gist ==
I can't figure out wtf is going on here. Something strange with variable scope that I can't quite wrap my mind around.
If anyone knows the solution, please email me at meltingice@meltingice.net
This is a huge generalization of my code... some of the functions here aren't even a part of my codebase,
but they will still produce the same result and they are easier to understand because of their simplicity.
Also, I am using either PHP 5.3.0 or PHP 5.2.8 for this code.
== Where to Start ==
<?php
/*
* Osimo - next-generation forum system
* Licensed under GPLv3 (GPL-LICENSE.txt)
*
* os-includes/bbcode/bbparser.php - osimo's bbcode parser
* This can be used on any site, just call bb2html()
*/
function bb2html($post)
<? get('data')->load_post_list(); ?>
<? get('theme')->include_header(); ?>
<div id="content">
<div class="thread_title">
<h1><? get('data')->thread_title(); ?></h1>
<h2><? get('data')->thread_description(); ?></h2>
</div>
<? if(get('data')->are_posts()): while(get('data')->has_posts()): ?>
var yourVar;
$.ajax({
type:'POST',
url:'someurl',
data:someData,
success: function(data){
yourVar = data;
}
});
var artifact;
$.ajax({
type: "GET",
url: file,
function __autoload($class){
$classes = array(
'OsimoBBParser'=>'bbparser',
'OsimoForum'=>'forum',
'OsimoModel'=>'osimomodel',
'OsimoPost'=>'post',
'OsimoThread'=>'thread',
'OsimoUser'=>'user'
);
$modules = array(