Feature Profile Tester

Helps create the hashes for feature profiles on Mozilla Marketplace.

HTML

[<a href="javascript:;" class="fromsig" data-profile="0.46.3">CLEAR</a>]
[<a href="javascript:;" class="fromsig" data-profile="ffffffffffff.46.3">ALL</a>]
[<a href="javascript:;" class="fromsig" data-profile="1946aa0dc3d3.46.3">Fx Desktop</a>]
[<a href="javascript:;" class="fromsig" data-profile="1f5fbee9839b.46.3">FXOS (v1.1.0)</a>]
<br>
Profile Signature: <input id="profile">

<ul>
  <li><label for="id_has_apps"><input name="has_apps" id="id_has_apps" type="checkbox"> Apps</label></li>
  <li><label for="id_has_packaged_apps"><input name="has_packaged_apps" id="id_has_packaged_apps" type="checkbox"> Packaged apps</label></li>
  <li><label for="id_has_pay"><input name="has_pay" id="id_has_pay" type="checkbox"> Web Payment</label></li>
  <li><label for="id_has_activity"><input name="has_activity" id="id_has_activity" type="checkbox"> Web Activities</label></li>
  <li><label for="id_has_light_events"><input name="has_light_events" id="id_has_light_events" type="checkbox"> Ambient Light Sensor</label></li>
  <li><label for="id_has_archive"><input name="has_archive" id="id_has_archive" type="checkbox"> Archive</label></li>
  <li><label for="id_has_battery"><input name="has_battery" id="id_has_battery" type="checkbox"> Battery Status</label></li>
  <li><label for="id_has_bluetooth"><input name="has_bluetooth" id="id_has_bluetooth" type="checkbox"> Bluetooth</label></li>
  <li><label for="id_has_contacts"><input name="has_contacts" id="id_has_contacts" type="checkbox"> Contacts</label></li>
  <li><label for="id_has_device_storage"><input name="has_device_storage" id="id_has_device_storage" type="checkbox"> Device Storage</label></li>
  <li><label for="id_has_indexeddb"><input name="has_indexeddb" id="id_has_indexeddb" type="checkbox"> IndexedDB</label></li>
  <li><label for="id_has_geolocation"><input name="has_geolocation" id="id_has_geolocation" type="checkbox"> Geolocation</label></li>
  <li><label for="id_has_idle"><input name="has_idle" id="id_has_idle"...

JavaScript

$(document).ready(function() {
        
    var $boxes = $('input[type=checkbox]');
    
    function to_signature() {
        var flags = '';
        $boxes.each(function() {
            flags += $(this).is(':checked') ? '1' : '0';
        });
        profile = parseInt(flags, 2).toString(16);
        profile += '.' + $boxes.length + '.2';
        $('#profile').val(profile);
    }
    
    function _update_boxes(pro) {
        var flags = parseInt(pro.split('.')[0], 16).toString(2);
        $boxes.each(function(i) {
            $($boxes[i]).prop('checked', flags[i] === '1');
        });
    };
    
    function from_signature() {
        var pro = $(this).data('profile');
        $('#profile').val(pro);
        _update_boxes(pro);

    };
    
    function set_boxes_from_sig() {
        _update_boxes($('#profile').val());
    };
   
    $boxes.on('change', to_signature);
    $('.fromsig').on('click', from_signature);
    $('#profile').on('keyup paste blur', set_boxes_from_sig);

});