jQuery: click function exclude children.
|
1 2 3 4 5 |
$(".example").click(function(){ $(this).fadeOut("fast"); }).children().click(function(e) { return false; }); |
|
1 2 3 4 5 |
$(".example").click(function(){ $(this).fadeOut("fast"); }).children().click(function(e) { return false; }); |
Bytes(8 Bits) 0.1 bytes: A binary decision 1 byte: A single character 10 bytes: A single word 100 bytes: A telegram OR A punched card Kilobyte (1000 Bytes) 1 Kilobyte: A very short story 2 Kilobytes: A Typewritten page 10 Kilobytes: An encyclopaedic page OR A deck of punched cards 50 Kilobytes: A compressed document image page 100 Kilobytes: A low-resolution photograph 200 Kilobytes: A box […]
If you are looking to add and remove duplicate input fields, here’s another jQuery example below to do the task for you. This jQuery snippet adds duplicate input fields dynamically and stops when it reaches maximum. If you read comment lines carefully, the process is pretty straight forward. We start with 1 input field and […]
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
//==================== function check_previous_videos() { $output = array("exists" => false); // The $_REQUEST contains all the data sent via ajax if ( isset($_REQUEST) ) { $video_name = $_REQUEST['video_name']; $not_in = $_REQUEST['post_id']; $output ['not in'] = $not_in ; $query_array = array( "post_type" => "post", "meta_key" => "video", "meta_value" => $video_name, "post__not_in" => array($not_in)); $myquery = new WP_Query( $query_array); if($myquery->have_posts()){ $output ['exists'] = true; } } echo json_encode($output ); // Always die in functions echoing ajax content die(); } add_action( 'wp_ajax_check_previous_videos', 'check_previous_videos' ); function check_old_videos($hook) { wp_enqueue_script( 'my_custom_script', get_stylesheet_directory_uri(). '/js/sctipt.js' ); } add_action( 'admin_enqueue_scripts', 'check_old_videos' ); //==================== |
sctipt.js
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
$ = jQuery; jQuery(document).ready(function($) { // Validate New Password fields $("#acf-field-video").blur(function() { var __that = $(this); $("#publish").prop('disabled', true); $.ajax({ url: ajaxurl, data: { 'action': 'check_previous_videos', 'video_name': $("#acf-field-video").val(), 'post_id' :$("#post_ID").val() }, success: function(data) { // This outputs the result of the ajax request console.log(data); try { var obj = JSON.parse(data); if (obj.exists) { // $("#publish").prop('disabled', false); __that.css("border-color", "#ff0000"); } else { $("#publish").prop('disabled', false); __that.css("border-color", "#008000"); } } catch (e) {} }, error: function(errorThrown) { console.log(errorThrown); } }); }); }); |
If you are looking for delete cache of your own application then simply delete your cache directory and its all done !
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
public static void deleteCache(Context context) { try { File dir = context.getCacheDir(); deleteDir(dir); } catch (Exception e) {} } public static boolean deleteDir(File dir) { if (dir != null && dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { boolean success = deleteDir(new File(dir, children[i])); if (!success) { return false; } } return dir.delete(); } else if(dir!= null && dir.isFile()) { return dir.delete(); } else { return false; } } |
And you may require following permission to add in your manifest file in order to delete cache of other application
|
1 |
<uses-permission android:name="android.permission.CLEAR_APP_CACHE"/> |
Android Thread Constructs(Part 4): Comparisons In this series of posts we have seen the following thread constructs: 1. Basic threads and communication between them [see article] 2. Understanding the Main thread or the UI thread [see article] 3. IntentService [see article] 4. AsyncTask [see article] NOTE: These are Android specific constructs. Android also includes the […]
Do it without service http://www.rbgrn.net/content/307-light-racer-20-days-61-64-completion If you are so serious about doing it with services using media player
|
1 2 |
Intent svc=new Intent(this, BackgroundSoundService.class); startService(svc); |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
public class BackgroundSoundService extends Service { private static final String TAG = null; MediaPlayer player; public IBinder onBind(Intent arg0) { return null; } @Override public void onCreate() { super.onCreate(); player = MediaPlayer.create(this, R.raw.idil); player.setLooping(true); // Set looping player.setVolume(100,100); } public int onStartCommand(Intent intent, int flags, int startId) { player.start(); return 1; } public void onStart(Intent intent, int startId) { // TO DO } public IBinder onUnBind(Intent arg0) { // TO DO Auto-generated method return null; } public void onStop() { } public void onPause() { } @Override public void onDestroy() { player.stop(); player.release(); } @Override public void onLowMemory() { } } |
Please call this service in Manifest
|
1 |
<service android:enabled="true" android:name=".BackgroundSoundService " /> |
Google Chrome browser allows you import bookmarks, browsing history, and other settings from Internet Explorer or Firefox browser in a jiffy. But the only problem is it doesn’t have an option to export or backup stored passwords. Sure, there is a free extension called LastPass, but even it doesn’t help much either to have an […]
What is View? View class represents the basic building block for user interface components. A View occupies a rectangular area on the screen and is responsible for drawing and event handling. View is the base class for widgets, which are used to create interactive UI components (buttons, text fields, etc.). The ViewGroup subclass is the […]
getWidth() and getHeight return zero after onMeasure() (specific devices) Use getMeasuredWidth/Height() here. getWidth/Height() aren’t valid until after a layout.