This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
onny:notizen:programmierung [2022/03/07 13:26] – [wordpress] 141.52.248.2 | onny:notizen:programmierung [2022/09/28 14:37] – [javascript] 10.25.40.1 | ||
---|---|---|---|
Line 176: | Line 176: | ||
</ | </ | ||
===== javascript ===== | ===== javascript ===== | ||
+ | |||
split up javascript files | split up javascript files | ||
+ | |||
<code javascript> | <code javascript> | ||
var MODULE = (function (my) { | var MODULE = (function (my) { | ||
Line 192: | Line 194: | ||
}(MODULE || {})); | }(MODULE || {})); | ||
</ | </ | ||
- | jquery select by attribute content | + | |
+ | on document ready | ||
<code javascript> | <code javascript> | ||
- | $( "tr[data-id=' | + | document.addEventListener("DOMContentLoaded", function() { |
- | </ | + | |
- | jquery select dynamicly loaded ajax elements | + | |
- | <code javascript> | + | |
- | $(' | + | |
- | | + | |
- | load_page(link); | + | |
}); | }); | ||
+ | |||
</ | </ | ||
- | jquery set background color | + | |
- | <code javascript> | + | change content text |
- | $(this).parent().css(" | + | |
- | </ | + | |
- | print mixed objects | + | |
- | <code javascript> | + | |
- | console.log(' | + | |
- | </ | + | |
- | javascript document ready | + | |
- | <code javascript> | + | |
- | $(document).ready(function(){ | + | |
- | console.log(' | + | |
- | }); | + | |
- | </ | + | |
- | vanilla js change content text | + | |
<code javascript> | <code javascript> | ||
var webgl_field = document.getElementById(' | var webgl_field = document.getElementById(' | ||
Line 226: | Line 214: | ||
} | } | ||
</ | </ | ||
- | vanilla js ajax post form | + | |
+ | ajax post form | ||
<code javascript> | <code javascript> | ||
document.getElementById(' | document.getElementById(' | ||
Line 244: | Line 234: | ||
} | } | ||
</ | </ | ||
- | vanilla js change style element | + | |
+ | change style element | ||
<code javascript> | <code javascript> | ||
function show_create_post() { | function show_create_post() { | ||
Line 257: | Line 249: | ||
trim string to max length | trim string to max length | ||
+ | |||
<code javascript> | <code javascript> | ||
var string = string.substring(0, | var string = string.substring(0, | ||
</ | </ | ||
- | vanilla js onclick class element | + | onclick class element |
<code javascript> | <code javascript> | ||
document.getElementsByClassName(' | document.getElementsByClassName(' | ||
console.log(' | console.log(' | ||
}; | }; | ||
+ | </ | ||
+ | |||
+ | onclick on all class elements | ||
+ | |||
+ | <code javascript> | ||
+ | var anchors = document.getElementsByClassName(' | ||
+ | for(var i = 0; i < anchors.length; | ||
+ | var anchor = anchors[i]; | ||
+ | anchor.onclick = function() { | ||
+ | console.log(' | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | remove class from element | ||
+ | |||
+ | <code javascript> | ||
+ | var element = document.getElementsByClassName(' | ||
+ | element.classList.remove(" | ||
+ | </ | ||
+ | |||
+ | get url and pathname | ||
+ | |||
+ | <code javascript> | ||
+ | console.log(window.location.url) | ||
+ | console.log(window.location.pathname) | ||
</ | </ | ||
==== vuejs ==== | ==== vuejs ==== | ||
Line 615: | Line 635: | ||
margin-left: | margin-left: | ||
} | } | ||
+ | </ | ||
+ | |||
+ | custom menu walker, only printing <a> tags without list items | ||
+ | <code php> | ||
+ | class Nav_Footer_Walker extends Walker_Nav_Menu { | ||
+ | |||
+ | function start_lvl( & | ||
+ | $indent = str_repeat(" | ||
+ | $output .= " | ||
+ | } | ||
+ | |||
+ | function end_lvl( & | ||
+ | $indent = str_repeat(" | ||
+ | $output .= " | ||
+ | } | ||
+ | |||
+ | function start_el( & | ||
+ | $indent = ( $depth ) ? str_repeat( " | ||
+ | |||
+ | $class_names = $value = ''; | ||
+ | |||
+ | $classes = empty( $item-> | ||
+ | $classes[] = ' | ||
+ | |||
+ | $class_names = join( ' ', apply_filters( ' | ||
+ | $class_names = $class_names ? ' class="' | ||
+ | |||
+ | $id = apply_filters( ' | ||
+ | $id = $id ? ' id="' | ||
+ | |||
+ | $output .= $indent . ''; | ||
+ | |||
+ | $attributes | ||
+ | $attributes .= ! empty( $item-> | ||
+ | $attributes .= ! empty( $item-> | ||
+ | $attributes .= ! empty( $item-> | ||
+ | |||
+ | $item_output = $args-> | ||
+ | $item_output .= '<a class=" | ||
+ | $item_output .= $args-> | ||
+ | $item_output .= '</ | ||
+ | $item_output .= $args-> | ||
+ | |||
+ | $output .= apply_filters( ' | ||
+ | } | ||
+ | |||
+ | |||
+ | function end_el( & | ||
+ | $output .= " | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | wp_nav_menu( array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ) ); | ||
+ | </ | ||
+ | |||
+ | customizer add option custom text | ||
+ | <code php> | ||
+ | function theme_customize_register( $wp_customize ) { | ||
+ | |||
+ | $wp_customize-> | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ),); | ||
+ | |||
+ | $wp_customize-> | ||
+ | $wp_customize, | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ) | ||
+ | ) ); | ||
+ | |||
+ | } | ||
+ | |||
+ | add_action( ' | ||
+ | </ | ||
+ | |||
+ | add custom javascript js | ||
+ | |||
+ | <code php> | ||
+ | function twentytwentytwo_enqueue_custom_js() { | ||
+ | wp_enqueue_script(' | ||
+ | } | ||
+ | |||
+ | add_action( ' | ||
</ | </ | ||
===== sql ===== | ===== sql ===== | ||
Line 650: | Line 766: | ||
==== mysql ==== | ==== mysql ==== | ||
- | |||
- | Dump database | ||
- | <code bash> | ||
- | mysqldump -u root -p Tutorials > tut_backup.sql | ||
- | </ | ||
- | |||
- | Backup everything | ||
- | <code bash> | ||
- | mysqldump -u root -p --all-databases > alldb.sql | ||
- | </ | ||
- | |||
- | Import database | ||
- | < | ||
- | mysql> CREATE DATABASE wordpress; | ||
- | sudo mysql -u root wordpress < wordpress.sql | ||
- | </ | ||
- | |||
- | Setup | ||
- | <code bash> | ||
- | systemctl stop mysqld | ||
- | mysql_install_db --user=mysql --basedir=/ | ||
- | systemctl start mysqld | ||
- | mysql_secure_installation | ||
- | </ | ||
delete specific row | delete specific row | ||
Line 685: | Line 777: | ||
</ | </ | ||
+ | adjust permissions to table | ||
+ | <code sql> | ||
+ | CREATE USER ' | ||
+ | GRANT ALL PRIVILEGES ON ninja.* TO ' | ||
+ | GRANT ALL PRIVILEGES ON ninja.* TO ' | ||
+ | FLUSH PRIVILEGES; | ||
+ | </ | ||
+ | |||
+ | update statement | ||
+ | |||
+ | <code sql> | ||
+ | UPDATE wp_options SET option_value = ' | ||
+ | </ | ||
==== postgresql ==== | ==== postgresql ==== | ||
Line 696: | Line 801: | ||
< | < | ||
psql# \l | psql# \l | ||
- | </ | ||
- | |||
- | dump database | ||
- | < | ||
- | pg_dump -U gitlab gitlabhq_production > / | ||
- | </ | ||
- | |||
- | dump all | ||
- | < | ||
- | pg_dumpall > / | ||
- | </ | ||
- | |||
- | import database | ||
- | < | ||
- | psql# CREATE DATABASE gitlabhq_production; | ||
- | psql -U gitlab gitlabhq_production < gitlab.pgsql | ||
</ | </ | ||