Skip to content

Instantly share code, notes, and snippets.

@ferlyz05
ferlyz05 / How to embed Javascript widget
Last active June 21, 2022 14:33
How to embed Javascript widget
(function(window, document, version, callback) {
var j, d;
var loaded = false;
if (!(j = window.jQuery) || version > j.fn.jquery || callback(j, loaded)) {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "/media/jquery.js";
script.onload = script.onreadystatechange = function() {
if (!loaded && (!(d = this.readyState) || d == "loaded" || d == "complete")) {
callback((j = window.jQuery).noConflict(1), loaded = true);
Note that the code snippets in this article have been tested in the latest Google Chrome version 30, which uses the V8 JavaScript Engine (V8 3.20.17.15).
1 – Don’t forget var keyword when assigning a variable’s value for the first time.
Assignment to an undeclared variable automatically results in a global variable being created. Avoid global variables.
2 – use === instead of ==
The == (or !=) operator performs an automatic type conversion if needed. The === (or !==) operator will not perform any conversion. It compares the value and the type, which could be considered faster than ==.
The template:
<img class="placeholder" src="avatar-small.jpg" width="200" height="200">
<img class="fullImage" src="avatar-large.jpg" width="200" height="200">
The CSS:
.fullImage {
transition: opacity 0.2s linear;
}
the javascript:
/* $sql = 'SELECT *
FROM pelanggan, (
SELECT id_pelanggan, COUNT( id ) AS total_promo, SUM( jumlah_resi ) AS jumlah_resi, SUM( total_nominal ) AS total_transaksi
FROM `promo`
GROUP BY id_pelanggan
) AS x
WHERE id = x.id_pelanggan'; */
$criteria = new CDbCriteria();
$criteria->compare('customer.nama',$this->nama,true);
Edit index-test.php:
$boot=dirname(__FILE__).'/protected/tests/bootstrap.php';
require_once($boot);
- Run CMD as Administrator
- cd C:\xampp\htdocs\contest2\protected\tests
- pear config-set auto_discover 1
- pear install pear.symfony.com/Yaml
- pear install --alldeps pear.phpunit.de/PHPUnit
- pear install Testing_Selenium-beta
function shorten_string($string, $wordsreturned)
/* Returns the first $wordsreturned out of $string. If string
contains fewer words than $wordsreturned, the entire string
is returned.
*/
{
$retval = $string; // Just in case of a problem
$array = explode(" ", $string);
if (count($array)<=$wordsreturned)
Dim s As String = ""
Dim bound0 As Integer = penampunganNilaiHujan.GetUpperBound(0)
Dim bound1 As Integer = penampunganNilaiHujan.GetUpperBound(1)
' Loop over all elements.
For i As Integer = 0 To bound0
For x As Integer = 0 To bound1
' Get element.
Dim s1 As String = penampunganNilaiHujan(i, x)
Public Class ListPusher
Public Value As Object
Public Description As String
Public Sub New(ByVal NewValue As Object, ByVal NewDescription As String)
Value = NewValue
Description = NewDescription
End Sub
Public Overrides Function ToString() As String
Public Module Example
Public Sub Main()
' Create a one-dimensional integer array.
Dim integers() As Integer = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 }
' Get the upper and lower bound of the array.
Dim upper As Integer = integers.GetUpperBound(0)
Dim lower As Integer = integers.GetLowerBound(0)
Console.WriteLine("Elements from index {0} to {1}:", lower, upper)
' Iterate the array.
For ctr As Integer = lower To upper
' Specific Cell Contents to string - (row 0, cell 0)
Dim s As String = Me.DataGridView1.Rows(0).Cells(0).Value
' Selected Cell
Dim s As String = Me.DataGridView1.SelectedCells(0).Value
' A single string containing all selected cell values
Dim s As String = ""