Determine File Extensions Using JavaScript

A handy JavaScript function to get file extensions.

function fileExt(path) {
return path.substr(path.lastIndexOf(’.') + 1);
}

Sample Output
Input Output()
file.ext ext
/folder/subfolder/file.ext ext
file.bak.ext ext

[jQuery] weird error in globalEval

If I change the first line to
var head = document.documentElement,
it all works fine.In IE (but not in firefox) i suddenly got a ‘fatal’ error in globalEval; wrong argument passed in the last line, that says head.removeChild (script)..

In order to get things working again, i’ve had to make a small workaround:

globalEval: function( data ) {

data = jQuery.trim( data );if ( data ) {

// Inspired by code by Andrea Giammarchi

// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html

var head = document.getElementsByTagName("head")[0] || document.documentElement,

script = document.createElement("script");

script.type = "text/javascript";

if ( jQuery.browser.msie )

script.text = data;

else

script.appendChild( document.createTextNode( data ) );

head.appendChild( script );

try {

head.removeChild( script );

}

catch (e) {

}

}

},

If I change the first line to “var head = document.documentElement” it all works fine too

Кодировка внешнего файла скрипта

Кажется, не все в курсе. Чтобы генерируемый JavaScript-сценарием текст в кодировке, отличной от кодировки страницы, куда этот текст выводится, отображался корректно (это актуально, например, для Google Maps), достаточно добавить к соответствующему элементу script атрибут charset, явно указывающий на кодировку JS-файла:
<script … charset=”utf-8″></script>

Javascript in Ten Minutes

Basic Types

var intValue = 1;
var floatValue = 3.0;
var stringValue = "This is a string\n";
var sqString = 'This is also a string';

Javascript is a dynamically typed language. Variables are declared with the keyword var. Common simple types are supported.

Arrays

var emptyList = [];
var homogenousList = [1, 2, 3];
var heterogenousList = ["one", 2, 3.0];

Javascript has built-in collection objects. The Array object is a dynamically typed sequence of Javascript values. They are created with the bracket notation [] or with the new operator on the Array object (e.g. new Array(5)).
Read the rest of this entry »

jQuery Cheet Sheet

See more…..
Read the rest of this entry »

Javascript CPU-monitor

jpu.gifДемонстация здесь (http://www.3site.eu/JPU/demo.html). смотрим в правый верхний угол

Andrea Giammarchi создал небольшой (0,5 Kb) javascript мониторинга CPU.

Скрипт реализует монитор который отображает загрузку процессора клиента.
На мой взгляд, подобное решение может использоваться для оптимизации нагрузки на клиентский ПК, в процессе работы веб- приложениями требующего значительные ресурсы клиентского ПК (ajax решения и.т.д.).

Вставить скрипт себе на страницу можно так:

<script type=“text/javascript” src=“http://www.3site.eu/JPU/JPU.js”>
<!–//
JPU - by WebReflection
//–></script>

Запустить скрипт на данной страницы можно нажав тут
Более детально - тут.
З.Ы. Скрипт написан Just for fun - о сверх точности говорить пока рано.