מדיה ויקי:סקריפטים/62.js
קפיצה לניווט
קפיצה לחיפוש
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
// סקריפט 62: מלמד את תיבת "חיפוש והחלפה" בסרגל העריכה החדש לזכור את המחרוזות ותיבות הבחירה if ($.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit']) + 1) $(function() { // first half: searchbox (jQuery dialog) in source editor without syntax highlight. // opens from "advanced" toolbar var controls = '#wikieditor-toolbar-replace-search, #wikieditor-toolbar-replace-replace, #wikieditor-toolbar-replace-case, #wikieditor-toolbar-replace-regex'; $('body').on('change', controls, function() { var $this = $(this), val = $this.attr('type') == 'checkbox' ? $this.prop('checked') ? 'checked' : '' : $this.val(); $.cookie($this.attr('id'), val, {path: '/', expires: 30} ); }); $('body').on('dialogopen', '#wikieditor-toolbar-replace-dialog', function() { $.each(controls.split(/,\s*/), function(ind, name) { var control = $(name), val = $.cookie(name.replace('#','')); if (control.attr('type') == 'checkbox') control.prop('checked', val); else control.val(val); }); }); // end of first half // second half, handles the search panel in syntax-highlighintg editor, opens using Ctrl+F const observer = new MutationObserver(doIt), storageKey = 'SynSourceEditSearch'; observer.observe(document.body, { childList: true, subtree: true }); var didIt; function doIt() { const controls = { search: 'text', replace: 'text', 'case': 'checkbox', re: 'checkbox', word: 'checkbox' }; if (didIt) return; mw.loader.using('mediawiki.storage').done(function() { var config = mw.storage.getObject(storageKey) || {}; for (var control in controls) if (! $('input[name="' + control + '"]').length) return; for (control in controls) { var element = $('input[name="' + control + '"]'); didIt = true; if (element.prop('type') == 'checkbox') element.prop('checked', config[control]); else element.val(config[control]); element.on('change', function() { var $this = $(this); config[$this.attr('name')] = $this.prop('type') === 'checkbox' ? $this.prop('checked') : $this.val(); mw.storage.setObject(storageKey, config); }); } }); } // end of 2nd half });